#W# Source and Scripts added. Added Scripts/Settings.cs to expose some basic tweak able settings.
This commit is contained in:
parent
b51c58f514
commit
3045c83799
3512 changed files with 627673 additions and 0 deletions
57
Scripts/Misc/ValidationQueue.cs
Normal file
57
Scripts/Misc/ValidationQueue.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Server;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public delegate void ValidationEventHandler();
|
||||
|
||||
public static class ValidationQueue
|
||||
{
|
||||
public static event ValidationEventHandler StartValidation;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if ( StartValidation != null )
|
||||
StartValidation();
|
||||
|
||||
StartValidation = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValidationQueue<T>
|
||||
{
|
||||
private static List<T> m_Queue;
|
||||
|
||||
static ValidationQueue()
|
||||
{
|
||||
m_Queue = new List<T>();
|
||||
ValidationQueue.StartValidation += new ValidationEventHandler( ValidateAll );
|
||||
}
|
||||
|
||||
public static void Add( T obj )
|
||||
{
|
||||
m_Queue.Add( obj );
|
||||
}
|
||||
|
||||
private static void ValidateAll()
|
||||
{
|
||||
Type type = typeof( T );
|
||||
|
||||
if ( type != null )
|
||||
{
|
||||
MethodInfo m = type.GetMethod( "Validate", BindingFlags.Instance | BindingFlags.Public );
|
||||
|
||||
if ( m != null )
|
||||
{
|
||||
for ( int i = 0; i < m_Queue.Count; ++i )
|
||||
m.Invoke( m_Queue[i], null );
|
||||
}
|
||||
}
|
||||
|
||||
m_Queue.Clear();
|
||||
m_Queue = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue