revert to VB and update to new project file format

This commit is contained in:
schedpas
2020-09-25 09:04:15 +02:00
parent 04869b2814
commit 9feaf658be
313 changed files with 9895 additions and 17566 deletions

View File

@@ -1,11 +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>
// ------------------------------------------------------------------------------

View File

@@ -0,0 +1,13 @@
'------------------------------------------------------------------------------
' <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

View File

@@ -1,192 +0,0 @@
// 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.Collections.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 */

View File

@@ -1,253 +0,0 @@
// 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.Collections.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;
}
}
}

View File

@@ -1,14 +0,0 @@
// 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
{
}
}

View File

@@ -0,0 +1,63 @@
'------------------------------------------------------------------------------
' <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.Collections.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

View File

@@ -0,0 +1,73 @@
'------------------------------------------------------------------------------
' <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.Collections.My.MySettings
Get
Return Global.Pilz.Collections.My.MySettings.Default
End Get
End Property
End Module
End Namespace

View File

@@ -3,12 +3,6 @@
<StartupObject />
<MyType>Windows</MyType>
<TargetFramework>net48</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);$(ProjectDir)**\*.vb</DefaultItemExcludes>
<LangVersion>latest</LangVersion>
<AssemblyTitle>SimpleHistory</AssemblyTitle>
<Company>Dr. Schneider Kunststoffwerke GmbH</Company>
<Product>SimpleHistory</Product>
<Copyright>Copyright © Pascal Schedel 2018</Copyright>
<DocumentationFile>Pilz.Collections.xml</DocumentationFile>
<DefineTrace>true</DefineTrace>
</PropertyGroup>
@@ -47,11 +41,10 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Data.DataSetExtensions" Version="4.*" />
<PackageReference Include="System.Net.Http" Version="4.*" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="System.Deployment" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
@@ -69,38 +62,41 @@
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Update="My Project\Application.Designer.cs">
<Compile Update="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon>
</Compile>
<Compile Update="Resources.Designer.cs">
<Compile Update="My Project\Resources.Designer.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Properties\Settings.Designer.cs">
<Compile Update="My Project\Settings.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<CustomToolNamespace>Pilz.Collections.My.Resources</CustomToolNamespace>
<EmbeddedResource Update="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.cs</LastGenOutput>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
<None Include="Properties\Settings.settings">
<None Include="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<CustomToolNamespace>Pilz.Collections.My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Compile Remove="SimpleHistory\Enums.vb" />
</ItemGroup>
</Project>

View File

@@ -1,8 +0,0 @@
using global::System;
using global::System.Reflection;
using global::System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird.
[assembly: Guid("7dd4cf70-efc1-4386-a169-39ec65e4aef3")]

View File

@@ -1,26 +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>
//------------------------------------------------------------------------------
namespace Pilz.Collections.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;
}
}
}
}

View File

@@ -1,69 +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>
// ------------------------------------------------------------------------------
using System.Diagnostics;
using Microsoft.VisualBasic;
namespace Pilz.Collections.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.Collections.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;
}
}
}
}

View File

@@ -1,117 +0,0 @@
<?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>

View File

