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,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;
}
}
}
}
}