Projektdateien hinzufügen.

This commit is contained in:
2019-04-02 18:47:41 +02:00
parent 2ce6f5f16d
commit ef15e45df7
138 changed files with 8675 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>

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

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>true</MySubMain>
<MainForm>Form1</MainForm>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>
<AuthenticationMode>0</AuthenticationMode>
<ApplicationType>0</ApplicationType>
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>

View File

@@ -0,0 +1,35 @@
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' Allgemeine Informationen über eine Assembly werden über die folgenden
' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
' die einer Assembly zugeordnet sind.
' Werte der Assemblyattribute überprüfen
<Assembly: AssemblyTitle("SimpleHistory")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("Dr. Schneider Kunststoffwerke GmbH")>
<Assembly: AssemblyProduct("SimpleHistory")>
<Assembly: AssemblyCopyright("Copyright © Pascal Schedel 2018")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird.
<Assembly: Guid("7dd4cf70-efc1-4386-a169-39ec65e4aef3")>
' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
'
' Hauptversion
' Nebenversion
' Buildnummer
' Revision
'
' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>

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,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

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

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E4B2D294-8479-4014-942D-0B460E453DEA}</ProjectGuid>
<OutputType>Library</OutputType>
<StartupObject>
</StartupObject>
<RootNamespace>Pilz.Collections</RootNamespace>
<AssemblyName>Pilz.Collections</AssemblyName>
<FileAlignment>512</FileAlignment>
<MyType>Windows</MyType>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>Pilz.Collections.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,40008</NoWarn>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DocumentationFile>Pilz.Collections.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<Prefer32Bit>false</Prefer32Bit>
<RemoveIntegerChecks>true</RemoveIntegerChecks>
</PropertyGroup>
<PropertyGroup>
<OptionExplicit>On</OptionExplicit>
</PropertyGroup>
<PropertyGroup>
<OptionCompare>Binary</OptionCompare>
</PropertyGroup>
<PropertyGroup>
<OptionStrict>Off</OptionStrict>
</PropertyGroup>
<PropertyGroup>
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\x86\Debug\</OutputPath>
<DocumentationFile>Pilz.Collections.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022,40008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<DefineTrace>true</DefineTrace>
<OutputPath>bin\x86\Release\</OutputPath>
<RemoveIntegerChecks>true</RemoveIntegerChecks>
<DocumentationFile>Pilz.Collections.xml</DocumentationFile>
<Optimize>true</Optimize>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup>
<Import Include="Microsoft.VisualBasic" />
<Import Include="System" />
<Import Include="System.Collections" />
<Import Include="System.Collections.Generic" />
<Import Include="System.Data" />
<Import Include="System.Drawing" />
<Import Include="System.Diagnostics" />
<Import Include="System.Windows.Forms" />
<Import Include="System.Linq" />
<Import Include="System.Xml.Linq" />
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="SimpleHistory\Enums.vb" />
<Compile Include="SimpleHistory\HistoryPoint.vb" />
<Compile Include="SimpleHistory\MemberLists.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon>
</Compile>
<Compile Include="My Project\Resources.Designer.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="My Project\Settings.Designer.vb">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="SimpleHistory\ObjectAction.vb" />
<Compile Include="SimpleHistory\ObjectBase.vb" />
<Compile Include="SimpleHistory\ObjectState.vb" />
<Compile Include="SimpleHistory\SimpleHistory.vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="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.vb</LastGenOutput>
</None>
<None Include="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
</Project>

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

@@ -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 = whiteOrBlackList.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 = whiteOrBlackList.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

@@ -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

@@ -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

@@ -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

@@ -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

@@ -0,0 +1,89 @@
Imports System.Reflection
Namespace SimpleHistory
Public Class HistoryStack
Private stackPast As New Stack(Of HistoryPoint)
Private stackFuture As New Stack(Of HistoryPoint)
''' <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