Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -4,139 +4,131 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Server.Commands.Generic
|
||||
{
|
||||
public delegate BaseExtension ExtensionConstructor();
|
||||
public delegate BaseExtension ExtensionConstructor();
|
||||
|
||||
public sealed class ExtensionInfo
|
||||
{
|
||||
public static Dictionary<string, ExtensionInfo> Table { get; } = new Dictionary<string, ExtensionInfo>( StringComparer.InvariantCultureIgnoreCase );
|
||||
public sealed class ExtensionInfo
|
||||
{
|
||||
public ExtensionInfo(int order, string name, int size, ExtensionConstructor constructor)
|
||||
{
|
||||
Name = name;
|
||||
Size = size;
|
||||
|
||||
public static void Register( ExtensionInfo ext )
|
||||
{
|
||||
Table[ext.Name] = ext;
|
||||
}
|
||||
Order = order;
|
||||
|
||||
public int Order { get; }
|
||||
Constructor = constructor;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
public static Dictionary<string, ExtensionInfo> Table{ get; } =
|
||||
new Dictionary<string, ExtensionInfo>(StringComparer.InvariantCultureIgnoreCase);
|
||||
|
||||
public int Size { get; }
|
||||
public int Order{ get; }
|
||||
|
||||
public bool IsFixedSize => ( Size >= 0 );
|
||||
public string Name{ get; }
|
||||
|
||||
public ExtensionConstructor Constructor { get; }
|
||||
public int Size{ get; }
|
||||
|
||||
public ExtensionInfo( int order, string name, int size, ExtensionConstructor constructor )
|
||||
{
|
||||
Name = name;
|
||||
Size = size;
|
||||
public bool IsFixedSize => Size >= 0;
|
||||
|
||||
Order = order;
|
||||
public ExtensionConstructor Constructor{ get; }
|
||||
|
||||
Constructor = constructor;
|
||||
}
|
||||
}
|
||||
public static void Register(ExtensionInfo ext)
|
||||
{
|
||||
Table[ext.Name] = ext;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class Extensions : List<BaseExtension>
|
||||
{
|
||||
public Extensions()
|
||||
{
|
||||
}
|
||||
public sealed class Extensions : List<BaseExtension>
|
||||
{
|
||||
public bool IsValid(object obj)
|
||||
{
|
||||
for (int i = 0; i < Count; ++i)
|
||||
if (!this[i].IsValid(obj))
|
||||
return false;
|
||||
|
||||
public bool IsValid( object obj )
|
||||
{
|
||||
for ( int i = 0; i < Count; ++i )
|
||||
{
|
||||
if ( !this[i].IsValid( obj ) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public void Filter(ArrayList list)
|
||||
{
|
||||
for (int i = 0; i < Count; ++i)
|
||||
this[i].Filter(list);
|
||||
}
|
||||
|
||||
public void Filter( ArrayList list )
|
||||
{
|
||||
for ( int i = 0; i < Count; ++i )
|
||||
this[i].Filter( list );
|
||||
}
|
||||
public static Extensions Parse(Mobile from, ref string[] args)
|
||||
{
|
||||
Extensions parsed = new Extensions();
|
||||
|
||||
public static Extensions Parse( Mobile from, ref string[] args )
|
||||
{
|
||||
Extensions parsed = new Extensions();
|
||||
int size = args.Length;
|
||||
|
||||
int size = args.Length;
|
||||
Type baseType = null;
|
||||
|
||||
Type baseType = null;
|
||||
for (int i = args.Length - 1; i >= 0; --i)
|
||||
{
|
||||
if (!ExtensionInfo.Table.TryGetValue(args[i], out ExtensionInfo extInfo))
|
||||
continue;
|
||||
|
||||
for ( int i = args.Length - 1; i >= 0; --i )
|
||||
{
|
||||
if ( !ExtensionInfo.Table.TryGetValue( args[i], out ExtensionInfo extInfo ) )
|
||||
continue;
|
||||
if (extInfo.IsFixedSize && i != size - extInfo.Size - 1)
|
||||
throw new Exception("Invalid extended argument count.");
|
||||
|
||||
if ( extInfo.IsFixedSize && i != ( size - extInfo.Size - 1 ) )
|
||||
throw new Exception( "Invalid extended argument count." );
|
||||
BaseExtension ext = extInfo.Constructor();
|
||||
|
||||
BaseExtension ext = extInfo.Constructor();
|
||||
ext.Parse(from, args, i + 1, size - i - 1);
|
||||
|
||||
ext.Parse( from, args, i + 1, size - i - 1 );
|
||||
if (ext is WhereExtension extension)
|
||||
baseType = extension.Conditional.Type;
|
||||
|
||||
if ( ext is WhereExtension extension )
|
||||
baseType = extension.Conditional.Type;
|
||||
parsed.Add(ext);
|
||||
|
||||
parsed.Add( ext );
|
||||
size = i;
|
||||
}
|
||||
|
||||
size = i;
|
||||
}
|
||||
parsed.Sort(delegate(BaseExtension a, BaseExtension b) { return a.Order - b.Order; });
|
||||
|
||||
parsed.Sort( delegate( BaseExtension a, BaseExtension b )
|
||||
{
|
||||
return ( a.Order - b.Order );
|
||||
} );
|
||||
AssemblyEmitter emitter = null;
|
||||
|
||||
AssemblyEmitter emitter = null;
|
||||
foreach (BaseExtension update in parsed)
|
||||
update.Optimize(from, baseType, ref emitter);
|
||||
|
||||
foreach ( BaseExtension update in parsed )
|
||||
update.Optimize( from, baseType, ref emitter );
|
||||
if (size != args.Length)
|
||||
{
|
||||
string[] old = args;
|
||||
args = new string[size];
|
||||
|
||||
if ( size != args.Length )
|
||||
{
|
||||
string[] old = args;
|
||||
args = new string[size];
|
||||
for (int i = 0; i < args.Length; ++i)
|
||||
args[i] = old[i];
|
||||
}
|
||||
|
||||
for ( int i = 0; i < args.Length; ++i )
|
||||
args[i] = old[i];
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
public abstract class BaseExtension
|
||||
{
|
||||
public abstract ExtensionInfo Info{ get; }
|
||||
|
||||
public abstract class BaseExtension
|
||||
{
|
||||
public abstract ExtensionInfo Info { get; }
|
||||
public string Name => Info.Name;
|
||||
|
||||
public string Name => Info.Name;
|
||||
public int Size => Info.Size;
|
||||
|
||||
public int Size => Info.Size;
|
||||
public bool IsFixedSize => Info.IsFixedSize;
|
||||
|
||||
public bool IsFixedSize => Info.IsFixedSize;
|
||||
public int Order => Info.Order;
|
||||
|
||||
public int Order => Info.Order;
|
||||
public virtual void Optimize(Mobile from, Type baseType, ref AssemblyEmitter assembly)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Optimize( Mobile from, Type baseType, ref AssemblyEmitter assembly )
|
||||
{
|
||||
}
|
||||
public virtual void Parse(Mobile from, string[] arguments, int offset, int size)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Parse( Mobile from, string[] arguments, int offset, int size )
|
||||
{
|
||||
}
|
||||
public virtual bool IsValid(object obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool IsValid( object obj )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Filter( ArrayList list )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
public virtual void Filter(ArrayList list)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue