Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,49 @@
using System;
namespace Server.Engines.Reports
{
public abstract class PersistableObject
{
public PersistableObject()
{
}
public abstract PersistableType TypeID { get; }
public virtual void SerializeAttributes(PersistenceWriter op)
{
}
public virtual void SerializeChildren(PersistenceWriter op)
{
}
public void Serialize(PersistenceWriter op)
{
op.BeginObject(this.TypeID);
this.SerializeAttributes(op);
op.BeginChildren();
this.SerializeChildren(op);
op.FinishChildren();
op.FinishObject();
}
public virtual void DeserializeAttributes(PersistenceReader ip)
{
}
public virtual void DeserializeChildren(PersistenceReader ip)
{
}
public void Deserialize(PersistenceReader ip)
{
this.DeserializeAttributes(ip);
if (ip.BeginChildren())
{
this.DeserializeChildren(ip);
ip.FinishChildren();
}
}
}
}

View File

@@ -0,0 +1,196 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.573
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
namespace Server.Engines.Reports
{
using System;
using System.Collections;
/// <summary>
/// Strongly typed collection of Server.Engines.Reports.PersistableObject.
/// </summary>
public class ObjectCollection : System.Collections.CollectionBase
{
/// <summary>
/// Default constructor.
/// </summary>
public ObjectCollection()
: base()
{
}
/// <summary>
/// Gets or sets the value of the Server.Engines.Reports.PersistableObject at a specific position in the ObjectCollection.
/// </summary>
public Server.Engines.Reports.PersistableObject this[int index]
{
get
{
return ((Server.Engines.Reports.PersistableObject)(this.List[index]));
}
set
{
this.List[index] = value;
}
}
/// <summary>
/// Append a Server.Engines.Reports.PersistableObject entry to this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.PersistableObject instance.</param>
/// <returns>The position into which the new element was inserted.</returns>
public int Add(Server.Engines.Reports.PersistableObject value)
{
return this.List.Add(value);
}
public void AddRange(PersistableObject[] col)
{
this.InnerList.AddRange(col);
}
/// <summary>
/// Determines whether a specified Server.Engines.Reports.PersistableObject instance is in this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.PersistableObject instance to search for.</param>
/// <returns>True if the Server.Engines.Reports.PersistableObject instance is in the collection; otherwise false.</returns>
public bool Contains(Server.Engines.Reports.PersistableObject value)
{
return this.List.Contains(value);
}
/// <summary>
/// Retrieve the index a specified Server.Engines.Reports.PersistableObject instance is in this collection.
/// </summary>
/// <param name="value">Server.Engines.Reports.PersistableObject instance to find.</param>
/// <returns>The zero-based index of the specified Server.Engines.Reports.PersistableObject instance. If the object is not found, the return value is -1.</returns>
public int IndexOf(Server.Engines.Reports.PersistableObject value)
{
return this.List.IndexOf(value);
}
/// <summary>
/// Removes a specified Server.Engines.Reports.PersistableObject instance from this collection.
/// </summary>
/// <param name="value">The Server.Engines.Reports.PersistableObject instance to remove.</param>
public void Remove(Server.Engines.Reports.PersistableObject value)
{
this.List.Remove(value);
}
/// <summary>
/// Returns an enumerator that can iterate through the Server.Engines.Reports.PersistableObject instance.
/// </summary>
/// <returns>An Server.Engines.Reports.PersistableObject's enumerator.</returns>
public new ObjectCollectionEnumerator GetEnumerator()
{
return new ObjectCollectionEnumerator(this);
}
/// <summary>
/// Insert a Server.Engines.Reports.PersistableObject instance into this collection at a specified index.
/// </summary>
/// <param name="index">Zero-based index.</param>
/// <param name="value">The Server.Engines.Reports.PersistableObject instance to insert.</param>
public void Insert(int index, Server.Engines.Reports.PersistableObject value)
{
this.List.Insert(index, value);
}
/// <summary>
/// Strongly typed enumerator of Server.Engines.Reports.PersistableObject.
/// </summary>
public class ObjectCollectionEnumerator : System.Collections.IEnumerator
{
/// <summary>
/// Collection to enumerate.
/// </summary>
private readonly ObjectCollection _collection;
/// <summary>
/// Current index
/// </summary>
private int _index;
/// <summary>
/// Current element pointed to.
/// </summary>
private Server.Engines.Reports.PersistableObject _currentElement;
/// <summary>
/// Default constructor for enumerator.
/// </summary>
/// <param name="collection">Instance of the collection to enumerate.</param>
internal ObjectCollectionEnumerator(ObjectCollection collection)
{
this._index = -1;
this._collection = collection;
}
/// <summary>
/// Gets the Server.Engines.Reports.PersistableObject object in the enumerated ObjectCollection currently indexed by this instance.
/// </summary>
public Server.Engines.Reports.PersistableObject Current
{
get
{
if (((this._index == -1) ||
(this._index >= this._collection.Count)))
{
throw new System.IndexOutOfRangeException("Enumerator not started.");
}
else
{
return this._currentElement;
}
}
}
/// <summary>
/// Gets the current element in the collection.
/// </summary>
object IEnumerator.Current
{
get
{
if (((this._index == -1) ||
(this._index >= this._collection.Count)))
{
throw new System.IndexOutOfRangeException("Enumerator not started.");
}
else
{
return this._currentElement;
}
}
}
/// <summary>
/// Reset the cursor, so it points to the beginning of the enumerator.
/// </summary>
public void Reset()
{
this._index = -1;
this._currentElement = null;
}
/// <summary>
/// Advances the enumerator to the next queue of the enumeration, if one is currently available.
/// </summary>
/// <returns>true, if the enumerator was succesfully advanced to the next queue; false, if the enumerator has reached the end of the enumeration.</returns>
public bool MoveNext()
{
if ((this._index <
(this._collection.Count - 1)))
{
this._index = (this._index + 1);
this._currentElement = this._collection[this._index];
return true;
}
this._index = this._collection.Count;
return false;
}
}
}
}