@@ -0,0 +1,12 @@
Namespace SimpleHistory
''' <summary>
''' Specify which member types you would include.
''' </summary>
Public Enum ObjectValueType
None = 0
Field = 1
[Property] = 2
End Enum
End Namespace

View File

@@ -1,615 +0,0 @@
using System.Collections.Generic;
using System.Data;
using System.Linq;
using global::System.Reflection;
using Microsoft.VisualBasic.CompilerServices;
namespace Pilz.Collections.SimpleHistory
{
/// <summary>
/// Represent some Object States and Actions.
/// </summary>
public class HistoryPoint
{
/// <summary>
/// Represents the Name of this History Point
/// </summary>
/// <returns></returns>
public string Name { get; set; } = "";
/// <summary>
/// A List of Object States and Actions.
/// </summary>
/// <returns></returns>
public List<ObjectBase> Entries { get; private set; } = new List<ObjectBase>();
/// <summary>
/// Some data can be refered on this HistoryPoint. Don't know, in some situations this can be helpful.
/// </summary>
public readonly object Tag = null;
public bool HasEntries<T>() where T : ObjectBase
{
return Entries.Where(n => n is T).Count() > 0;
}
internal void Undo()
{
foreach (ObjectBase s in Entries.OrderBy(n => n.UndoPriority))
{
if (s is ObjectState)
{
((ObjectState)s).Patch();
}
else if (s is ObjectAction)
{
((ObjectAction)s).Undo();
}
}
}
internal void Redo()
{
foreach (ObjectBase s in Entries.OrderBy(n => n.RedoPriority))
{
if (s is ObjectState)
{
((ObjectState)s).Patch();
}
else if (s is ObjectAction)
{
((ObjectAction)s).Redo();
}
}
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The objects that should be included.</param>
/// <param name="whiteList">Specify which members to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] obj, MemberWhiteList whiteList)
{
return FromObject(new[] { obj }, ObjectValueType.None, whiteList, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The objects that should be included.</param>
/// <param name="blackList">Specify which members to exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] obj, MemberBlackList blackList)
{
return FromObject(new[] { obj }, ObjectValueType.None, blackList, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The objects that should be included.</param>
/// <param name="memberName">The member names to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] obj, params string[] memberName)
{
return FromObject(obj, true, memberName);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The objects that should be included.</param>
/// <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
/// <param name="memberName">The member names to include/exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] obj, bool isWhiteList, params string[] memberName)
{
if (isWhiteList)
{
return FromObject(new[] { obj }, ObjectValueType.None, new MemberWhiteList(memberName), BindingFlags.Default);
}
else
{
return FromObject(new[] { obj }, ObjectValueType.None, new MemberBlackList(memberName), BindingFlags.Default);
}
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The objects that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="memberName">The member names to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] obj, ObjectValueType membersToStore, params string[] memberName)
{
return FromObject(obj, membersToStore, true, memberName);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The objects that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
/// <param name="memberName">The member names to include/exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] obj, ObjectValueType membersToStore, bool isWhiteList, params string[] memberName)
{
if (isWhiteList)
{
return FromObject(new[] { obj }, membersToStore, new MemberWhiteList(memberName), BindingFlags.Default);
}
else
{
return FromObject(new[] { obj }, membersToStore, new MemberBlackList(memberName), BindingFlags.Default);
}
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The objects that should be included.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <param name="memberName">The member names to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] obj, BindingFlags flags, params string[] memberName)
{
return FromObject(obj, flags, true, memberName);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The objects that should be included.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
/// <param name="memberName">The member names to include/exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] obj, BindingFlags flags, bool isWhiteList, params string[] memberName)
{
if (isWhiteList)
{
return FromObject(new[] { obj }, ObjectValueType.None, new MemberWhiteList(memberName), flags);
}
else
{
return FromObject(new[] { obj }, ObjectValueType.None, new MemberBlackList(memberName), flags);
}
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The objects that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <param name="memberName">The member names to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] obj, ObjectValueType membersToStore, BindingFlags flags, params string[] memberName)
{
return FromObject(obj, flags, true, memberName);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The objects that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
/// <param name="memberName">The member names to include/exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] obj, ObjectValueType membersToStore, BindingFlags flags, bool isWhiteList, params string[] memberName)
{
if (isWhiteList)
{
return FromObject(new[] { obj }, membersToStore, new MemberWhiteList(memberName), flags);
}
else
{
return FromObject(new[] { obj }, membersToStore, new MemberBlackList(memberName), flags);
}
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="whiteList">Specify which members to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, MemberWhiteList whiteList)
{
return FromObject(new[] { obj }, ObjectValueType.None, whiteList, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="blackList">Specify which members to exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, MemberBlackList blackList)
{
return FromObject(new[] { obj }, ObjectValueType.None, blackList, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="memberName">The member names to include/exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, params string[] memberName)
{
return FromObject(obj, true, memberName);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
/// <param name="memberName">The member names to include/exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, bool isWhiteList, params string[] memberName)
{
if (isWhiteList)
{
return FromObject(new[] { obj }, ObjectValueType.None, new MemberWhiteList(memberName), BindingFlags.Default);
}
else
{
return FromObject(new[] { obj }, ObjectValueType.None, new MemberBlackList(memberName), BindingFlags.Default);
}
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="memberName">The member names to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, ObjectValueType membersToStore, params string[] memberName)
{
return FromObject(obj, membersToStore, true, memberName);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
/// <param name="memberName">The member names to include/exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, ObjectValueType membersToStore, bool isWhiteList, params string[] memberName)
{
if (isWhiteList)
{
return FromObject(new[] { obj }, membersToStore, new MemberWhiteList(memberName), BindingFlags.Default);
}
else
{
return FromObject(new[] { obj }, membersToStore, new MemberBlackList(memberName), BindingFlags.Default);
}
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <param name="memberName">The member names to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, BindingFlags flags, params string[] memberName)
{
return FromObject(obj, flags, true, memberName);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
/// <param name="memberName">The member names to include/exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, BindingFlags flags, bool isWhiteList, params string[] memberName)
{
if (isWhiteList)
{
return FromObject(new[] { obj }, ObjectValueType.None, new MemberWhiteList(memberName), flags);
}
else
{
return FromObject(new[] { obj }, ObjectValueType.None, new MemberBlackList(memberName), flags);
}
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <param name="memberName">The member names to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, ObjectValueType membersToStore, BindingFlags flags, params string[] memberName)
{
return FromObject(obj, flags, true, memberName);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
/// <param name="memberName">The member names to include/exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, ObjectValueType membersToStore, BindingFlags flags, bool isWhiteList, params string[] memberName)
{
if (isWhiteList)
{
return FromObject(new[] { obj }, membersToStore, new MemberWhiteList(memberName), flags);
}
else
{
return FromObject(new[] { obj }, membersToStore, new MemberBlackList(memberName), flags);
}
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj)
{
return FromObject(new[] { obj }, ObjectValueType.None, (object)null, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, ObjectValueType membersToStore)
{
return FromObject(new[] { obj }, membersToStore, (object)null, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="whiteList">Specify which members to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, ObjectValueType membersToStore, MemberWhiteList whiteList)
{
return FromObject(new[] { obj }, membersToStore, whiteList, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="blackList">Specify which members to exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, ObjectValueType membersToStore, MemberBlackList blackList)
{
return FromObject(new[] { obj }, membersToStore, blackList, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, BindingFlags flags)
{
return FromObject(new[] { obj }, ObjectValueType.None, (object)null, flags);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, ObjectValueType membersToStore, BindingFlags flags)
{
return FromObject(new[] { obj }, membersToStore, (object)null, flags);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="whiteList">Specify which members to include.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, ObjectValueType membersToStore, MemberWhiteList whiteList, BindingFlags flags)
{
return FromObject(new[] { obj }, membersToStore, whiteList, flags);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="obj">The object that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="blackList">Specify which members to exclude.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object obj, ObjectValueType membersToStore, MemberBlackList blackList, BindingFlags flags)
{
return FromObject(new[] { obj }, membersToStore, blackList, flags);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="objs">The objects that should be included.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] objs)
{
return FromObject(objs, ObjectValueType.None, (object)null, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="objs">The objects that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] objs, ObjectValueType membersToStore)
{
return FromObject(objs, membersToStore, (object)null, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="objs">The objects that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="whiteList">Specify which members to include.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] objs, ObjectValueType membersToStore, MemberWhiteList whiteList)
{
return FromObject(objs, membersToStore, whiteList, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="objs">The objects that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="blackList">Specify which members to exclude.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] objs, ObjectValueType membersToStore, MemberBlackList blackList)
{
return FromObject(objs, membersToStore, blackList, BindingFlags.Default);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="objs">The objects that should be included.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] objs, BindingFlags flags)
{
return FromObject(objs, ObjectValueType.None, (object)null, flags);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="objs">The objects that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] objs, ObjectValueType membersToStore, BindingFlags flags)
{
return FromObject(objs, membersToStore, (object)null, flags);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="objs">The objects that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="whiteList">Specify which members to include.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] objs, ObjectValueType membersToStore, MemberWhiteList whiteList, BindingFlags flags)
{
return FromObject(objs, membersToStore, whiteList, flags);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="objs">The objects that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="blackList">Specify which members to exclude.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <returns>A History Point with Object States.</returns>
public static HistoryPoint FromObject(object[] objs, ObjectValueType membersToStore, MemberBlackList blackList, BindingFlags flags)
{
return FromObject(objs, membersToStore, blackList, flags);
}
/// <summary>
/// Creates an History Point with Object States automaticly from input.
/// </summary>
/// <param name="objs">The objects that should be included.</param>
/// <param name="membersToStore">Specify what member types to include.</param>
/// <param name="whiteOrBlackList">Specify which members to include.</param>
/// <param name="flags">The Binding Flags that the members should have.</param>
/// <returns>A History Point with Object States.</returns>
private static HistoryPoint FromObject(object[] objs, ObjectValueType membersToStore, object whiteOrBlackList, BindingFlags flags)
{
var hp = new HistoryPoint();
if (whiteOrBlackList is null)
whiteOrBlackList = new MemberBlackList();
bool isWhiteList = whiteOrBlackList is MemberWhiteList;
if (flags == BindingFlags.Default)
{
flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
}
if (membersToStore == ObjectValueType.None)
{
membersToStore = ObjectValueType.Field | ObjectValueType.Property;
}
foreach (object obj in objs)
{
if ((membersToStore & ObjectValueType.Field) == ObjectValueType.Field)
{
foreach (FieldInfo fi in obj.GetType().GetFields(flags))
{
bool contains = Conversions.ToBoolean(((List<string>)whiteOrBlackList).Contains(fi.Name));
if (isWhiteList ? contains : !contains)
{
var os = new ObjectState();
os.Object = obj;
os.MemberName = fi.Name;
os.MemberType = ObjectValueType.Field;
os.MemberFlags = flags;
os.ValueToPatch = fi.GetValue(obj);
hp.Entries.Add(os);
}
}
}
if ((membersToStore & ObjectValueType.Property) == ObjectValueType.Property)
{
foreach (PropertyInfo pi in obj.GetType().GetProperties(flags))
{
bool contains = Conversions.ToBoolean(((List<string>)whiteOrBlackList).Contains(pi.Name));
if (isWhiteList ? contains : !contains)
{
var os = new ObjectState();
os.Object = obj;
os.MemberName = pi.Name;
os.MemberType = ObjectValueType.Property;
os.MemberFlags = flags;
os.ValueToPatch = pi.GetValue(obj);
hp.Entries.Add(os);
}
}
}
}
return hp;
}
/// <summary>
/// Combines some History Points to one.
/// </summary>
/// <param name="hps">An array of History Points to combine.</param>
/// <returns>One History Point that contains all Data of inputted History Points.</returns>
public static HistoryPoint Concat(params HistoryPoint[] hps)
{
return Concat(hps.FirstOrDefault()?.Name, hps);
}
/// <summary>
/// Combines some History Points to one.
/// </summary>
/// <param name="hps">An array of History Points to combine.</param>
/// <returns>One History Point that contains all Data of inputted History Points.</returns>
public static HistoryPoint Concat(string newName, params HistoryPoint[] hps)
{
var hp = new HistoryPoint();
foreach (HistoryPoint _hp in hps)
hp.Entries.AddRange(_hp.Entries);
return hp;
}
}
}

View File

@@ -0,0 +1,543 @@
Imports System.Reflection
Namespace SimpleHistory
''' <summary>
''' Represent some Object States and Actions.
''' </summary>
Public Class HistoryPoint
''' <summary>
''' Represents the Name of this History Point
''' </summary>
''' <returns></returns>
Public Property Name As String = ""
''' <summary>
''' A List of Object States and Actions.
''' </summary>
''' <returns></returns>
Public ReadOnly Property Entries As New List(Of ObjectBase)
''' <summary>
''' Some data can be refered on this HistoryPoint. Don't know, in some situations this can be helpful.
''' </summary>
Public ReadOnly Tag As Object = Nothing
Public Function HasEntries(Of T As ObjectBase)() As Boolean
Return Entries.Where(Function(n) TypeOf n Is T).Count > 0
End Function
Friend Sub Undo()
For Each s As ObjectBase In Entries.OrderBy(Function(n) n.UndoPriority)
If TypeOf s Is ObjectState Then
CType(s, ObjectState).Patch()
ElseIf TypeOf s Is ObjectAction Then
CType(s, ObjectAction).Undo()
End If
Next
End Sub
Friend Sub Redo()
For Each s As ObjectBase In Entries.OrderBy(Function(n) n.RedoPriority)
If TypeOf s Is ObjectState Then
CType(s, ObjectState).Patch()
ElseIf TypeOf s Is ObjectAction Then
CType(s, ObjectAction).Redo()
End If
Next
End Sub
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The objects that should be included.</param>
''' <param name="whiteList">Specify which members to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object(), whiteList As MemberWhiteList) As HistoryPoint
Return FromObject({obj}, ObjectValueType.None, CObj(whiteList), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The objects that should be included.</param>
''' <param name="blackList">Specify which members to exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object(), blackList As MemberBlackList) As HistoryPoint
Return FromObject({obj}, ObjectValueType.None, CObj(blackList), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The objects that should be included.</param>
''' <param name="memberName">The member names to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object(), ParamArray memberName As String()) As HistoryPoint
Return FromObject(obj, True, memberName)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The objects that should be included.</param>
''' <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
''' <param name="memberName">The member names to include/exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object(), isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint
If isWhiteList Then
Return FromObject({obj}, ObjectValueType.None, CObj(New MemberWhiteList(memberName)), BindingFlags.Default)
Else
Return FromObject({obj}, ObjectValueType.None, CObj(New MemberBlackList(memberName)), BindingFlags.Default)
End If
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The objects that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="memberName">The member names to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object(), membersToStore As ObjectValueType, ParamArray memberName As String()) As HistoryPoint
Return FromObject(obj, membersToStore, True, memberName)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The objects that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
''' <param name="memberName">The member names to include/exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object(), membersToStore As ObjectValueType, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint
If isWhiteList Then
Return FromObject({obj}, membersToStore, CObj(New MemberWhiteList(memberName)), BindingFlags.Default)
Else
Return FromObject({obj}, membersToStore, CObj(New MemberBlackList(memberName)), BindingFlags.Default)
End If
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The objects that should be included.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <param name="memberName">The member names to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object(), flags As BindingFlags, ParamArray memberName As String()) As HistoryPoint
Return FromObject(obj, flags, True, memberName)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The objects that should be included.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
''' <param name="memberName">The member names to include/exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object(), flags As BindingFlags, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint
If isWhiteList Then
Return FromObject({obj}, ObjectValueType.None, CObj(New MemberWhiteList(memberName)), flags)
Else
Return FromObject({obj}, ObjectValueType.None, CObj(New MemberBlackList(memberName)), flags)
End If
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The objects that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <param name="memberName">The member names to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object(), membersToStore As ObjectValueType, flags As BindingFlags, ParamArray memberName As String()) As HistoryPoint
Return FromObject(obj, flags, True, memberName)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The objects that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
''' <param name="memberName">The member names to include/exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object(), membersToStore As ObjectValueType, flags As BindingFlags, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint
If isWhiteList Then
Return FromObject({obj}, membersToStore, CObj(New MemberWhiteList(memberName)), flags)
Else
Return FromObject({obj}, membersToStore, CObj(New MemberBlackList(memberName)), flags)
End If
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="whiteList">Specify which members to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, whiteList As MemberWhiteList) As HistoryPoint
Return FromObject({obj}, ObjectValueType.None, CObj(whiteList), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="blackList">Specify which members to exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, blackList As MemberBlackList) As HistoryPoint
Return FromObject({obj}, ObjectValueType.None, CObj(blackList), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="memberName">The member names to include/exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, ParamArray memberName As String()) As HistoryPoint
Return FromObject(obj, True, memberName)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
''' <param name="memberName">The member names to include/exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint
If isWhiteList Then
Return FromObject({obj}, ObjectValueType.None, CObj(New MemberWhiteList(memberName)), BindingFlags.Default)
Else
Return FromObject({obj}, ObjectValueType.None, CObj(New MemberBlackList(memberName)), BindingFlags.Default)
End If
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="memberName">The member names to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, ParamArray memberName As String()) As HistoryPoint
Return FromObject(obj, membersToStore, True, memberName)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
''' <param name="memberName">The member names to include/exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint
If isWhiteList Then
Return FromObject({obj}, membersToStore, CObj(New MemberWhiteList(memberName)), BindingFlags.Default)
Else
Return FromObject({obj}, membersToStore, CObj(New MemberBlackList(memberName)), BindingFlags.Default)
End If
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <param name="memberName">The member names to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, flags As BindingFlags, ParamArray memberName As String()) As HistoryPoint
Return FromObject(obj, flags, True, memberName)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
''' <param name="memberName">The member names to include/exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, flags As BindingFlags, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint
If isWhiteList Then
Return FromObject({obj}, ObjectValueType.None, CObj(New MemberWhiteList(memberName)), flags)
Else
Return FromObject({obj}, ObjectValueType.None, CObj(New MemberBlackList(memberName)), flags)
End If
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <param name="memberName">The member names to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, flags As BindingFlags, ParamArray memberName As String()) As HistoryPoint
Return FromObject(obj, flags, True, memberName)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <param name="isWhiteList">If true, the memberName-Array has member names that should be included.</param>
''' <param name="memberName">The member names to include/exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, flags As BindingFlags, isWhiteList As Boolean, ParamArray memberName As String()) As HistoryPoint
If isWhiteList Then
Return FromObject({obj}, membersToStore, CObj(New MemberWhiteList(memberName)), flags)
Else
Return FromObject({obj}, membersToStore, CObj(New MemberBlackList(memberName)), flags)
End If
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object) As HistoryPoint
Return FromObject({obj}, ObjectValueType.None, CObj(Nothing), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType) As HistoryPoint
Return FromObject({obj}, membersToStore, CObj(Nothing), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="whiteList">Specify which members to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, whiteList As MemberWhiteList) As HistoryPoint
Return FromObject({obj}, membersToStore, CObj(whiteList), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="blackList">Specify which members to exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, blackList As MemberBlackList) As HistoryPoint
Return FromObject({obj}, membersToStore, CObj(blackList), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, flags As BindingFlags) As HistoryPoint
Return FromObject({obj}, ObjectValueType.None, CObj(Nothing), flags)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, flags As BindingFlags) As HistoryPoint
Return FromObject({obj}, membersToStore, CObj(Nothing), flags)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="whiteList">Specify which members to include.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, whiteList As MemberWhiteList, flags As BindingFlags) As HistoryPoint
Return FromObject({obj}, membersToStore, CObj(whiteList), flags)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="obj">The object that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="blackList">Specify which members to exclude.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(obj As Object, membersToStore As ObjectValueType, blackList As MemberBlackList, flags As BindingFlags) As HistoryPoint
Return FromObject({obj}, membersToStore, CObj(blackList), flags)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="objs">The objects that should be included.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(objs As Object()) As HistoryPoint
Return FromObject(objs, ObjectValueType.None, CObj(Nothing), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="objs">The objects that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType) As HistoryPoint
Return FromObject(objs, membersToStore, CObj(Nothing), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="objs">The objects that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="whiteList">Specify which members to include.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, whiteList As MemberWhiteList) As HistoryPoint
Return FromObject(objs, membersToStore, CObj(whiteList), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="objs">The objects that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="blackList">Specify which members to exclude.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, blackList As MemberBlackList) As HistoryPoint
Return FromObject(objs, membersToStore, CObj(blackList), BindingFlags.Default)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="objs">The objects that should be included.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(objs As Object(), flags As BindingFlags) As HistoryPoint
Return FromObject(objs, ObjectValueType.None, CObj(Nothing), flags)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="objs">The objects that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, flags As BindingFlags) As HistoryPoint
Return FromObject(objs, membersToStore, CObj(Nothing), flags)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="objs">The objects that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="whiteList">Specify which members to include.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, whiteList As MemberWhiteList, flags As BindingFlags) As HistoryPoint
Return FromObject(objs, membersToStore, CObj(whiteList), flags)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="objs">The objects that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="blackList">Specify which members to exclude.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <returns>A History Point with Object States.</returns>
Public Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, blackList As MemberBlackList, flags As BindingFlags) As HistoryPoint
Return FromObject(objs, membersToStore, CObj(blackList), flags)
End Function
''' <summary>
''' Creates an History Point with Object States automaticly from input.
''' </summary>
''' <param name="objs">The objects that should be included.</param>
''' <param name="membersToStore">Specify what member types to include.</param>
''' <param name="whiteOrBlackList">Specify which members to include.</param>
''' <param name="flags">The Binding Flags that the members should have.</param>
''' <returns>A History Point with Object States.</returns>
Private Shared Function FromObject(objs As Object(), membersToStore As ObjectValueType, whiteOrBlackList As Object, flags As BindingFlags) As HistoryPoint
Dim hp As New HistoryPoint
If whiteOrBlackList Is Nothing Then whiteOrBlackList = New MemberBlackList
Dim isWhiteList As Boolean = TypeOf whiteOrBlackList Is MemberWhiteList
If flags = BindingFlags.Default Then
flags = BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic
End If
If membersToStore = ObjectValueType.None Then
membersToStore = ObjectValueType.Field Or ObjectValueType.Property
End If
For Each obj As Object In objs
If (membersToStore And ObjectValueType.Field) = ObjectValueType.Field Then
For Each fi As FieldInfo In obj.GetType.GetFields(flags)
Dim contains As Boolean = CType(whiteOrBlackList, List(Of String)).Contains(fi.Name)
If If(isWhiteList, contains, Not contains) Then
Dim os As New ObjectState
os.Object = obj
os.MemberName = fi.Name
os.MemberType = ObjectValueType.Field
os.MemberFlags = flags
os.ValueToPatch = fi.GetValue(obj)
hp.Entries.Add(os)
End If
Next
End If
If (membersToStore And ObjectValueType.Property) = ObjectValueType.Property Then
For Each pi As PropertyInfo In obj.GetType.GetProperties(flags)
Dim contains As Boolean = CType(whiteOrBlackList, List(Of String)).Contains(pi.Name)
If If(isWhiteList, contains, Not contains) Then
Dim os As New ObjectState
os.Object = obj
os.MemberName = pi.Name
os.MemberType = ObjectValueType.Property
os.MemberFlags = flags
os.ValueToPatch = pi.GetValue(obj)
hp.Entries.Add(os)
End If
Next
End If
Next
Return hp
End Function
''' <summary>
''' Combines some History Points to one.
''' </summary>
''' <param name="hps">An array of History Points to combine.</param>
''' <returns>One History Point that contains all Data of inputted History Points.</returns>
Public Shared Function Concat(ParamArray hps As HistoryPoint()) As HistoryPoint
Return Concat(hps.FirstOrDefault?.Name, hps)
End Function
''' <summary>
''' Combines some History Points to one.
''' </summary>
''' <param name="hps">An array of History Points to combine.</param>
''' <returns>One History Point that contains all Data of inputted History Points.</returns>
Public Shared Function Concat(newName As String, ParamArray hps As HistoryPoint()) As HistoryPoint
Dim hp As New HistoryPoint
For Each _hp As HistoryPoint In hps
hp.Entries.AddRange(_hp.Entries)
Next
Return hp
End Function
End Class
End Namespace

View File

@@ -1,33 +0,0 @@
using System.Collections.Generic;
namespace Pilz.Collections.SimpleHistory
{
/// <summary>
/// List contianing member names to include.
/// </summary>
public class MemberWhiteList : List<string>
{
public MemberWhiteList() : base()
{
}
public MemberWhiteList(string[] entries) : base(entries)
{
}
}
/// <summary>
/// List contianing member names to exclude
/// </summary>
public class MemberBlackList : List<string>
{
public MemberBlackList() : base()
{
}
public MemberBlackList(string[] entries) : base(entries)
{
}
}
}

View File

@@ -0,0 +1,33 @@
Namespace SimpleHistory
''' <summary>
''' List contianing member names to include.
''' </summary>
Public Class MemberWhiteList
Inherits List(Of String)
Public Sub New()
MyBase.New
End Sub
Public Sub New(entries As String())
MyBase.New(entries)
End Sub
End Class
''' <summary>
''' List contianing member names to exclude
''' </summary>
Public Class MemberBlackList
Inherits List(Of String)
Public Sub New()
MyBase.New
End Sub
Public Sub New(entries As String())
MyBase.New(entries)
End Sub
End Class
End Namespace

View File

@@ -1,176 +0,0 @@
using System;
using System.Collections.Generic;
using global::System.Reflection;
namespace Pilz.Collections.SimpleHistory
{
public class ObjectAction : ObjectBase
{
public object Object { get; set; } = null;
public List<object> ParametersUndo { get; private set; } = new List<object>();
public List<object> ParametersRedo { get; private set; } = new List<object>();
public MethodInfo MethodUndo { get; set; } = null;
public MethodInfo MethodRedo { get; set; } = null;
public bool AutogenerateObject { get; set; } = true;
/// <summary>
/// Creates a new Instance of Object Action.
/// </summary>
public ObjectAction()
{
}
private object GetMethodInfo(object obj, string name, BindingFlags flags)
{
return obj.GetType().GetMethod(name, flags);
}
/// <summary>
/// Creates a new Instance of Object Action.
/// </summary>
/// <param name="obj">The Objects that contains the methodes to call.</param>
/// <param name="methodNameUndo">The name of the methode to call on Undo.</param>
/// <param name="methodNameRedo">The name of the methode to call on Redo.</param>
public ObjectAction(object obj, string methodNameUndo, string methodNameRedo) : this(obj, methodNameUndo, methodNameRedo, Array.Empty<object>(), Array.Empty<object>(), BindingFlags.Default, BindingFlags.Default)
{
}
/// <summary>
/// Creates a new Instance of Object Action.
/// </summary>
/// <param name="obj">The Objects that contains the methodes to call.</param>
/// <param name="methodNameUndo">The name of the methode to call on Undo.</param>
/// <param name="methodNameRedo">The name of the methode to call on Redo.</param>
/// <param name="paramsUndo">The parameters for calling the methode on Undo.</param>
/// <param name="paramsRedo">The parameters for calling the methode on Redo.</param>
public ObjectAction(object obj, string methodNameUndo, string methodNameRedo, object[] paramsUndo, object[] paramsRedo) : this(obj, methodNameUndo, methodNameRedo, paramsUndo, paramsRedo, BindingFlags.Default, BindingFlags.Default)
{
}
/// <summary>
/// Creates a new Instance of Object Action.
/// </summary>
/// <param name="obj">The Objects that contains the methodes to call.</param>
/// <param name="methodNameUndo">The name of the methode to call on Undo.</param>
/// <param name="methodNameRedo">The name of the methode to call on Redo.</param>
/// <param name="paramsUndo">The parameters for calling the methode on Undo.</param>
/// <param name="paramsRedo">The parameters for calling the methode on Redo.</param>
/// <param name="methodFlagsUndo">The Binding Flags of Methode on Undo.</param>
/// <param name="methodFlagsRedo">The Binding Flags of Methode on Redo.</param>
public ObjectAction(object obj, string methodNameUndo, string methodNameRedo, object[] paramsUndo, object[] paramsRedo, BindingFlags methodFlagsUndo, BindingFlags methodFlagsRedo)
{
Object = obj;
ParametersUndo.AddRange(paramsUndo);
ParametersRedo.AddRange(paramsRedo);
MethodUndo = (MethodInfo)GetMethodInfo(obj, methodNameUndo, GetFlags(methodFlagsUndo));
MethodRedo = (MethodInfo)GetMethodInfo(obj, methodNameRedo, GetFlags(methodFlagsRedo));
}
/// <summary>
/// Creates a new Instance of Object Action.
/// </summary>
/// <param name="obj">The Objects that contains the methodes to call.</param>
/// <param name="methodNameUndo">The name of the methode to call on Undo.</param>
/// <param name="methodNameRedo">The name of the methode to call on Redo.</param>
/// <param name="methodFlagsUndo">The Binding Flags of Methode on Undo.</param>
/// <param name="methodFlagsRedo">The Binding Flags of Methode on Redo.</param>
public ObjectAction(object obj, string methodNameUndo, string methodNameRedo, BindingFlags methodFlagsUndo, BindingFlags methodFlagsRedo) : this(obj, methodNameUndo, methodNameRedo, Array.Empty<object>(), Array.Empty<object>(), methodFlagsUndo, methodFlagsRedo)
{
}
/// <summary>
/// Creates a new Instance of Object Action.
/// </summary>
/// <param name="obj">The Objects that contains the methodes to call.</param>
/// <param name="methodUndo">The MethodInfo of the methode to call on Undo.</param>
/// <param name="methodRedo">The MethodInfo of the methode to call on Redo.</param>
public ObjectAction(object obj, MethodInfo methodUndo, MethodInfo methodRedo)
{
Object = obj;
MethodUndo = methodUndo;
MethodRedo = methodRedo;
}
/// <summary>
/// Creates a new Instance of Object Action.
/// </summary>
/// <param name="obj">The Objects that contains the methodes to call.</param>
/// <param name="methodUndo">The MethodInfo of the methode to call on Undo.</param>
/// <param name="methodRedo">The MethodInfo of the methode to call on Redo.</param>
/// <param name="paramsUndo">The parameters for calling the methode on Undo.</param>
/// <param name="paramsRedo">The parameters for calling the methode on Redo.</param>
public ObjectAction(object obj, MethodInfo methodUndo, MethodInfo methodRedo, object[] paramsUndo, object[] paramsRedo) : this(obj, methodUndo, methodRedo)
{
ParametersUndo.AddRange(paramsUndo);
ParametersRedo.AddRange(paramsRedo);
}
/// <summary>
/// Creates a new Instance of Object Action.
/// </summary>
/// <param name="obj">The Objects that contains the methodes to call.</param>
/// <param name="methodUndo">The Delegate of the methode to call on Undo.</param>
/// <param name="methodRedo">The Delegate of the methode to call on Redo.</param>
public ObjectAction(object obj, Delegate methodUndo, Delegate methodRedo)
{
Object = obj;
MethodUndo = methodUndo.Method;
MethodRedo = methodRedo.Method;
}
/// <summary>
/// Creates a new Instance of Object Action.
/// </summary>
/// <param name="obj">The Objects that contains the methodes to call.</param>
/// <param name="methodUndo">The Delegate of the methode to call on Undo.</param>
/// <param name="methodRedo">The Delegate of the methode to call on Redo.</param>
/// <param name="paramsUndo">The parameters for calling the methode on Undo.</param>
/// <param name="paramsRedo">The parameters for calling the methode on Redo.</param>
public ObjectAction(object obj, Delegate methodUndo, Delegate methodRedo, object[] paramsUndo, object[] paramsRedo) : this(obj, methodUndo, methodRedo)
{
ParametersUndo.AddRange(paramsUndo);
ParametersRedo.AddRange(paramsRedo);
}
/// <summary>
/// Creates a new Instance of Object Action.
/// </summary>
/// <param name="obj">The Objects that contains the methodes to call.</param>
/// <param name="methodUndo">The Action of the methode to call on Undo.</param>
/// <param name="methodRedo">The Action of the methode to call on Redo.</param>
public ObjectAction(object obj, Action methodUndo, Action methodRedo)
{
Object = obj;
MethodUndo = methodUndo.Method;
MethodRedo = methodRedo.Method;
}
private BindingFlags GetFlags(BindingFlags flags)
{
if (flags == BindingFlags.Default)
{
flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
}
return flags;
}
internal void Undo()
{
CheckIfObjIsNothing(MethodUndo);
MethodUndo?.Invoke(Object, ParametersUndo.ToArray());
}
internal void Redo()
{
CheckIfObjIsNothing(MethodRedo);
MethodRedo?.Invoke(Object, ParametersRedo.ToArray());
}
private void CheckIfObjIsNothing(MethodInfo mi)
{
if (mi is object && !mi.IsStatic && AutogenerateObject)
{
if ((Object is null || Object.GetType() != mi.ReflectedType) && !mi.IsStatic)
{
var constructor = mi.ReflectedType.GetConstructor(Type.EmptyTypes);
var classObject = constructor.Invoke(Array.Empty<object>());
Object = classObject;
}
}
}
}
}

View File

@@ -0,0 +1,165 @@
Imports System.Reflection
Imports System.Runtime.InteropServices
Namespace SimpleHistory
Public Class ObjectAction
Inherits ObjectBase
Public Property [Object] As Object = Nothing
Public ReadOnly Property ParametersUndo As New List(Of Object)
Public ReadOnly Property ParametersRedo As New List(Of Object)
Public Property MethodUndo As MethodInfo = Nothing
Public Property MethodRedo As MethodInfo = Nothing
Public Property AutogenerateObject As Boolean = True
''' <summary>
''' Creates a new Instance of Object Action.
''' </summary>
Public Sub New()
End Sub
Private Function GetMethodInfo(obj As Object, name As String, flags As BindingFlags)
Return obj.GetType.GetMethod(name, flags)
End Function
''' <summary>
''' Creates a new Instance of Object Action.
''' </summary>
''' <param name="obj">The Objects that contains the methodes to call.</param>
''' <param name="methodNameUndo">The name of the methode to call on Undo.</param>
''' <param name="methodNameRedo">The name of the methode to call on Redo.</param>
Public Sub New(obj As Object, methodNameUndo As String, methodNameRedo As String)
Me.New(obj, methodNameUndo, methodNameRedo, {}, {}, BindingFlags.Default, BindingFlags.Default)
End Sub
''' <summary>
''' Creates a new Instance of Object Action.
''' </summary>
''' <param name="obj">The Objects that contains the methodes to call.</param>
''' <param name="methodNameUndo">The name of the methode to call on Undo.</param>
''' <param name="methodNameRedo">The name of the methode to call on Redo.</param>
''' <param name="paramsUndo">The parameters for calling the methode on Undo.</param>
''' <param name="paramsRedo">The parameters for calling the methode on Redo.</param>
Public Sub New(obj As Object, methodNameUndo As String, methodNameRedo As String, paramsUndo As Object(), paramsRedo As Object())
Me.New(obj, methodNameUndo, methodNameRedo, paramsUndo, paramsRedo, BindingFlags.Default, BindingFlags.Default)
End Sub
''' <summary>
''' Creates a new Instance of Object Action.
''' </summary>
''' <param name="obj">The Objects that contains the methodes to call.</param>
''' <param name="methodNameUndo">The name of the methode to call on Undo.</param>
''' <param name="methodNameRedo">The name of the methode to call on Redo.</param>
''' <param name="paramsUndo">The parameters for calling the methode on Undo.</param>
''' <param name="paramsRedo">The parameters for calling the methode on Redo.</param>
''' <param name="methodFlagsUndo">The Binding Flags of Methode on Undo.</param>
''' <param name="methodFlagsRedo">The Binding Flags of Methode on Redo.</param>
Public Sub New(obj As Object, methodNameUndo As String, methodNameRedo As String, paramsUndo As Object(), paramsRedo As Object(), methodFlagsUndo As BindingFlags, methodFlagsRedo As BindingFlags)
[Object] = obj
ParametersUndo.AddRange(paramsUndo)
ParametersRedo.AddRange(paramsRedo)
MethodUndo = GetMethodInfo(obj, methodNameUndo, GetFlags(methodFlagsUndo))
MethodRedo = GetMethodInfo(obj, methodNameRedo, GetFlags(methodFlagsRedo))
End Sub
''' <summary>
''' Creates a new Instance of Object Action.
''' </summary>
''' <param name="obj">The Objects that contains the methodes to call.</param>
''' <param name="methodNameUndo">The name of the methode to call on Undo.</param>
''' <param name="methodNameRedo">The name of the methode to call on Redo.</param>
''' <param name="methodFlagsUndo">The Binding Flags of Methode on Undo.</param>
''' <param name="methodFlagsRedo">The Binding Flags of Methode on Redo.</param>
Public Sub New(obj As Object, methodNameUndo As String, methodNameRedo As String, methodFlagsUndo As BindingFlags, methodFlagsRedo As BindingFlags)
Me.New(obj, methodNameUndo, methodNameRedo, {}, {}, methodFlagsUndo, methodFlagsRedo)
End Sub
''' <summary>
''' Creates a new Instance of Object Action.
''' </summary>
''' <param name="obj">The Objects that contains the methodes to call.</param>
''' <param name="methodUndo">The MethodInfo of the methode to call on Undo.</param>
''' <param name="methodRedo">The MethodInfo of the methode to call on Redo.</param>
Public Sub New(obj As Object, methodUndo As MethodInfo, methodRedo As MethodInfo)
[Object] = obj
Me.MethodUndo = methodUndo
Me.MethodRedo = methodRedo
End Sub
''' <summary>
''' Creates a new Instance of Object Action.
''' </summary>
''' <param name="obj">The Objects that contains the methodes to call.</param>
''' <param name="methodUndo">The MethodInfo of the methode to call on Undo.</param>
''' <param name="methodRedo">The MethodInfo of the methode to call on Redo.</param>
''' <param name="paramsUndo">The parameters for calling the methode on Undo.</param>
''' <param name="paramsRedo">The parameters for calling the methode on Redo.</param>
Public Sub New(obj As Object, methodUndo As MethodInfo, methodRedo As MethodInfo, paramsUndo As Object(), paramsRedo As Object())
Me.New(obj, methodUndo, methodRedo)
ParametersUndo.AddRange(paramsUndo)
ParametersRedo.AddRange(paramsRedo)
End Sub
''' <summary>
''' Creates a new Instance of Object Action.
''' </summary>
''' <param name="obj">The Objects that contains the methodes to call.</param>
''' <param name="methodUndo">The Delegate of the methode to call on Undo.</param>
''' <param name="methodRedo">The Delegate of the methode to call on Redo.</param>
Public Sub New(obj As Object, methodUndo As [Delegate], methodRedo As [Delegate])
[Object] = obj
Me.MethodUndo = methodUndo.Method
Me.MethodRedo = methodRedo.Method
End Sub
''' <summary>
''' Creates a new Instance of Object Action.
''' </summary>
''' <param name="obj">The Objects that contains the methodes to call.</param>
''' <param name="methodUndo">The Delegate of the methode to call on Undo.</param>
''' <param name="methodRedo">The Delegate of the methode to call on Redo.</param>
''' <param name="paramsUndo">The parameters for calling the methode on Undo.</param>
''' <param name="paramsRedo">The parameters for calling the methode on Redo.</param>
Public Sub New(obj As Object, methodUndo As [Delegate], methodRedo As [Delegate], paramsUndo As Object(), paramsRedo As Object())
Me.New(obj, methodUndo, methodRedo)
ParametersUndo.AddRange(paramsUndo)
ParametersRedo.AddRange(paramsRedo)
End Sub
''' <summary>
''' Creates a new Instance of Object Action.
''' </summary>
''' <param name="obj">The Objects that contains the methodes to call.</param>
''' <param name="methodUndo">The Action of the methode to call on Undo.</param>
''' <param name="methodRedo">The Action of the methode to call on Redo.</param>
Public Sub New(obj As Object, methodUndo As Action, methodRedo As Action)
[Object] = obj
Me.MethodUndo = methodUndo.Method
Me.MethodRedo = methodRedo.Method
End Sub
Private Function GetFlags(flags As BindingFlags) As BindingFlags
If flags = BindingFlags.Default Then
flags = BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic
End If
Return flags
End Function
Friend Sub Undo()
CheckIfObjIsNothing(MethodUndo)
MethodUndo?.Invoke([Object], ParametersUndo.ToArray)
End Sub
Friend Sub Redo()
CheckIfObjIsNothing(MethodRedo)
MethodRedo?.Invoke([Object], ParametersRedo.ToArray)
End Sub
Private Sub CheckIfObjIsNothing(mi As MethodInfo)
If mi IsNot Nothing AndAlso Not mi.IsStatic AndAlso AutogenerateObject Then
If (Me.Object Is Nothing OrElse Me.Object.GetType <> mi.ReflectedType) AndAlso Not mi.IsStatic Then
Dim constructor As ConstructorInfo = mi.ReflectedType.GetConstructor(Type.EmptyTypes)
Dim classObject As Object = constructor.Invoke({})
Me.Object = classObject
End If
End If
End Sub
End Class
End Namespace

