generic conversions

This commit is contained in:
Mark Sturgill 2013-11-02 21:40:42 -07:00
parent fa1df8eae5
commit 0eeb0c0c31
6 changed files with 29 additions and 25 deletions

View file

@ -1,5 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace Server.Items
{
@ -480,7 +480,7 @@ namespace Server.Items
return ( resource == CraftResource.None || resource == CraftResource.Iron || resource == CraftResource.RegularLeather || resource == CraftResource.RegularWood );
}
private static Hashtable m_TypeTable;
private static Dictionary<Type, CraftResource> m_TypeTable;
/// <summary>
/// Registers that '<paramref name="resourceType"/>' uses '<paramref name="resource"/>' so that it can later be queried by <see cref="CraftResources.GetFromType"/>
@ -488,7 +488,7 @@ namespace Server.Items
public static void RegisterType( Type resourceType, CraftResource resource )
{
if ( m_TypeTable == null )
m_TypeTable = new Hashtable();
m_TypeTable = new Dictionary<Type, CraftResource>();
m_TypeTable[resourceType] = resource;
}
@ -501,12 +501,12 @@ namespace Server.Items
if ( m_TypeTable == null )
return CraftResource.None;
object obj = m_TypeTable[resourceType];
if ( !(obj is CraftResource) )
CraftResource res;
if (!m_TypeTable.TryGetValue(resourceType, out res))
return CraftResource.None;
return (CraftResource)obj;
return res;
}
/// <summary>