Exemplo n.º 1
0
        public static int GetId(string name, int defaultId)
        {
            int id = 0;

            if (!MapNameToId.TryGetValue(name, out id))
            {
                return(defaultId);
            }

            return(id);
        }
Exemplo n.º 2
0
        /// <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);
        }