View File

@@ -1,10 +0,0 @@
namespace Pilz.Collections.SimpleHistory
{
public class ObjectBase
{
public static int DefaultPriorityValue { get; set; } = 1000;
public int UndoPriority { get; set; } = DefaultPriorityValue;
public int RedoPriority { get; set; } = DefaultPriorityValue;
}
}

View File

@@ -0,0 +1,13 @@
Namespace SimpleHistory
Public Class ObjectBase
Public Shared Property DefaultPriorityValue As Integer = 1000
Public Property UndoPriority As Integer = DefaultPriorityValue
Public Property RedoPriority As Integer = DefaultPriorityValue
End Class
End Namespace

View File

@@ -1,98 +0,0 @@
using System;
using global::System.Reflection;
namespace Pilz.Collections.SimpleHistory
{
public class ObjectState : ObjectBase
{
/// <summary>
/// The Object including the members to patch.
/// </summary>
/// <returns></returns>
public object Object { get; set; } = null;
/// <summary>
/// The name of the Member to patch.
/// </summary>
/// <returns></returns>
public string MemberName { get; set; } = "";
/// <summary>
/// The Value that should be patched.
/// </summary>
/// <returns></returns>
public object ValueToPatch { get; set; } = null;
/// <summary>
/// The member types to include at searching for the member.
/// </summary>
/// <returns></returns>
public ObjectValueType MemberType { get; set; } = ObjectValueType.Field;
/// <summary>
/// The Binding Flags that are used at searching for the member.
/// </summary>
/// <returns></returns>
public BindingFlags MemberFlags { get; set; } = BindingFlags.Default;
/// <summary>
/// Creates a new Instance of ObjectState from input.
/// </summary>
/// <param name="obj">The Object including the members to patch.</param>
/// <param name="valname">The name of the Member to patch.</param>
/// <param name="valToPatch">The member types to include at searching for the member.</param>
/// <param name="valtype">The Binding Flags that are used at searching for the member.</param>
public ObjectState(object obj, string valname, object valToPatch, ObjectValueType valtype)
{
Object = obj;
MemberName = valname;
ValueToPatch = valToPatch;
MemberType = valtype;
}
/// <summary>
/// Creates a new Instance of ObjectState.
/// </summary>
public ObjectState()
{
}
internal void Patch()
{
var t = Object.GetType();
switch (MemberType)
{
case ObjectValueType.Field:
{
var f = t.GetField(MemberName, MemberFlags);
object temp = null;
if (f is object)
{
temp = f.GetValue(Object);
f.SetValue(Object, ValueToPatch);
ValueToPatch = temp;
}
break;
}
case ObjectValueType.Property:
{
var p = t.GetProperty(MemberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
object temp = null;
if (p is object)
{
temp = p.GetValue(Object);
p.SetValue(Object, ValueToPatch);
ValueToPatch = temp;
}
break;
}
default:
{
throw new Exception("ValueType is invalid!");
break;
}
}
}
}
}

View File

@@ -0,0 +1,84 @@
Imports System.Reflection
Namespace SimpleHistory
Public Class ObjectState
Inherits ObjectBase
''' <summary>
''' The Object including the members to patch.
''' </summary>
''' <returns></returns>
Public Property [Object] As Object = Nothing
''' <summary>
''' The name of the Member to patch.
''' </summary>
''' <returns></returns>
Public Property MemberName As String = ""
''' <summary>
''' The Value that should be patched.
''' </summary>
''' <returns></returns>
Public Property ValueToPatch As Object = Nothing
''' <summary>
''' The member types to include at searching for the member.
''' </summary>
''' <returns></returns>
Public Property MemberType As ObjectValueType = ObjectValueType.Field
''' <summary>
''' The Binding Flags that are used at searching for the member.
''' </summary>
''' <returns></returns>
Public Property MemberFlags As BindingFlags = BindingFlags.Default
''' <summary>
''' Creates a new Instance of ObjectState from input.
''' </summary>
''' <param name="obj">The Object including the members to patch.</param>
''' <param name="valname">The name of the Member to patch.</param>
''' <param name="valToPatch">The member types to include at searching for the member.</param>
''' <param name="valtype">The Binding Flags that are used at searching for the member.</param>
Public Sub New(obj As Object, valname As String, valToPatch As Object, valtype As ObjectValueType)
[Object] = obj
MemberName = valname
ValueToPatch = valToPatch
MemberType = valtype
End Sub
''' <summary>
''' Creates a new Instance of ObjectState.
''' </summary>
Public Sub New()
End Sub
Friend Sub Patch()
Dim t As Type = [Object].GetType
Select Case MemberType
Case ObjectValueType.Field
Dim f As FieldInfo = t.GetField(MemberName, MemberFlags)
Dim temp As Object = Nothing
If f IsNot Nothing Then
temp = f.GetValue([Object])
f.SetValue([Object], ValueToPatch)
ValueToPatch = temp
End If
Case ObjectValueType.Property
Dim p As PropertyInfo = t.GetProperty(MemberName, BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic Or BindingFlags.Static)
Dim temp As Object = Nothing
If p IsNot Nothing Then
temp = p.GetValue([Object])
p.SetValue([Object], ValueToPatch)
ValueToPatch = temp
End If
Case Else
Throw New Exception("ValueType is invalid!")
End Select
End Sub
End Class
End Namespace

View File

@@ -1,14 +0,0 @@
namespace Pilz.Collections.SimpleHistory
{
/// <summary>
/// Specify which member types you would include.
/// </summary>
public enum ObjectValueType
{
None = 0,
Field = 1,
Property = 2
}
}

View File

@@ -0,0 +1,12 @@
Namespace SimpleHistory
''' <summary>
''' Specify which member types you would include.
''' </summary>
Public Enum ObjectValueType
None = 0
Field = 1
[Property] = 2
End Enum
End Namespace

View File

@@ -1,104 +0,0 @@
using System.Collections.Generic;
using Microsoft.VisualBasic.CompilerServices;
namespace Pilz.Collections.SimpleHistory
{
public class HistoryStack
{
private Stack<HistoryPoint> stackPast = new Stack<HistoryPoint>();
private Stack<HistoryPoint> stackFuture = new Stack<HistoryPoint>();
/// <summary>
/// Gets the count of history points.
/// </summary>
/// <returns></returns>
public bool ChangesCount
{
get
{
return Conversions.ToBoolean(stackPast.Count);
}
}
/// <summary>
/// Checks if the History has past changes.
/// </summary>
/// <returns></returns>
public bool HasChanges()
{
return stackPast.Count > 0;
}
/// <summary>
/// Patch Object States and call Undo Actions.
/// </summary>
public HistoryPoint Undo()
{
HistoryPoint ret;
if (stackPast.Count > 0)
{
var hp = stackPast.Pop();
hp.Undo();
stackFuture.Push(hp);
ret = hp;
}
else
{
ret = null;
}
return ret;
}
/// <summary>
/// Patch Object States and call Redo Actions.
/// </summary>
public HistoryPoint Redo()
{
HistoryPoint ret;
if (stackFuture.Count > 0)
{
var hp = stackFuture.Pop();
hp.Redo();
stackPast.Push(hp);
ret = hp;
}
else
{
ret = null;
}
return ret;
}
/// <summary>
/// Clear the History.
/// </summary>
public void Clear()
{
stackPast.Clear();
stackFuture.Clear();
}
/// <summary>
/// Store a History Point.
/// </summary>
/// <param name="point">The History Point to add to the past changes.</param>
/// <param name="newName">The name to set for the History Point.</param>
public void Store(HistoryPoint point, string newName)
{
point.Name = newName;
Store(point);
}
/// <summary>
/// Store a History Point.
/// </summary>
/// <param name="point">The History Point to add to the past changes.</param>
public void Store(HistoryPoint point)
{
stackPast.Push(point);
stackFuture.Clear();
}
}
}

View File

@@ -0,0 +1,93 @@
Imports System.Reflection
Namespace SimpleHistory
Public Class HistoryStack
Private stackPast As New Stack(Of HistoryPoint)
Private stackFuture As New Stack(Of HistoryPoint)
''' <summary>
''' Gets the count of history points.
''' </summary>
''' <returns></returns>
Public ReadOnly Property ChangesCount As Boolean
Get
Return stackPast.Count
End Get
End Property
''' <summary>
''' Checks if the History has past changes.
''' </summary>
''' <returns></returns>
Public Function HasChanges() As Boolean
Return stackPast.Count > 0
End Function
''' <summary>
''' Patch Object States and call Undo Actions.
''' </summary>
Public Function Undo() As HistoryPoint
Dim ret As HistoryPoint
If stackPast.Count > 0 Then
Dim hp As HistoryPoint = stackPast.Pop
hp.Undo()
stackFuture.Push(hp)
ret = hp
Else
ret = Nothing
End If
Return ret
End Function
''' <summary>
''' Patch Object States and call Redo Actions.
''' </summary>
Public Function Redo() As HistoryPoint
Dim ret As HistoryPoint
If stackFuture.Count > 0 Then
Dim hp As HistoryPoint = stackFuture.Pop
hp.Redo()
stackPast.Push(hp)
ret = hp
Else
ret = Nothing
End If
Return ret
End Function
''' <summary>
''' Clear the History.
''' </summary>
Public Sub Clear()
stackPast.Clear()
stackFuture.Clear()
End Sub
''' <summary>
''' Store a History Point.
''' </summary>
''' <param name="point">The History Point to add to the past changes.</param>
''' <param name="newName">The name to set for the History Point.</param>
Public Sub Store(point As HistoryPoint, newName As String)
point.Name = newName
Store(point)
End Sub
''' <summary>
''' Store a History Point.
''' </summary>
''' <param name="point">The History Point to add to the past changes.</param>
Public Sub Store(point As HistoryPoint)
stackPast.Push(point)
stackFuture.Clear()
End Sub
End Class
End Namespace