convert VB to C#
This commit is contained in:
113
Pilz.Configuration/AutoSaveConfigurationManager.cs
Normal file
113
Pilz.Configuration/AutoSaveConfigurationManager.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
|
||||
namespace Pilz.Configuration
|
||||
{
|
||||
public class AutoSaveConfigurationManager : ConfigurationManager
|
||||
{
|
||||
private bool addedHandler = false;
|
||||
private bool enableAutoSave = false;
|
||||
private string _ConfigFilePath = string.Empty;
|
||||
private bool _AutoLoadConfigOnAccess = false;
|
||||
|
||||
public string ConfigFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ConfigFilePath;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_ConfigFilePath = value;
|
||||
if (AutoLoadConfigOnAccess)
|
||||
Load();
|
||||
}
|
||||
}
|
||||
|
||||
public bool AutoLoadConfigOnAccess
|
||||
{
|
||||
get
|
||||
{
|
||||
return _AutoLoadConfigOnAccess;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_AutoLoadConfigOnAccess = value;
|
||||
if (value)
|
||||
Load();
|
||||
}
|
||||
}
|
||||
|
||||
public bool AutoSaveConfigOnExit
|
||||
{
|
||||
get
|
||||
{
|
||||
return enableAutoSave;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (enableAutoSave != value)
|
||||
{
|
||||
enableAutoSave = value;
|
||||
switch (enableAutoSave)
|
||||
{
|
||||
case true:
|
||||
{
|
||||
AddAutoSaveHandler();
|
||||
break;
|
||||
}
|
||||
|
||||
case false:
|
||||
{
|
||||
RemoveAutoSaveHandler();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddAutoSaveHandler()
|
||||
{
|
||||
if (!addedHandler)
|
||||
{
|
||||
System.Windows.Forms.Application.ApplicationExit += AutoSaveSettingsOnExit;
|
||||
addedHandler = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveAutoSaveHandler()
|
||||
{
|
||||
System.Windows.Forms.Application.ApplicationExit -= AutoSaveSettingsOnExit;
|
||||
addedHandler = false;
|
||||
}
|
||||
|
||||
private void AutoSaveSettingsOnExit(object sender, EventArgs e)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ConfigFilePath) && Configuration is object)
|
||||
{
|
||||
Configuration.WriteToFile(ConfigFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ConfigFilePath))
|
||||
{
|
||||
Configuration.ReadFromFile(ConfigFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
~AutoSaveConfigurationManager()
|
||||
{
|
||||
RemoveAutoSaveHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
Public Class AutoSaveConfigurationManager
|
||||
Inherits ConfigurationManager
|
||||
|
||||
Private addedHandler As Boolean = False
|
||||
Private enableAutoSave As Boolean = False
|
||||
Private _ConfigFilePath As String = String.Empty
|
||||
Private _AutoLoadConfigOnAccess As Boolean = False
|
||||
|
||||
Public Property ConfigFilePath As String
|
||||
Get
|
||||
Return _ConfigFilePath
|
||||
End Get
|
||||
Set
|
||||
_ConfigFilePath = Value
|
||||
If AutoLoadConfigOnAccess Then Load()
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property AutoLoadConfigOnAccess As Boolean
|
||||
Get
|
||||
Return _AutoLoadConfigOnAccess
|
||||
End Get
|
||||
Set
|
||||
_AutoLoadConfigOnAccess = Value
|
||||
If Value Then Load()
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property AutoSaveConfigOnExit As Boolean
|
||||
Get
|
||||
Return enableAutoSave
|
||||
End Get
|
||||
Set
|
||||
If enableAutoSave <> Value Then
|
||||
enableAutoSave = Value
|
||||
Select Case enableAutoSave
|
||||
Case True
|
||||
AddAutoSaveHandler()
|
||||
Case False
|
||||
RemoveAutoSaveHandler()
|
||||
End Select
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Sub AddAutoSaveHandler()
|
||||
If Not addedHandler Then
|
||||
AddHandler Windows.Forms.Application.ApplicationExit, AddressOf AutoSaveSettingsOnExit
|
||||
addedHandler = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub RemoveAutoSaveHandler()
|
||||
RemoveHandler Windows.Forms.Application.ApplicationExit, AddressOf AutoSaveSettingsOnExit
|
||||
addedHandler = False
|
||||
End Sub
|
||||
|
||||
Private Sub AutoSaveSettingsOnExit(sender As Object, e As EventArgs)
|
||||
Save()
|
||||
End Sub
|
||||
|
||||
Private Sub Save()
|
||||
If Not String.IsNullOrEmpty(ConfigFilePath) AndAlso Configuration IsNot Nothing Then
|
||||
Configuration.WriteToFile(ConfigFilePath)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub Load()
|
||||
If Not String.IsNullOrEmpty(ConfigFilePath) Then
|
||||
Configuration.ReadFromFile(ConfigFilePath)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub Finalize()
|
||||
RemoveAutoSaveHandler()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
13
Pilz.Configuration/ConfigurationManager.cs
Normal file
13
Pilz.Configuration/ConfigurationManager.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
namespace Pilz.Configuration
|
||||
{
|
||||
public abstract class ConfigurationManager
|
||||
{
|
||||
public SimpleConfiguration Configuration { get; private set; }
|
||||
|
||||
internal void SetConfiguration(SimpleConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
Public MustInherit Class ConfigurationManager
|
||||
|
||||
Public ReadOnly Property Configuration As SimpleConfiguration
|
||||
|
||||
Friend Sub SetConfiguration(configuration As SimpleConfiguration)
|
||||
_Configuration = configuration
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
104
Pilz.Configuration/ConfigurationManagerList.cs
Normal file
104
Pilz.Configuration/ConfigurationManagerList.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using global::Pilz.GeneralEventArgs;
|
||||
|
||||
namespace Pilz.Configuration
|
||||
{
|
||||
public class ConfigurationManagerList : IList<ConfigurationManager>
|
||||
{
|
||||
public event GettingParentManagerEventHandler GettingParentManager;
|
||||
|
||||
public delegate void GettingParentManagerEventHandler(object sender, GetValueEventArgs<SimpleConfiguration> e);
|
||||
|
||||
private readonly List<ConfigurationManager> myList = new List<ConfigurationManager>();
|
||||
|
||||
private object GetParentManager()
|
||||
{
|
||||
var args = new GetValueEventArgs<SimpleConfiguration>();
|
||||
GettingParentManager?.Invoke(this, args);
|
||||
return args.Value;
|
||||
}
|
||||
|
||||
public ConfigurationManager this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return myList[index];
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
myList[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return myList.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Insert(int index, ConfigurationManager item)
|
||||
{
|
||||
myList.Insert(index, item);
|
||||
item.SetConfiguration((SimpleConfiguration)GetParentManager());
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
}
|
||||
|
||||
public void Add(ConfigurationManager item)
|
||||
{
|
||||
item.SetConfiguration((SimpleConfiguration)GetParentManager());
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
foreach (ConfigurationManager item in myList)
|
||||
item.SetConfiguration(null);
|
||||
myList.Clear();
|
||||
}
|
||||
|
||||
public void CopyTo(ConfigurationManager[] array, int arrayIndex)
|
||||
{
|
||||
myList.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public int IndexOf(ConfigurationManager item)
|
||||
{
|
||||
return myList.IndexOf(item);
|
||||
}
|
||||
|
||||
public bool Contains(ConfigurationManager item)
|
||||
{
|
||||
return myList.Contains(item);
|
||||
}
|
||||
|
||||
public bool Remove(ConfigurationManager item)
|
||||
{
|
||||
item.SetConfiguration(null);
|
||||
return myList.Remove(item);
|
||||
}
|
||||
|
||||
public IEnumerator<ConfigurationManager> GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return myList.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
Imports Pilz.Configuration
|
||||
Imports Pilz.GeneralEventArgs
|
||||
|
||||
Public Class ConfigurationManagerList
|
||||
Implements IList(Of ConfigurationManager)
|
||||
|
||||
Public Event GettingParentManager(sender As Object, e As GetValueEventArgs(Of SimpleConfiguration))
|
||||
|
||||
Private ReadOnly myList As New List(Of ConfigurationManager)
|
||||
|
||||
Private Function GetParentManager()
|
||||
Dim args As New GetValueEventArgs(Of SimpleConfiguration)
|
||||
RaiseEvent GettingParentManager(Me, args)
|
||||
Return args.Value
|
||||
End Function
|
||||
|
||||
Default Public Property Item(index As Integer) As ConfigurationManager Implements IList(Of ConfigurationManager).Item
|
||||
Get
|
||||
Return myList(index)
|
||||
End Get
|
||||
Set(value As ConfigurationManager)
|
||||
myList(index) = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property Count As Integer Implements ICollection(Of ConfigurationManager).Count
|
||||
Get
|
||||
Return myList.Count
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property IsReadOnly As Boolean Implements ICollection(Of ConfigurationManager).IsReadOnly
|
||||
Get
|
||||
Return False
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub Insert(index As Integer, item As ConfigurationManager) Implements IList(Of ConfigurationManager).Insert
|
||||
myList.Insert(index, item)
|
||||
item.SetConfiguration(GetParentManager)
|
||||
End Sub
|
||||
|
||||
Public Sub RemoveAt(index As Integer) Implements IList(Of ConfigurationManager).RemoveAt
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub Add(item As ConfigurationManager) Implements ICollection(Of ConfigurationManager).Add
|
||||
item.SetConfiguration(GetParentManager)
|
||||
End Sub
|
||||
|
||||
Public Sub Clear() Implements ICollection(Of ConfigurationManager).Clear
|
||||
For Each item As ConfigurationManager In myList
|
||||
item.SetConfiguration(Nothing)
|
||||
Next
|
||||
myList.Clear()
|
||||
End Sub
|
||||
|
||||
Public Sub CopyTo(array() As ConfigurationManager, arrayIndex As Integer) Implements ICollection(Of ConfigurationManager).CopyTo
|
||||
myList.CopyTo(array, arrayIndex)
|
||||
End Sub
|
||||
|
||||
Public Function IndexOf(item As ConfigurationManager) As Integer Implements IList(Of ConfigurationManager).IndexOf
|
||||
Return myList.IndexOf(item)
|
||||
End Function
|
||||
|
||||
Public Function Contains(item As ConfigurationManager) As Boolean Implements ICollection(Of ConfigurationManager).Contains
|
||||
Return myList.Contains(item)
|
||||
End Function
|
||||
|
||||
Public Function Remove(item As ConfigurationManager) As Boolean Implements ICollection(Of ConfigurationManager).Remove
|
||||
item.SetConfiguration(Nothing)
|
||||
Return myList.Remove(item)
|
||||
End Function
|
||||
|
||||
Public Function GetEnumerator() As IEnumerator(Of ConfigurationManager) Implements IEnumerable(Of ConfigurationManager).GetEnumerator
|
||||
Return IEnumerable_GetEnumerator()
|
||||
End Function
|
||||
|
||||
Private Function IEnumerable_GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
|
||||
Return myList.GetEnumerator
|
||||
End Function
|
||||
|
||||
End Class
|
||||
139
Pilz.Configuration/ConfigurationSerializer.cs
Normal file
139
Pilz.Configuration/ConfigurationSerializer.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using global::System.IO;
|
||||
using global::Newtonsoft.Json;
|
||||
using global::Pilz.GeneralEventArgs;
|
||||
|
||||
namespace Pilz.Configuration
|
||||
{
|
||||
public static class ConfigurationSerializer
|
||||
{
|
||||
public static event GettingJsonSerializerEventHandler GettingJsonSerializer;
|
||||
|
||||
public delegate void GettingJsonSerializerEventHandler(object instance, GetValueEventArgs<JsonSerializer> e);
|
||||
|
||||
private static JsonSerializer GetJsonSerializer(SimpleConfiguration instance)
|
||||
{
|
||||
var args = new GetValueEventArgs<JsonSerializer>(JsonSerializer.CreateDefault());
|
||||
GettingJsonSerializer?.Invoke(instance, args);
|
||||
return args.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the given instance to a string and return it.
|
||||
/// </summary>
|
||||
/// <param name="instance">The configuration instance that should be serialized.</param>
|
||||
/// <returns>The content of the configuration instance as string.</returns>
|
||||
public static string WriteToString(SimpleConfiguration instance)
|
||||
{
|
||||
var tw = new StringWriter();
|
||||
GetJsonSerializer(instance).Serialize(tw, instance);
|
||||
string txt = tw.ToString();
|
||||
tw.Close();
|
||||
return txt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write the given instance to a given stream.
|
||||
/// </summary>
|
||||
/// <param name="instance">The configuration instance that should be serialized.</param>
|
||||
/// <param name="stream">The stream where the content should be written to.</param>
|
||||
public static void WriteToStream(SimpleConfiguration instance, Stream stream)
|
||||
{
|
||||
var sr = new StreamWriter(stream);
|
||||
sr.Write(WriteToString(instance));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the given instance to the given filePath as text file.
|
||||
/// </summary>
|
||||
/// <param name="instance">The configuration instance that should be serialized.</param>
|
||||
/// <param name="filePath">The file path where the content should be written to. The file will be created or overwritten.</param>
|
||||
public static void WriteToFile(SimpleConfiguration instance, string filePath)
|
||||
{
|
||||
var fs = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite);
|
||||
WriteToStream(instance, fs);
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a configuratin from the given string and returns an instance of it.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
/// <param name="content">The content of the configuration as string.</param>
|
||||
/// <returns></returns>
|
||||
public static T ReadFromString<T>(string content) where T : SimpleConfiguration
|
||||
{
|
||||
var sr = new StringReader(content);
|
||||
T instance = (T)GetJsonSerializer(null).Deserialize(sr, typeof(T));
|
||||
sr.Close();
|
||||
return instance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a configuration from the given string and put them to the given instance.
|
||||
/// </summary>
|
||||
/// <param name="instance">The instance to populate with the configuration.</param>
|
||||
/// <param name="content">The content of the configuration as string.</param>
|
||||
public static void ReadFromString(SimpleConfiguration instance, string content)
|
||||
{
|
||||
var sr = new StringReader(content);
|
||||
GetJsonSerializer(null).Populate(sr, content);
|
||||
sr.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a configuratin from the given string and returns an instance of it.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
/// <param name="stream">The stream with the content of the configuration.</param>
|
||||
/// <returns></returns>
|
||||
public static T ReadFromStream<T>(Stream stream) where T : SimpleConfiguration
|
||||
{
|
||||
return ReadFromString<T>(GetContentOfStream(stream));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a configuration from the given string and put them to the given instance.
|
||||
/// </summary>
|
||||
/// <param name="instance">The instance to populate with the configuration.</param>
|
||||
/// <param name="stream">The stream with the content of the configuration.</param>
|
||||
public static void ReadFromStream(SimpleConfiguration instance, Stream stream)
|
||||
{
|
||||
ReadFromString(instance, GetContentOfStream(stream));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a configuratin from the given string and returns an instance of it.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
/// <param name="filePath">The path to the file with the content of the configuration.</param>
|
||||
/// <returns></returns>
|
||||
public static T ReadFromFile<T>(string filePath) where T : SimpleConfiguration
|
||||
{
|
||||
return ReadFromString<T>(GetContentOfFile(filePath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a configuration from the given string and put them to the given instance.
|
||||
/// </summary>
|
||||
/// <param name="instance">The instance to populate with the configuration.</param>
|
||||
/// <param name="filePath">The path to the file with the content of the configuration.</param>
|
||||
public static void ReadFromFile(SimpleConfiguration instance, string filePath)
|
||||
{
|
||||
ReadFromString(instance, GetContentOfFile(filePath));
|
||||
}
|
||||
|
||||
private static string GetContentOfStream(Stream stream)
|
||||
{
|
||||
var sr = new StreamReader(stream);
|
||||
return sr.ReadToEnd();
|
||||
}
|
||||
|
||||
private static string GetContentOfFile(string filePath)
|
||||
{
|
||||
var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
||||
string content = GetContentOfStream(fs);
|
||||
fs.Close();
|
||||
return content;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
Imports System.IO
|
||||
Imports Newtonsoft.Json
|
||||
Imports Pilz.GeneralEventArgs
|
||||
|
||||
Public Module ConfigurationSerializer
|
||||
|
||||
Public Event GettingJsonSerializer(instance As Object, e As GetValueEventArgs(Of JsonSerializer))
|
||||
|
||||
Private Function GetJsonSerializer(instance As SimpleConfiguration) As JsonSerializer
|
||||
Dim args As New GetValueEventArgs(Of JsonSerializer)(JsonSerializer.CreateDefault)
|
||||
RaiseEvent GettingJsonSerializer(instance, args)
|
||||
Return args.Value
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Writes the given instance to a string and return it.
|
||||
''' </summary>
|
||||
''' <param name="instance">The configuration instance that should be serialized.</param>
|
||||
''' <returns>The content of the configuration instance as string.</returns>
|
||||
Public Function WriteToString(instance As SimpleConfiguration) As String
|
||||
Dim tw As New StringWriter
|
||||
GetJsonSerializer(instance).Serialize(tw, instance)
|
||||
Dim txt = tw.ToString
|
||||
tw.Close()
|
||||
Return txt
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Write the given instance to a given stream.
|
||||
''' </summary>
|
||||
''' <param name="instance">The configuration instance that should be serialized.</param>
|
||||
''' <param name="stream">The stream where the content should be written to.</param>
|
||||
Public Sub WriteToStream(instance As SimpleConfiguration, stream As Stream)
|
||||
Dim sr As New StreamWriter(stream)
|
||||
sr.Write(WriteToString(instance))
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Writes the given instance to the given filePath as text file.
|
||||
''' </summary>
|
||||
''' <param name="instance">The configuration instance that should be serialized.</param>
|
||||
''' <param name="filePath">The file path where the content should be written to. The file will be created or overwritten.</param>
|
||||
Public Sub WriteToFile(instance As SimpleConfiguration, filePath As String)
|
||||
Dim fs As New FileStream(filePath, FileMode.Create, FileAccess.ReadWrite)
|
||||
WriteToStream(instance, fs)
|
||||
fs.Close()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Reads a configuratin from the given string and returns an instance of it.
|
||||
''' </summary>
|
||||
''' <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
''' <param name="content">The content of the configuration as string.</param>
|
||||
''' <returns></returns>
|
||||
Public Function ReadFromString(Of T As SimpleConfiguration)(content As String) As T
|
||||
Dim sr As New StringReader(content)
|
||||
Dim instance As T = GetJsonSerializer(Nothing).Deserialize(sr, GetType(T))
|
||||
sr.Close()
|
||||
Return instance
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Read a configuration from the given string and put them to the given instance.
|
||||
''' </summary>
|
||||
''' <param name="instance">The instance to populate with the configuration.</param>
|
||||
''' <param name="content">The content of the configuration as string.</param>
|
||||
Public Sub ReadFromString(instance As SimpleConfiguration, content As String)
|
||||
Dim sr As New StringReader(content)
|
||||
GetJsonSerializer(Nothing).Populate(sr, content)
|
||||
sr.Close()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Reads a configuratin from the given string and returns an instance of it.
|
||||
''' </summary>
|
||||
''' <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
''' <param name="stream">The stream with the content of the configuration.</param>
|
||||
''' <returns></returns>
|
||||
Public Function ReadFromStream(Of T As SimpleConfiguration)(stream As Stream) As T
|
||||
Return ReadFromString(Of T)(GetContentOfStream(stream))
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Read a configuration from the given string and put them to the given instance.
|
||||
''' </summary>
|
||||
''' <param name="instance">The instance to populate with the configuration.</param>
|
||||
''' <param name="stream">The stream with the content of the configuration.</param>
|
||||
Public Sub ReadFromStream(instance As SimpleConfiguration, stream As Stream)
|
||||
ReadFromString(instance, GetContentOfStream(stream))
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Reads a configuratin from the given string and returns an instance of it.
|
||||
''' </summary>
|
||||
''' <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
''' <param name="filePath">The path to the file with the content of the configuration.</param>
|
||||
''' <returns></returns>
|
||||
Public Function ReadFromFile(Of T As SimpleConfiguration)(filePath As String) As T
|
||||
Return ReadFromString(Of T)(GetContentOfFile(filePath))
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Read a configuration from the given string and put them to the given instance.
|
||||
''' </summary>
|
||||
''' <param name="instance">The instance to populate with the configuration.</param>
|
||||
''' <param name="filePath">The path to the file with the content of the configuration.</param>
|
||||
Public Sub ReadFromFile(instance As SimpleConfiguration, filePath As String)
|
||||
ReadFromString(instance, GetContentOfFile(filePath))
|
||||
End Sub
|
||||
|
||||
Private Function GetContentOfStream(stream As Stream) As String
|
||||
Dim sr As New StreamReader(stream)
|
||||
Return sr.ReadToEnd
|
||||
End Function
|
||||
|
||||
Private Function GetContentOfFile(filePath As String) As String
|
||||
Dim fs As New FileStream(filePath, FileMode.Open, FileAccess.Read)
|
||||
Dim content = GetContentOfStream(fs)
|
||||
fs.Close()
|
||||
Return content
|
||||
End Function
|
||||
|
||||
End Module
|
||||
12
Pilz.Configuration/ISettingsManager.cs
Normal file
12
Pilz.Configuration/ISettingsManager.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
namespace Pilz.Configuration
|
||||
{
|
||||
public interface ISettingsManager
|
||||
{
|
||||
string ConfigFilePath { get; set; }
|
||||
|
||||
void Save();
|
||||
void Load();
|
||||
void Reset();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
Public Interface ISettingsManager
|
||||
Property ConfigFilePath As String
|
||||
Sub Save()
|
||||
Sub Load()
|
||||
Sub Reset()
|
||||
End Interface
|
||||
11
Pilz.Configuration/My Project/Application.Designer.cs
generated
Normal file
11
Pilz.Configuration/My Project/Application.Designer.cs
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Dieser Code wurde von einem Tool generiert.
|
||||
// Laufzeitversion:4.0.30319.42000
|
||||
//
|
||||
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
// der Code erneut generiert wird.
|
||||
// </auto-generated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
' die einer Assembly zugeordnet sind.
|
||||
|
||||
' Werte der Assemblyattribute überprüfen
|
||||
|
||||
<Assembly: AssemblyTitle("Pilz.Configuration")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("DRSN")>
|
||||
<Assembly: AssemblyProduct("Pilz.Configuration")>
|
||||
<Assembly: AssemblyCopyright("Copyright © DRSN 2019")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird.
|
||||
<Assembly: Guid("3980caa6-d118-4166-8f0d-e91c9dc07e3c")>
|
||||
|
||||
' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
'
|
||||
' Hauptversion
|
||||
' Nebenversion
|
||||
' Buildnummer
|
||||
' Revision
|
||||
'
|
||||
' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
192
Pilz.Configuration/My Project/MyNamespace.Static.1.Designer.cs
generated
Normal file
192
Pilz.Configuration/My Project/MyNamespace.Static.1.Designer.cs
generated
Normal file
@@ -0,0 +1,192 @@
|
||||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia */
|
||||
/* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia *//* TODO ERROR: Skipped DefineDirectiveTrivia */
|
||||
/* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
namespace Pilz.Configuration.My
|
||||
{
|
||||
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
[System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped ElifDirectiveTrivia */
|
||||
internal partial class MyApplication : Microsoft.VisualBasic.ApplicationServices.ApplicationBase
|
||||
{
|
||||
/* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
}
|
||||
|
||||
/* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
[System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
internal partial class MyComputer : Microsoft.VisualBasic.Devices.Computer
|
||||
{
|
||||
/* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
[DebuggerHidden()]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public MyComputer() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
/* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
[HideModuleName()]
|
||||
[System.CodeDom.Compiler.GeneratedCode("MyTemplate", "11.0.0.0")]
|
||||
internal static class MyProject
|
||||
{
|
||||
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
[System.ComponentModel.Design.HelpKeyword("My.Computer")]
|
||||
internal static MyComputer Computer
|
||||
{
|
||||
[DebuggerHidden()]
|
||||
get
|
||||
{
|
||||
return m_ComputerObjectProvider.GetInstance;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly static ThreadSafeObjectProvider<MyComputer> m_ComputerObjectProvider = new ThreadSafeObjectProvider<MyComputer>();
|
||||
/* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
[System.ComponentModel.Design.HelpKeyword("My.Application")]
|
||||
internal static MyApplication Application
|
||||
{
|
||||
[DebuggerHidden()]
|
||||
get
|
||||
{
|
||||
return m_AppObjectProvider.GetInstance;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly static ThreadSafeObjectProvider<MyApplication> m_AppObjectProvider = new ThreadSafeObjectProvider<MyApplication>();
|
||||
/* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
[System.ComponentModel.Design.HelpKeyword("My.User")]
|
||||
internal static Microsoft.VisualBasic.ApplicationServices.User User
|
||||
{
|
||||
[DebuggerHidden()]
|
||||
get
|
||||
{
|
||||
return m_UserObjectProvider.GetInstance;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly static ThreadSafeObjectProvider<Microsoft.VisualBasic.ApplicationServices.User> m_UserObjectProvider = new ThreadSafeObjectProvider<Microsoft.VisualBasic.ApplicationServices.User>();
|
||||
/* TODO ERROR: Skipped ElifDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
[System.ComponentModel.Design.HelpKeyword("My.WebServices")]
|
||||
internal static MyWebServices WebServices
|
||||
{
|
||||
[DebuggerHidden()]
|
||||
get
|
||||
{
|
||||
return m_MyWebServicesObjectProvider.GetInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
[MyGroupCollection("System.Web.Services.Protocols.SoapHttpClientProtocol", "Create__Instance__", "Dispose__Instance__", "")]
|
||||
internal sealed class MyWebServices
|
||||
{
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
[DebuggerHidden()]
|
||||
public override bool Equals(object o)
|
||||
{
|
||||
return base.Equals(o);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
[DebuggerHidden()]
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
[DebuggerHidden()]
|
||||
internal new Type GetType()
|
||||
{
|
||||
return typeof(MyWebServices);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
[DebuggerHidden()]
|
||||
public override string ToString()
|
||||
{
|
||||
return base.ToString();
|
||||
}
|
||||
|
||||
[DebuggerHidden()]
|
||||
private static T Create__Instance__<T>(T instance) where T : new()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
return new T();
|
||||
}
|
||||
else
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
[DebuggerHidden()]
|
||||
private void Dispose__Instance__<T>(ref T instance)
|
||||
{
|
||||
instance = default;
|
||||
}
|
||||
|
||||
[DebuggerHidden()]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public MyWebServices() : base()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private readonly static ThreadSafeObjectProvider<MyWebServices> m_MyWebServicesObjectProvider = new ThreadSafeObjectProvider<MyWebServices>();
|
||||
/* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
[System.Runtime.InteropServices.ComVisible(false)]
|
||||
internal sealed class ThreadSafeObjectProvider<T> where T : new()
|
||||
{
|
||||
internal T GetInstance
|
||||
{
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
[DebuggerHidden()]
|
||||
get
|
||||
{
|
||||
var Value = m_Context.Value;
|
||||
if (Value == null)
|
||||
{
|
||||
Value = new T();
|
||||
m_Context.Value = Value;
|
||||
}
|
||||
|
||||
return Value;
|
||||
}
|
||||
/* TODO ERROR: Skipped ElseDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
}
|
||||
|
||||
[DebuggerHidden()]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public ThreadSafeObjectProvider() : base()
|
||||
{
|
||||
}
|
||||
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
private readonly Microsoft.VisualBasic.MyServices.Internal.ContextValue<T> m_Context = new Microsoft.VisualBasic.MyServices.Internal.ContextValue<T>();
|
||||
/* TODO ERROR: Skipped ElseDirectiveTrivia *//* TODO ERROR: Skipped DisabledTextTrivia *//* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
}
|
||||
}
|
||||
}
|
||||
/* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
253
Pilz.Configuration/My Project/MyNamespace.Static.2.Designer.cs
generated
Normal file
253
Pilz.Configuration/My Project/MyNamespace.Static.2.Designer.cs
generated
Normal file
@@ -0,0 +1,253 @@
|
||||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
// See Compiler::LoadXmlSolutionExtension
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
using Microsoft.VisualBasic.CompilerServices;
|
||||
|
||||
namespace Pilz.Configuration.My
|
||||
{
|
||||
[Embedded()]
|
||||
[DebuggerNonUserCode()]
|
||||
[System.Runtime.CompilerServices.CompilerGenerated()]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
internal sealed class InternalXmlHelper
|
||||
{
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
private InternalXmlHelper()
|
||||
{
|
||||
}
|
||||
|
||||
public static string get_Value(IEnumerable<XElement> source)
|
||||
{
|
||||
foreach (XElement item in source)
|
||||
return item.Value;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void set_Value(IEnumerable<XElement> source, string value)
|
||||
{
|
||||
foreach (XElement item in source)
|
||||
{
|
||||
item.Value = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static string get_AttributeValue(IEnumerable<XElement> source, XName name)
|
||||
{
|
||||
foreach (XElement item in source)
|
||||
return Conversions.ToString(item.Attribute(name));
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void set_AttributeValue(IEnumerable<XElement> source, XName name, string value)
|
||||
{
|
||||
foreach (XElement item in source)
|
||||
{
|
||||
item.SetAttributeValue(name, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static string get_AttributeValue(XElement source, XName name)
|
||||
{
|
||||
return Conversions.ToString(source.Attribute(name));
|
||||
}
|
||||
|
||||
public static void set_AttributeValue(XElement source, XName name, string value)
|
||||
{
|
||||
source.SetAttributeValue(name, value);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public static XAttribute CreateAttribute(XName name, object value)
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new XAttribute(name, value);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public static XAttribute CreateNamespaceAttribute(XName name, XNamespace ns)
|
||||
{
|
||||
var a = new XAttribute(name, ns.NamespaceName);
|
||||
a.AddAnnotation(ns);
|
||||
return a;
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public static object RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List<XAttribute> attributes, object obj)
|
||||
{
|
||||
if (obj is object)
|
||||
{
|
||||
XElement elem = obj as XElement;
|
||||
if (elem is object)
|
||||
{
|
||||
return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elem);
|
||||
}
|
||||
else
|
||||
{
|
||||
IEnumerable elems = obj as IEnumerable;
|
||||
if (elems is object)
|
||||
{
|
||||
return RemoveNamespaceAttributes(inScopePrefixes, inScopeNs, attributes, elems);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public static IEnumerable RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List<XAttribute> attributes, IEnumerable obj)
|
||||
{
|
||||
if (obj is object)
|
||||
{
|
||||
IEnumerable<XElement> elems = obj as IEnumerable<XElement>;
|
||||
if (elems is object)
|
||||
{
|
||||
return elems.Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessXElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
return obj.Cast<object>().Select(new RemoveNamespaceAttributesClosure(inScopePrefixes, inScopeNs, attributes).ProcessObject);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
[DebuggerNonUserCode()]
|
||||
[System.Runtime.CompilerServices.CompilerGenerated()]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
private sealed class RemoveNamespaceAttributesClosure
|
||||
{
|
||||
private readonly string[] m_inScopePrefixes;
|
||||
private readonly XNamespace[] m_inScopeNs;
|
||||
private readonly List<XAttribute> m_attributes;
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
internal RemoveNamespaceAttributesClosure(string[] inScopePrefixes, XNamespace[] inScopeNs, List<XAttribute> attributes)
|
||||
{
|
||||
m_inScopePrefixes = inScopePrefixes;
|
||||
m_inScopeNs = inScopeNs;
|
||||
m_attributes = attributes;
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
internal XElement ProcessXElement(XElement elem)
|
||||
{
|
||||
return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem);
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
internal object ProcessObject(object obj)
|
||||
{
|
||||
XElement elem = obj as XElement;
|
||||
if (elem is object)
|
||||
{
|
||||
return RemoveNamespaceAttributes(m_inScopePrefixes, m_inScopeNs, m_attributes, elem);
|
||||
}
|
||||
else
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public static XElement RemoveNamespaceAttributes(string[] inScopePrefixes, XNamespace[] inScopeNs, List<XAttribute> attributes, XElement e)
|
||||
{
|
||||
if (e is object)
|
||||
{
|
||||
var a = e.FirstAttribute;
|
||||
while (a is object)
|
||||
{
|
||||
var nextA = a.NextAttribute;
|
||||
if (a.IsNamespaceDeclaration)
|
||||
{
|
||||
var ns = a.Annotation<XNamespace>();
|
||||
string prefix = a.Name.LocalName;
|
||||
if (ns is object)
|
||||
{
|
||||
if (inScopePrefixes is object && inScopeNs is object)
|
||||
{
|
||||
int lastIndex = inScopePrefixes.Length - 1;
|
||||
for (int i = 0, loopTo = lastIndex; i <= loopTo; i++)
|
||||
{
|
||||
string currentInScopePrefix = inScopePrefixes[i];
|
||||
var currentInScopeNs = inScopeNs[i];
|
||||
if (prefix.Equals(currentInScopePrefix))
|
||||
{
|
||||
if (ns == currentInScopeNs)
|
||||
{
|
||||
// prefix and namespace match. Remove the unneeded ns attribute
|
||||
a.Remove();
|
||||
}
|
||||
|
||||
// prefix is in scope but refers to something else. Leave the ns attribute.
|
||||
a = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (a is object)
|
||||
{
|
||||
// Prefix is not in scope
|
||||
// Now check whether it's going to be in scope because it is in the attributes list
|
||||
|
||||
if (attributes is object)
|
||||
{
|
||||
int lastIndex = attributes.Count - 1;
|
||||
for (int i = 0, loopTo1 = lastIndex; i <= loopTo1; i++)
|
||||
{
|
||||
var currentA = attributes[i];
|
||||
string currentInScopePrefix = currentA.Name.LocalName;
|
||||
var currentInScopeNs = currentA.Annotation<XNamespace>();
|
||||
if (currentInScopeNs is object)
|
||||
{
|
||||
if (prefix.Equals(currentInScopePrefix))
|
||||
{
|
||||
if (ns == currentInScopeNs)
|
||||
{
|
||||
// prefix and namespace match. Remove the unneeded ns attribute
|
||||
a.Remove();
|
||||
}
|
||||
|
||||
// prefix is in scope but refers to something else. Leave the ns attribute.
|
||||
a = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (a is object)
|
||||
{
|
||||
// Prefix is definitely not in scope
|
||||
a.Remove();
|
||||
// namespace is not defined either. Add this attributes list
|
||||
attributes.Add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a = nextA;
|
||||
}
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Pilz.Configuration/My Project/MyNamespace.Static.3.Designer.cs
generated
Normal file
14
Pilz.Configuration/My Project/MyNamespace.Static.3.Designer.cs
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.VisualBasic
|
||||
{
|
||||
[Embedded()]
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Module | AttributeTargets.Assembly, Inherited = false)]
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
[System.Runtime.CompilerServices.CompilerGenerated()]
|
||||
internal sealed class Embedded : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
63
Pilz.Configuration/My Project/Resources.Designer.vb
generated
63
Pilz.Configuration/My Project/Resources.Designer.vb
generated
@@ -1,63 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace My.Resources
|
||||
|
||||
'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
||||
'-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||
'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||
'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
||||
'''<summary>
|
||||
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
'''</summary>
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
Friend Module Resources
|
||||
|
||||
Private resourceMan As Global.System.Resources.ResourceManager
|
||||
|
||||
Private resourceCulture As Global.System.Globalization.CultureInfo
|
||||
|
||||
'''<summary>
|
||||
''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
||||
Get
|
||||
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
||||
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Pilz.Configuration.Resources", GetType(Resources).Assembly)
|
||||
resourceMan = temp
|
||||
End If
|
||||
Return resourceMan
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend Property Culture() As Global.System.Globalization.CultureInfo
|
||||
Get
|
||||
Return resourceCulture
|
||||
End Get
|
||||
Set
|
||||
resourceCulture = value
|
||||
End Set
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
73
Pilz.Configuration/My Project/Settings.Designer.vb
generated
73
Pilz.Configuration/My Project/Settings.Designer.vb
generated
@@ -1,73 +0,0 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
|
||||
|
||||
#Region "Automatische My.Settings-Speicherfunktion"
|
||||
#If _MyType = "WindowsForms" Then
|
||||
Private Shared addedHandler As Boolean
|
||||
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
#End If
|
||||
#End Region
|
||||
|
||||
Public Shared ReadOnly Property [Default]() As MySettings
|
||||
Get
|
||||
|
||||
#If _MyType = "WindowsForms" Then
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
#End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
Friend Module MySettingsProperty
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
Friend ReadOnly Property Settings() As Global.Pilz.Configuration.My.MySettings
|
||||
Get
|
||||
Return Global.Pilz.Configuration.My.MySettings.Default
|
||||
End Get
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
@@ -4,7 +4,7 @@
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A56C6153-C61F-4B10-BE06-35EB0448CFDC}</ProjectGuid>
|
||||
<ProjectGuid>{1748E038-0A47-04E1-3C5E-FF9566DFFB7C}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Pilz.Configuration</RootNamespace>
|
||||
<AssemblyName>Pilz.Configuration</AssemblyName>
|
||||
@@ -13,6 +13,8 @@
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
<DefaultItemExcludes>$(DefaultItemExcludes);$(ProjectDir)**\*.vb</DefaultItemExcludes>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -45,6 +47,7 @@
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
@@ -66,52 +69,55 @@
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConfigurationManager.vb" />
|
||||
<Compile Include="ConfigurationManagerList.vb" />
|
||||
<Compile Include="ConfigurationSerializer.vb" />
|
||||
<Compile Include="AutoSaveConfigurationManager.vb" />
|
||||
<Compile Include="SimpleConfiguration.vb" />
|
||||
<Compile Include="ISettingsManager.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<Compile Include="My Project\MyNamespace.Static.1.Designer.cs" />
|
||||
<Compile Include="My Project\MyNamespace.Static.2.Designer.cs" />
|
||||
<Compile Include="My Project\MyNamespace.Static.3.Designer.cs" />
|
||||
<Compile Include="ConfigurationManager.cs" />
|
||||
<Compile Include="ConfigurationManagerList.cs" />
|
||||
<Compile Include="ConfigurationSerializer.cs" />
|
||||
<Compile Include="AutoSaveConfigurationManager.cs" />
|
||||
<Compile Include="SimpleConfiguration.cs" />
|
||||
<Compile Include="ISettingsManager.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="My Project\Application.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<Compile Include="Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="SettingsBase.vb" />
|
||||
<Compile Include="SettingsManager.vb" />
|
||||
<Compile Include="SettingsBase.cs" />
|
||||
<Compile Include="SettingsManager.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<EmbeddedResource Include="Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<CustomToolNamespace>Pilz.Configuration.My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
<LastGenOutput>Application.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>Pilz.Configuration.My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Pilz\Pilz.vbproj">
|
||||
<Project>{277D2B83-7613-4C49-9CAB-E080195A6E0C}</Project>
|
||||
<ProjectReference Include="..\Pilz\Pilz.csproj">
|
||||
<Project>{9559AAE8-BA4B-03B8-1EF3-2AFE7BCD5AAC}</Project>
|
||||
<Name>Pilz</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
@@ -120,5 +126,5 @@
|
||||
<Version>12.0.3</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
35
Pilz.Configuration/Properties/AssemblyInfo.cs
Normal file
35
Pilz.Configuration/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using global::System;
|
||||
using global::System.Reflection;
|
||||
using global::System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
|
||||
// Werte der Assemblyattribute überprüfen
|
||||
|
||||
[assembly: AssemblyTitle("Pilz.Configuration")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyCompany("DRSN")]
|
||||
[assembly: AssemblyProduct("Pilz.Configuration")]
|
||||
[assembly: AssemblyCopyright("Copyright © DRSN 2019")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird.
|
||||
[assembly: Guid("3980caa6-d118-4166-8f0d-e91c9dc07e3c")]
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
26
Pilz.Configuration/Properties/Settings.Designer.cs
generated
Normal file
26
Pilz.Configuration/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Dieser Code wurde von einem Tool generiert.
|
||||
// Laufzeitversion:4.0.30319.42000
|
||||
//
|
||||
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
// der Code erneut generiert wird.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Pilz.Configuration.My {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
69
Pilz.Configuration/Resources.Designer.cs
generated
Normal file
69
Pilz.Configuration/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,69 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Dieser Code wurde von einem Tool generiert.
|
||||
// Laufzeitversion:4.0.30319.42000
|
||||
//
|
||||
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
// der Code erneut generiert wird.
|
||||
// </auto-generated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
using System.Diagnostics;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
namespace Pilz.Configuration.My.Resources
|
||||
{
|
||||
|
||||
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
||||
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
||||
/// <summary>
|
||||
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
/// </summary>
|
||||
[System.CodeDom.Compiler.GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[DebuggerNonUserCode()]
|
||||
[System.Runtime.CompilerServices.CompilerGenerated()]
|
||||
[HideModuleName()]
|
||||
internal static class Resources
|
||||
{
|
||||
private static System.Resources.ResourceManager resourceMan;
|
||||
private static System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
/// <summary>
|
||||
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
/// </summary>
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
var temp = new System.Resources.ResourceManager("Pilz.Configuration.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
/// </summary>
|
||||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
Pilz.Configuration/Resources.resx
Normal file
117
Pilz.Configuration/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
26
Pilz.Configuration/SettingsBase.cs
Normal file
26
Pilz.Configuration/SettingsBase.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using global::Newtonsoft.Json;
|
||||
|
||||
namespace Pilz.Configuration
|
||||
{
|
||||
public abstract class SettingsBase
|
||||
{
|
||||
public SettingsBase()
|
||||
{
|
||||
ResetValues();
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
internal ISettingsManager _settingsManager;
|
||||
|
||||
[JsonIgnore]
|
||||
public ISettingsManager SettingsManager
|
||||
{
|
||||
get
|
||||
{
|
||||
return _settingsManager;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void ResetValues();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
Imports Newtonsoft.Json
|
||||
|
||||
Public MustInherit Class SettingsBase
|
||||
|
||||
Public Sub New()
|
||||
ResetValues()
|
||||
End Sub
|
||||
|
||||
<JsonIgnore>
|
||||
Friend _settingsManager As ISettingsManager
|
||||
<JsonIgnore>
|
||||
Public ReadOnly Property SettingsManager As ISettingsManager
|
||||
Get
|
||||
Return _settingsManager
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public MustOverride Sub ResetValues()
|
||||
|
||||
End Class
|
||||
161
Pilz.Configuration/SettingsManager.cs
Normal file
161
Pilz.Configuration/SettingsManager.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using global::System.IO;
|
||||
using global::Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Pilz.Configuration
|
||||
{
|
||||
public sealed class SettingsManager<T> : ISettingsManager where T : SettingsBase
|
||||
{
|
||||
public event EventHandler AutoSavingSettings;
|
||||
public event EventHandler SavingSettings;
|
||||
public event EventHandler SavedSettings;
|
||||
|
||||
private T defaultInstance = null;
|
||||
private bool enableAutoSave = false;
|
||||
private bool addedHandler = false;
|
||||
|
||||
public string ConfigFilePath { get; set; }
|
||||
|
||||
public bool AutoSaveOnExit
|
||||
{
|
||||
get
|
||||
{
|
||||
return enableAutoSave;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (enableAutoSave != value)
|
||||
{
|
||||
enableAutoSave = value;
|
||||
switch (enableAutoSave)
|
||||
{
|
||||
case true:
|
||||
{
|
||||
if (!addedHandler)
|
||||
{
|
||||
AddAutoSaveHandler();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case false:
|
||||
{
|
||||
if (addedHandler)
|
||||
{
|
||||
RemoveAutoSaveHandler();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddAutoSaveHandler()
|
||||
{
|
||||
System.Windows.Forms.Application.ApplicationExit += AutoSaveSettingsOnExit;
|
||||
addedHandler = true;
|
||||
}
|
||||
|
||||
private void RemoveAutoSaveHandler()
|
||||
{
|
||||
System.Windows.Forms.Application.ApplicationExit -= AutoSaveSettingsOnExit;
|
||||
addedHandler = false;
|
||||
}
|
||||
|
||||
public T Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (defaultInstance is null)
|
||||
{
|
||||
Load();
|
||||
}
|
||||
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsManager()
|
||||
{
|
||||
ConfigFilePath = "";
|
||||
AutoSaveOnExit = false;
|
||||
}
|
||||
|
||||
public SettingsManager(string fileName, bool autoSaveOnExit)
|
||||
{
|
||||
ConfigFilePath = fileName;
|
||||
AutoSaveOnExit = autoSaveOnExit;
|
||||
}
|
||||
|
||||
private void AutoSaveSettingsOnExit(object sender, EventArgs e)
|
||||
{
|
||||
AutoSavingSettings?.Invoke(this, new EventArgs());
|
||||
Save();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ConfigFilePath) && defaultInstance is object)
|
||||
{
|
||||
SavePrivate();
|
||||
}
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ConfigFilePath) && File.Exists(ConfigFilePath))
|
||||
{
|
||||
LoadPrivate();
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateNewInstance();
|
||||
}
|
||||
|
||||
if (defaultInstance is object)
|
||||
{
|
||||
defaultInstance._settingsManager = this;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Instance.ResetValues();
|
||||
}
|
||||
|
||||
private void CreateNewInstance()
|
||||
{
|
||||
var ctor = typeof(T).GetConstructor(Array.Empty<Type>());
|
||||
if (ctor is object)
|
||||
{
|
||||
defaultInstance = (T)ctor.Invoke(Array.Empty<object>());
|
||||
defaultInstance.ResetValues();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("The base type has no constructor with no parameters.");
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadPrivate()
|
||||
{
|
||||
defaultInstance = JObject.Parse(File.ReadAllText(ConfigFilePath)).ToObject<T>();
|
||||
}
|
||||
|
||||
private void SavePrivate()
|
||||
{
|
||||
SavingSettings?.Invoke(this, new EventArgs());
|
||||
var obj = JObject.FromObject(defaultInstance);
|
||||
if (obj is object)
|
||||
{
|
||||
File.WriteAllText(ConfigFilePath, obj.ToString());
|
||||
}
|
||||
|
||||
SavedSettings?.Invoke(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
Imports System.IO
|
||||
Imports System.Reflection
|
||||
Imports Newtonsoft.Json.Linq
|
||||
|
||||
Public NotInheritable Class SettingsManager(Of T As SettingsBase)
|
||||
Implements ISettingsManager
|
||||
|
||||
Public Event AutoSavingSettings As EventHandler
|
||||
Public Event SavingSettings As EventHandler
|
||||
Public Event SavedSettings As EventHandler
|
||||
|
||||
Private defaultInstance As T = Nothing
|
||||
Private enableAutoSave As Boolean = False
|
||||
Private addedHandler As Boolean = False
|
||||
|
||||
Public Property ConfigFilePath As String Implements ISettingsManager.ConfigFilePath
|
||||
|
||||
Public Property AutoSaveOnExit As Boolean
|
||||
Get
|
||||
Return enableAutoSave
|
||||
End Get
|
||||
Set
|
||||
If enableAutoSave <> Value Then
|
||||
enableAutoSave = Value
|
||||
Select Case enableAutoSave
|
||||
Case True
|
||||
If Not addedHandler Then
|
||||
AddAutoSaveHandler()
|
||||
End If
|
||||
Case False
|
||||
If addedHandler Then
|
||||
RemoveAutoSaveHandler()
|
||||
End If
|
||||
End Select
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Sub AddAutoSaveHandler()
|
||||
AddHandler Windows.Forms.Application.ApplicationExit, AddressOf AutoSaveSettingsOnExit
|
||||
addedHandler = True
|
||||
End Sub
|
||||
Private Sub RemoveAutoSaveHandler()
|
||||
RemoveHandler Windows.Forms.Application.ApplicationExit, AddressOf AutoSaveSettingsOnExit
|
||||
addedHandler = False
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property Instance As T
|
||||
Get
|
||||
If defaultInstance Is Nothing Then
|
||||
Load()
|
||||
End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub New()
|
||||
ConfigFilePath = ""
|
||||
AutoSaveOnExit = False
|
||||
End Sub
|
||||
Public Sub New(fileName As String, autoSaveOnExit As Boolean)
|
||||
ConfigFilePath = fileName
|
||||
Me.AutoSaveOnExit = autoSaveOnExit
|
||||
End Sub
|
||||
|
||||
Private Sub AutoSaveSettingsOnExit(sender As Object, e As EventArgs)
|
||||
RaiseEvent AutoSavingSettings(Me, New EventArgs)
|
||||
Save()
|
||||
End Sub
|
||||
|
||||
Public Sub Save() Implements ISettingsManager.Save
|
||||
If Not String.IsNullOrEmpty(ConfigFilePath) AndAlso defaultInstance IsNot Nothing Then
|
||||
SavePrivate()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub Load() Implements ISettingsManager.Load
|
||||
If Not String.IsNullOrEmpty(ConfigFilePath) AndAlso File.Exists(ConfigFilePath) Then
|
||||
LoadPrivate()
|
||||
Else
|
||||
CreateNewInstance()
|
||||
End If
|
||||
|
||||
If defaultInstance IsNot Nothing Then
|
||||
defaultInstance._settingsManager = Me
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub Reset() Implements ISettingsManager.Reset
|
||||
Instance.ResetValues()
|
||||
End Sub
|
||||
|
||||
Private Sub CreateNewInstance()
|
||||
Dim ctor As ConstructorInfo = GetType(T).GetConstructor({})
|
||||
If ctor IsNot Nothing Then
|
||||
defaultInstance = ctor.Invoke({})
|
||||
|
||||
defaultInstance.ResetValues()
|
||||
Else
|
||||
Throw New Exception("The base type has no constructor with no parameters.")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub LoadPrivate()
|
||||
defaultInstance = JObject.Parse(File.ReadAllText(ConfigFilePath)).ToObject(Of T)
|
||||
End Sub
|
||||
|
||||
Private Sub SavePrivate()
|
||||
RaiseEvent SavingSettings(Me, New EventArgs)
|
||||
|
||||
Dim obj As JObject = JObject.FromObject(defaultInstance)
|
||||
If obj IsNot Nothing Then
|
||||
File.WriteAllText(ConfigFilePath, obj.ToString)
|
||||
End If
|
||||
|
||||
RaiseEvent SavedSettings(Me, New EventArgs)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
112
Pilz.Configuration/SimpleConfiguration.cs
Normal file
112
Pilz.Configuration/SimpleConfiguration.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using global::System.IO;
|
||||
using global::Newtonsoft.Json;
|
||||
using global::Pilz.GeneralEventArgs;
|
||||
|
||||
namespace Pilz.Configuration
|
||||
{
|
||||
public class SimpleConfiguration
|
||||
{
|
||||
[JsonIgnore]
|
||||
public readonly ConfigurationManagerList Managers = new ConfigurationManagerList();
|
||||
|
||||
public SimpleConfiguration()
|
||||
{
|
||||
Managers.GettingParentManager += Managers_GettingParentManager;
|
||||
}
|
||||
|
||||
private void Managers_GettingParentManager(object sender, GetValueEventArgs<SimpleConfiguration> e)
|
||||
{
|
||||
if (ReferenceEquals(sender, Managers))
|
||||
{
|
||||
e.Value = this;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes this instance to a string and return it.
|
||||
/// </summary>
|
||||
/// <returns>The content of the configuration instance as string.</returns>
|
||||
public string WriteToString()
|
||||
{
|
||||
return ConfigurationSerializer.WriteToString(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write this instance to a given stream.
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream where the content should be written to.</param>
|
||||
public void WriteToStream(Stream stream)
|
||||
{
|
||||
ConfigurationSerializer.WriteToStream(this, stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes this instance to the given filePath as text file.
|
||||
/// </summary>
|
||||
/// <param name="filePath">The file path where the content should be written to. The file will be created or overwritten.</param>
|
||||
public void WriteToFile(string filePath)
|
||||
{
|
||||
ConfigurationSerializer.WriteToFile(this, filePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a configuratin from the given string and returns an instance of it.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
/// <param name="content">The content of the configuration as string.</param>
|
||||
/// <returns></returns>
|
||||
public static T ReadFromString<T>(string content) where T : SimpleConfiguration
|
||||
{
|
||||
return ConfigurationSerializer.ReadFromString<T>(content);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a configuration from the given string and put them to this instance.
|
||||
/// </summary>
|
||||
/// <param name="content">The content of the configuration as string.</param>
|
||||
public void ReadFromString(string content)
|
||||
{
|
||||
ConfigurationSerializer.ReadFromString(this, content);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a configuratin from the given string and returns an instance of it.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
/// <param name="stream">The stream with the content of the configuration.</param>
|
||||
/// <returns></returns>
|
||||
public static T ReadFromStream<T>(Stream stream) where T : SimpleConfiguration
|
||||
{
|
||||
return ConfigurationSerializer.ReadFromStream<T>(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a configuration from the given string and put them to this instance.
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream with the content of the configuration.</param>
|
||||
public void ReadFromStream(Stream stream)
|
||||
{
|
||||
ConfigurationSerializer.ReadFromStream(this, stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a configuratin from the given string and returns an instance of it.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
/// <param name="filePath">The path to the file with the content of the configuration.</param>
|
||||
/// <returns></returns>
|
||||
public static T ReadFromFile<T>(string filePath) where T : SimpleConfiguration
|
||||
{
|
||||
return ConfigurationSerializer.ReadFromFile<T>(filePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a configuration from the given string and put them to this instance.
|
||||
/// </summary>
|
||||
/// <param name="filePath">The path to the file with the content of the configuration.</param>
|
||||
public void ReadFromFile(string filePath)
|
||||
{
|
||||
ConfigurationSerializer.ReadFromFile(this, filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
Imports System.IO
|
||||
Imports Newtonsoft.Json
|
||||
Imports Pilz.Configuration
|
||||
Imports Pilz.GeneralEventArgs
|
||||
|
||||
Public Class SimpleConfiguration
|
||||
|
||||
<JsonIgnore>
|
||||
Public ReadOnly Managers As New ConfigurationManagerList
|
||||
|
||||
Public Sub New()
|
||||
AddHandler Managers.GettingParentManager, AddressOf Managers_GettingParentManager
|
||||
End Sub
|
||||
|
||||
Private Sub Managers_GettingParentManager(sender As Object, e As GetValueEventArgs(Of SimpleConfiguration))
|
||||
If sender Is Managers Then
|
||||
e.Value = Me
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Writes this instance to a string and return it.
|
||||
''' </summary>
|
||||
''' <returns>The content of the configuration instance as string.</returns>
|
||||
Public Function WriteToString() As String
|
||||
Return ConfigurationSerializer.WriteToString(Me)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Write this instance to a given stream.
|
||||
''' </summary>
|
||||
''' <param name="stream">The stream where the content should be written to.</param>
|
||||
Public Sub WriteToStream(stream As Stream)
|
||||
ConfigurationSerializer.WriteToStream(Me, stream)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Writes this instance to the given filePath as text file.
|
||||
''' </summary>
|
||||
''' <param name="filePath">The file path where the content should be written to. The file will be created or overwritten.</param>
|
||||
Public Sub WriteToFile(filePath As String)
|
||||
ConfigurationSerializer.WriteToFile(Me, filePath)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Reads a configuratin from the given string and returns an instance of it.
|
||||
''' </summary>
|
||||
''' <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
''' <param name="content">The content of the configuration as string.</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function ReadFromString(Of T As SimpleConfiguration)(content As String) As T
|
||||
Return ConfigurationSerializer.ReadFromString(Of T)(content)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Read a configuration from the given string and put them to this instance.
|
||||
''' </summary>
|
||||
''' <param name="content">The content of the configuration as string.</param>
|
||||
Public Sub ReadFromString(content As String)
|
||||
ConfigurationSerializer.ReadFromString(Me, content)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Reads a configuratin from the given string and returns an instance of it.
|
||||
''' </summary>
|
||||
''' <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
''' <param name="stream">The stream with the content of the configuration.</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function ReadFromStream(Of T As SimpleConfiguration)(stream As Stream) As T
|
||||
Return ConfigurationSerializer.ReadFromStream(Of T)(stream)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Read a configuration from the given string and put them to this instance.
|
||||
''' </summary>
|
||||
''' <param name="stream">The stream with the content of the configuration.</param>
|
||||
Public Sub ReadFromStream(stream As Stream)
|
||||
ConfigurationSerializer.ReadFromStream(Me, stream)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Reads a configuratin from the given string and returns an instance of it.
|
||||
''' </summary>
|
||||
''' <typeparam name="T">The type of the configuration class to instance.</typeparam>
|
||||
''' <param name="filePath">The path to the file with the content of the configuration.</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function ReadFromFile(Of T As SimpleConfiguration)(filePath As String) As T
|
||||
Return ConfigurationSerializer.ReadFromFile(Of T)(filePath)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Read a configuration from the given string and put them to this instance.
|
||||
''' </summary>
|
||||
''' <param name="filePath">The path to the file with the content of the configuration.</param>
|
||||
Public Sub ReadFromFile(filePath As String)
|
||||
ConfigurationSerializer.ReadFromFile(Me, filePath)
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user