View File

@@ -0,0 +1,68 @@
using System;
using System.Collections;
namespace Server.Engines.Reports
{
public delegate PersistableObject ConstructCallback();
public sealed class PersistableTypeRegistry
{
private static Hashtable m_Table;
static PersistableTypeRegistry()
{
m_Table = new Hashtable(StringComparer.OrdinalIgnoreCase);
Register(Report.ThisTypeID);
Register(BarGraph.ThisTypeID);
Register(PieChart.ThisTypeID);
Register(Snapshot.ThisTypeID);
Register(ItemValue.ThisTypeID);
Register(ChartItem.ThisTypeID);
Register(ReportItem.ThisTypeID);
Register(ReportColumn.ThisTypeID);
Register(SnapshotHistory.ThisTypeID);
Register(PageInfo.ThisTypeID);
Register(QueueStatus.ThisTypeID);
Register(StaffHistory.ThisTypeID);
Register(ResponseInfo.ThisTypeID);
}
public static PersistableType Find(string name)
{
return m_Table[name] as PersistableType;
}
public static void Register(PersistableType type)
{
if (type != null)
m_Table[type.Name] = type;
}
}
public sealed class PersistableType
{
private readonly string m_Name;
private readonly ConstructCallback m_Constructor;
public PersistableType(string name, ConstructCallback constructor)
{
this.m_Name = name;
this.m_Constructor = constructor;
}
public string Name
{
get
{
return this.m_Name;
}
}
public ConstructCallback Constructor
{
get
{
return this.m_Constructor;
}
}
}
}

View File

