public static int GetId(string name, int defaultId) { int id = 0; if (!MapNameToId.TryGetValue(name, out id)) { return(defaultId); } return(id); }
/// <summary> /// Connects a property type with a name that can be read by humans. Returns false if the property ID is already registered. /// </summary> /// <returns>false if the property ID is already registered</returns> public static bool AddMapping(int propertyId, string propertyName) { if (MapNameToId.ContainsKey(propertyName)) { // name already registered return(false); } if (m_MapIdToName.ContainsKey(propertyId)) { // id already registered return(false); } m_MapIdToName.Add(propertyId, propertyName); m_MapNameToId.Add(propertyName, propertyId); return(true); }