/// <summary> /// Adds a table to lookup, using the table's name as its id. /// </summary> public CustomVariantResolver SetTable(VariantTable inTable) { if (inTable == null) { throw new ArgumentNullException("inTable"); } return(SetTable(inTable.Name, inTable)); }
/// <summary> /// Sets the table associated with the given table id. /// </summary> public CustomVariantResolver SetTable(StringHash32 inTableId, VariantTable inTable) { if (inTable == null) { throw new ArgumentNullException("inTable"); } MakeTableRule(inTableId).SetConst(inTable); return(this); }
/// <summary> /// Overwrites another table with this table's values. /// </summary> public void CopyTo(IVariantTable inTarget) { VariantTable validTarget = inTarget as VariantTable; if (validTarget == null) { throw new ArgumentException("Invalid copy target", "inTarget"); } m_Values.CopyTo(validTarget.m_Values); validTarget.m_Optimized = m_Optimized; }
private bool InternalTryGetTable(object inContext, StringHash32 inTableId, out VariantTable outTable, bool inbCheckBase) { if (inTableId.IsEmpty) { if (m_DefaultTable != null && m_DefaultTable.IsActive()) { outTable = m_DefaultTable.Resolve(inContext); return(true); } } else { if (m_TableLookup != null) { TableRule tableRule; if (m_TableLookup.TryGetValue(inTableId, out tableRule)) { outTable = tableRule.Resolve(inContext); return(true); } } if (m_GetTableWithContextFallback != null) { outTable = m_GetTableWithContextFallback(inTableId, inContext); if (outTable != null) { return(true); } } if (m_GetTableFallback != null) { outTable = m_GetTableFallback(inTableId); if (outTable != null) { return(true); } } } if (inbCheckBase) { if (m_Base != null) { return(m_Base.TryGetTable(inContext, inTableId, out outTable)); } } outTable = null; return(false); }
/// <summary> /// Sets the default table if no table id is provided. /// </summary> public CustomVariantResolver SetDefaultTable(VariantTable inTable) { if (inTable == null) { throw new ArgumentNullException("inTable"); } if (m_DefaultTable == null) { m_DefaultTable = new TableRule(); } m_DefaultTable.SetConst(inTable); return(this); }
public VariantTable(StringHash32 inName, VariantTable inBase) : this(inName) { m_Base = inBase; }
public bool TryGetTable(object inContext, StringHash32 inTableId, out VariantTable outTable) { return(InternalTryGetTable(inContext, inTableId, out outTable, true)); }
public void SetDelegate(GetTableWithContextDelegate inDelegate) { m_Table = null; m_TableDelegate = null; m_TableWithContextDelegate = inDelegate; }
public void SetConst(VariantTable inTable) { m_Table = inTable; m_TableDelegate = null; m_TableWithContextDelegate = null; }
public void Clear() { m_Table = null; m_TableDelegate = null; m_TableWithContextDelegate = null; }