@@ -0,0 +1,124 @@
using System;
using System.IO;
using System.Xml;
namespace Server.Engines.Reports
{
public abstract class PersistenceReader
{
public PersistenceReader()
{
}
public abstract bool HasChild { get; }
public abstract int GetInt32(string key);
public abstract bool GetBoolean(string key);
public abstract string GetString(string key);
public abstract DateTime GetDateTime(string key);
public abstract bool BeginChildren();
public abstract void FinishChildren();
public abstract PersistableObject GetChild();
public abstract void ReadDocument(PersistableObject root);
public abstract void Close();
}
public class XmlPersistenceReader : PersistenceReader
{
private readonly StreamReader m_Reader;
private readonly XmlTextReader m_Xml;
private readonly string m_Title;
private bool m_HasChild;
private bool m_WasEmptyElement;
public XmlPersistenceReader(string filePath, string title)
{
this.m_Reader = new StreamReader(filePath);
this.m_Xml = new XmlTextReader(this.m_Reader);
this.m_Xml.WhitespaceHandling = WhitespaceHandling.None;
this.m_Title = title;
}
public override bool HasChild
{
get
{
return this.m_HasChild;
}
}
public override int GetInt32(string key)
{
return XmlConvert.ToInt32(this.m_Xml.GetAttribute(key));
}
public override bool GetBoolean(string key)
{
return XmlConvert.ToBoolean(this.m_Xml.GetAttribute(key));
}
public override string GetString(string key)
{
return this.m_Xml.GetAttribute(key);
}
public override DateTime GetDateTime(string key)
{
string val = this.m_Xml.GetAttribute(key);
if (val == null)
return DateTime.MinValue;
return XmlConvert.ToDateTime(val, XmlDateTimeSerializationMode.Utc);
}
public override bool BeginChildren()
{
this.m_HasChild = !this.m_WasEmptyElement;
this.m_Xml.Read();
return this.m_HasChild;
}
public override void FinishChildren()
{
this.m_Xml.Read();
}
public override PersistableObject GetChild()
{
PersistableType type = PersistableTypeRegistry.Find(this.m_Xml.Name);
PersistableObject obj = type.Constructor();
this.m_WasEmptyElement = this.m_Xml.IsEmptyElement;
obj.Deserialize(this);
this.m_HasChild = (this.m_Xml.NodeType == XmlNodeType.Element);
return obj;
}
public override void ReadDocument(PersistableObject root)
{
Console.Write("Reports: {0}: Loading...", this.m_Title);
this.m_Xml.Read();
this.m_Xml.Read();
this.m_HasChild = !this.m_Xml.IsEmptyElement;
root.Deserialize(this);
Console.WriteLine("done");
}
public override void Close()
{
this.m_Xml.Close();
this.m_Reader.Close();
}
}
}

View File

@@ -0,0 +1,134 @@
using System;
using System.IO;
using System.Xml;
namespace Server.Engines.Reports
{
public abstract class PersistenceWriter
{
public PersistenceWriter()
{
}
public abstract void SetInt32(string key, int value);
public abstract void SetBoolean(string key, bool value);
public abstract void SetString(string key, string value);
public abstract void SetDateTime(string key, DateTime value);
public abstract void BeginObject(PersistableType typeID);
public abstract void BeginChildren();
public abstract void FinishChildren();
public abstract void FinishObject();
public abstract void WriteDocument(PersistableObject root);
public abstract void Close();
}
public sealed class XmlPersistenceWriter : PersistenceWriter
{
private readonly string m_RealFilePath;
private readonly string m_TempFilePath;
private readonly StreamWriter m_Writer;
private readonly XmlTextWriter m_Xml;
private readonly string m_Title;
public XmlPersistenceWriter(string filePath, string title)
{
this.m_RealFilePath = filePath;
this.m_TempFilePath = Path.ChangeExtension(filePath, ".tmp");
this.m_Writer = new StreamWriter(this.m_TempFilePath);
this.m_Xml = new XmlTextWriter(this.m_Writer);
this.m_Title = title;
}
public override void SetInt32(string key, int value)
{
this.m_Xml.WriteAttributeString(key, XmlConvert.ToString(value));
}
public override void SetBoolean(string key, bool value)
{
this.m_Xml.WriteAttributeString(key, XmlConvert.ToString(value));
}
public override void SetString(string key, string value)
{
if (value != null)
this.m_Xml.WriteAttributeString(key, value);
}
public override void SetDateTime(string key, DateTime value)
{
if (value != DateTime.MinValue)
this.m_Xml.WriteAttributeString(key, XmlConvert.ToString(value, XmlDateTimeSerializationMode.Utc));
}
public override void BeginObject(PersistableType typeID)
{
this.m_Xml.WriteStartElement(typeID.Name);
}
public override void BeginChildren()
{
}
public override void FinishChildren()
{
}
public override void FinishObject()
{
this.m_Xml.WriteEndElement();
}
public override void WriteDocument(PersistableObject root)
{
Console.WriteLine("Reports: {0}: Save started", this.m_Title);
this.m_Xml.Formatting = Formatting.Indented;
this.m_Xml.IndentChar = '\t';
this.m_Xml.Indentation = 1;
this.m_Xml.WriteStartDocument(true);
root.Serialize(this);
Console.WriteLine("Reports: {0}: Save complete", this.m_Title);
}
public override void Close()
{
this.m_Xml.Close();
this.m_Writer.Close();
try
{
string renamed = null;
if (File.Exists(this.m_RealFilePath))
{
renamed = Path.ChangeExtension(this.m_RealFilePath, ".rem");
File.Move(this.m_RealFilePath, renamed);
File.Move(this.m_TempFilePath, this.m_RealFilePath);
File.Delete(renamed);
}
else
{
File.Move(this.m_TempFilePath, this.m_RealFilePath);
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}