remove obsolete code in favor of using .NET-provided classes
This commit is contained in:
parent
f242a8c304
commit
0f09dd9288
@ -1,144 +0,0 @@
|
||||
//
|
||||
// NameValuePair.cs - represents a name-value pair of String expressions (not sure why we did this)
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2011-2020 Mike Becker's Software
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace UniversalEditor
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a name-value pair of String expressions (not sure why we did this).
|
||||
/// </summary>
|
||||
public class NameValuePair : NameValuePair<string>
|
||||
{
|
||||
public NameValuePair(string Name) : base(Name)
|
||||
{
|
||||
}
|
||||
|
||||
public NameValuePair(string Name, string Value) : base(Name, Value)
|
||||
{
|
||||
}
|
||||
}
|
||||
public class NameValuePair<T> : ICloneable
|
||||
{
|
||||
private string mvarName;
|
||||
private T mvarValue;
|
||||
|
||||
public NameValuePair(string Name)
|
||||
{
|
||||
this.mvarName = "";
|
||||
this.mvarValue = default(T);
|
||||
this.mvarName = Name;
|
||||
this.mvarValue = default(T);
|
||||
}
|
||||
|
||||
public NameValuePair(string Name, T Value)
|
||||
{
|
||||
this.mvarName = "";
|
||||
this.mvarValue = default(T);
|
||||
this.mvarName = Name;
|
||||
this.mvarValue = Value;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mvarName;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.mvarName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mvarValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.mvarValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public class NameValuePairCollection : System.Collections.ObjectModel.Collection<NameValuePair<T>>
|
||||
{
|
||||
public NameValuePair<T> Add(string Name)
|
||||
{
|
||||
return this.Add(Name, default(T));
|
||||
}
|
||||
|
||||
public NameValuePair<T> Add(string Name, T Value)
|
||||
{
|
||||
NameValuePair<T> p = new NameValuePair<T>(Name, Value);
|
||||
base.Add(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
public bool Contains(string Name)
|
||||
{
|
||||
return (this[Name] != null);
|
||||
}
|
||||
|
||||
public bool Remove(string Name)
|
||||
{
|
||||
NameValuePair<T> p = this[Name];
|
||||
if (p != null)
|
||||
{
|
||||
base.Remove(p);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public NameValuePair<T> this[string Name]
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (NameValuePair<T> p in this)
|
||||
{
|
||||
if (p.Name == Name)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
NameValuePair<T> clone = new NameValuePair<T>(mvarName.Clone() as string);
|
||||
if (mvarValue is ICloneable)
|
||||
{
|
||||
clone.Value = (T)((mvarValue as ICloneable).Clone());
|
||||
}
|
||||
else
|
||||
{
|
||||
clone.Value = mvarValue;
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,226 +0,0 @@
|
||||
//
|
||||
// NameValuePairGroup.cs - represents a grouped collection of NameValuePair<T> items
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2011-2020 Mike Becker's Software
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace UniversalEditor
|
||||
{
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a grouped collection of <see cref="NameValuePair{T}" /> items.
|
||||
/// </summary>
|
||||
public class NameValuePairGroup<T>
|
||||
{
|
||||
private NameValuePairGroupCollection mvarGroups;
|
||||
private NameValuePair<T>.NameValuePairCollection mvarItems;
|
||||
private string mvarName;
|
||||
private string mvarPathSeparator;
|
||||
|
||||
public NameValuePairGroup(string Name)
|
||||
{
|
||||
mvarGroups = new NameValuePairGroupCollection();
|
||||
mvarItems = new NameValuePair<T>.NameValuePairCollection();
|
||||
mvarPathSeparator = "";
|
||||
mvarName = Name;
|
||||
}
|
||||
|
||||
public NameValuePairGroup<T> GetGroup(string GroupName)
|
||||
{
|
||||
string[] path = GroupName.Split(new string[] { this.mvarPathSeparator }, StringSplitOptions.None);
|
||||
if (path.Length == 1)
|
||||
{
|
||||
return this.mvarGroups[path[0]];
|
||||
}
|
||||
NameValuePairGroup<T> pgParent = this.mvarGroups[path[0]];
|
||||
int i = 1;
|
||||
while (pgParent != null)
|
||||
{
|
||||
if (pgParent.Groups[path[i]] != null)
|
||||
{
|
||||
pgParent = pgParent.Groups[path[i]];
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pgParent.Groups[path[path.Length - 1]];
|
||||
}
|
||||
|
||||
public NameValuePair<T> GetItem(string PropertyName)
|
||||
{
|
||||
string[] path = PropertyName.Split(new string[] { this.mvarPathSeparator }, StringSplitOptions.None);
|
||||
if (path.Length == 1)
|
||||
{
|
||||
return mvarItems[path[0]];
|
||||
}
|
||||
NameValuePairGroup<T> pgParent = mvarGroups[path[0]];
|
||||
int i = 1;
|
||||
while (pgParent != null)
|
||||
{
|
||||
if (pgParent.Groups[path[i]] != null)
|
||||
{
|
||||
pgParent = pgParent.Groups[path[i]];
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pgParent.Items[path[path.Length - 1]];
|
||||
}
|
||||
|
||||
public bool GetItemValueAsBoolean(string ValueName)
|
||||
{
|
||||
return this.GetItemValueAsBoolean(ValueName, false);
|
||||
}
|
||||
|
||||
public bool GetItemValueAsBoolean(string ValueName, bool DefaultValue)
|
||||
{
|
||||
string val = this.GetItemValueAsString(ValueName);
|
||||
if ((((val.ToLower() == "1") || (val.ToLower() == "true")) || (val.ToLower() == "yes")) || (val.ToLower() == "on"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if ((((val.ToLower() == "0") || (val.ToLower() == "false")) || (val.ToLower() == "no")) || (val.ToLower() == "off"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return DefaultValue;
|
||||
}
|
||||
|
||||
public int GetItemValueAsInteger(string ValueName)
|
||||
{
|
||||
return this.GetItemValueAsInteger(ValueName, -1);
|
||||
}
|
||||
|
||||
public int GetItemValueAsInteger(string ValueName, int DefaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
return int.Parse(this.GetItemValueAsString(ValueName, DefaultValue.ToString()));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return DefaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetItemValueAsString(string ValueName)
|
||||
{
|
||||
return this.GetItemValueAsString(ValueName, "");
|
||||
}
|
||||
|
||||
public string GetItemValueAsString(string ValueName, string DefaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.GetItem(ValueName).Value.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return DefaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public NameValuePairGroupCollection Groups
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mvarGroups;
|
||||
}
|
||||
}
|
||||
|
||||
public NameValuePair<T>.NameValuePairCollection Items
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mvarItems;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mvarName;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.mvarName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string PathSeparator
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.mvarPathSeparator;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.mvarPathSeparator = value;
|
||||
}
|
||||
}
|
||||
|
||||
public class NameValuePairGroupCollection : System.Collections.ObjectModel.Collection<NameValuePairGroup<T>>
|
||||
{
|
||||
public NameValuePairGroup<T> Add(string Name)
|
||||
{
|
||||
NameValuePairGroup<T> pg = new NameValuePairGroup<T>(Name);
|
||||
base.Add(pg);
|
||||
return pg;
|
||||
}
|
||||
|
||||
public bool Contains(string Name)
|
||||
{
|
||||
return (this[Name] != null);
|
||||
}
|
||||
|
||||
public bool Remove(string Name)
|
||||
{
|
||||
NameValuePairGroup<T> pg = this[Name];
|
||||
if (pg != null)
|
||||
{
|
||||
base.Remove(pg);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public NameValuePairGroup<T> this[string Name]
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (NameValuePairGroup<T> pg in this)
|
||||
{
|
||||
if (pg.Name == Name)
|
||||
{
|
||||
return pg;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,8 +74,6 @@
|
||||
<Compile Include="DataFormats\Text\Formatted\RichText\RTFGenerator.cs" />
|
||||
<Compile Include="DataFormats\UEPackage\UEPackageXMLDataFormat.cs" />
|
||||
<Compile Include="ExpandedString.cs" />
|
||||
<Compile Include="NameValuePair.cs" />
|
||||
<Compile Include="NameValuePairGroup.cs" />
|
||||
<Compile Include="ObjectModels\AbstractSyntax\AbstractSyntaxObjectModel.cs" />
|
||||
<Compile Include="ObjectModels\Chunked\ChunkedObjectModel.cs" />
|
||||
<Compile Include="ObjectModels\Chunked\RIFFChunk.cs" />
|
||||
|
||||
@ -26,6 +26,7 @@ using UniversalEditor.ObjectModels.Executable;
|
||||
using UniversalEditor.ObjectModels.FileSystem;
|
||||
|
||||
using UniversalEditor.DataFormats.Executable.Microsoft.PortableExecutable;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if EXECUTABLE_LOAD_RESOURCES
|
||||
using UniversalEditor.DataFormats.Resource.Microsoft;
|
||||
@ -40,7 +41,7 @@ namespace UniversalEditor.DataFormats.Executable.Microsoft
|
||||
/// </summary>
|
||||
public class MicrosoftExecutableDataFormat : DataFormat
|
||||
{
|
||||
public NameValuePair<int>.NameValuePairCollection ImportTable { get; } = new NameValuePair<int>.NameValuePairCollection();
|
||||
public Dictionary<string, int> ImportTable { get; } = new Dictionary<string, int>();
|
||||
public System.Reflection.Assembly CLRAssembly { get; private set; } = null;
|
||||
|
||||
private static DataFormatReference _dfr;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user