/// ------------------------------------------------------------------------------------ /// <summary> /// Gets an enumeration associated with the given General Category /// </summary> /// <param name="ucdRepresentation">The UCD general category e.g. "Lu" or "Nd" /// see: http://www.unicode.org/Public/UNIDATA/UCD.html#General_Category_Values</param> /// <param name="ucdCategory">The category that this enumeration represents, /// e.g. "generalCategory"</param> /// <returns> /// The UcdEnumeration that matches the ucdRepresentation, or null. /// Returns the only instance that matches the requested value. /// Thus two calls will get the same instance. /// </returns> /// ------------------------------------------------------------------------------------ public static UcdProperty GetInstance(string ucdRepresentation, UcdCategories ucdCategory) { InitializeHashTables(); if (ucdCategory != UcdCategories.dontParse) { Dictionary <int, UcdProperty> propertyHash = s_ucdPropertyDict[ucdCategory]; foreach (UcdProperty ucdEnum in propertyHash.Values) { if (ucdEnum.m_ucdRepresentation == ucdRepresentation) { return(ucdEnum); } } } else { // TODO: do we really want to add-non existant values? return(new UcdProperty(ucdRepresentation, UcdCategories.dontParse)); } // Special case: blank is the same as none for decompostion type if (ucdCategory == UcdCategories.compatabilityDecompositionType && ucdRepresentation == "") { return(GetInstance(Icu.UDecompositionType.U_DT_NONE)); } // If the specified a UcdProptery, but none was found, fall through to this error throw new ArgumentException("The specified UcdProperty does not exist. " + ucdCategory.ToString() + ":" + ucdRepresentation, "ucdProperty"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This constructor creates a single enumerated value that contains human readable descriptions /// </summary> /// <param name="ucdRepresentation">The ucd representation.</param> /// <param name="ucdProperty">The ucd property.</param> /// ------------------------------------------------------------------------------------ private UcdProperty(string ucdRepresentation, UcdCategories ucdProperty) { // Read the human readable value from the resource file. switch (ucdProperty) { case UcdCategories.generalCategory: this.m_description = UcdCharacterResources.ResourceManager.GetString("kstidGenCat" + ucdRepresentation); break; case UcdCategories.canonicalCombiningClass: this.m_description = UcdCharacterResources.ResourceManager.GetString("kstidCanComb" + ucdRepresentation); break; case UcdCategories.bidiClass: this.m_description = UcdCharacterResources.ResourceManager.GetString("kstidBidiClass" + ucdRepresentation); break; case UcdCategories.compatabilityDecompositionType: // Cut off the '<' and '>' if (ucdRepresentation[0] == '<' && ucdRepresentation[ucdRepresentation.Length - 1] == '>') { string clipTagChars = ucdRepresentation.Substring(1, ucdRepresentation.Length - 2); this.m_description = UcdCharacterResources.ResourceManager.GetString("kstidDecompCompat" + clipTagChars); } else { // This "ucdRepresentation" should not be written to UnicodeData this.m_displayInUnicodeData = false; this.m_description = UcdCharacterResources.ResourceManager.GetString("kstidDecompCompat" + ucdRepresentation); } break; case UcdCategories.numericType: // This "ucdRepresentation" should not be written to UnicodeData this.m_displayInUnicodeData = false; this.m_description = UcdCharacterResources.ResourceManager.GetString("kstidNumType" + ucdRepresentation); break; } this.m_ucdRepresentation = ucdRepresentation; this.m_ucdCategory = ucdProperty; }
/// ------------------------------------------------------------------------------------ /// <summary> /// This constructor creates a single enumerated value that contains human readable descriptions /// </summary> /// <param name="ucdRepresentation">The ucd representation.</param> /// <param name="ucdProperty">The ucd property.</param> /// ------------------------------------------------------------------------------------ private UcdProperty(string ucdRepresentation, UcdCategories ucdProperty) { // Read the human readable value from the resource file. switch (ucdProperty) { case UcdCategories.generalCategory: this.m_description = m_res.GetString("kstidGenCat" + ucdRepresentation); break; case UcdCategories.canonicalCombiningClass: this.m_description = m_res.GetString("kstidCanComb" + ucdRepresentation); break; case UcdCategories.bidiClass: this.m_description = m_res.GetString("kstidBidiClass" + ucdRepresentation); break; case UcdCategories.compatabilityDecompositionType: // Cut off the '<' and '>' if (ucdRepresentation[0] == '<' && ucdRepresentation[ucdRepresentation.Length - 1] == '>') { string clipTagChars = ucdRepresentation.Substring(1, ucdRepresentation.Length - 2); this.m_description = m_res.GetString("kstidDecompCompat" + clipTagChars); } else { // This "ucdRepresentation" should not be written to UnicodeData this.m_displayInUnicodeData = false; this.m_description = m_res.GetString("kstidDecompCompat" + ucdRepresentation); } break; case UcdCategories.numericType: // This "ucdRepresentation" should not be written to UnicodeData this.m_displayInUnicodeData = false; this.m_description = m_res.GetString("kstidNumType" + ucdRepresentation); break; } this.m_ucdRepresentation = ucdRepresentation; this.m_ucdCategory = ucdProperty; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets all of the possible UcdProperties of the given ucdCategory. /// </summary> /// <param name="ucdCategory">The ucd category.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static ICollection GetUCDProperty(UcdCategories ucdCategory) { InitializeHashTables(); return(s_ucdPropertyDict[ucdCategory].Values); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets all of the possible UcdProperties of the given ucdCategory. /// </summary> /// <param name="ucdCategory">The ucd category.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static ICollection GetUCDProperty(UcdCategories ucdCategory) { InitializeHashTables(); return s_ucdPropertyDict[ucdCategory].Values; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets an enumeration associated with the given General Category /// </summary> /// <param name="ucdRepresentation">The UCD general category e.g. "Lu" or "Nd" /// see: http://www.unicode.org/Public/UNIDATA/UCD.html#General_Category_Values</param> /// <param name="ucdCategory">The category that this enumeration represents, /// e.g. "generalCategory"</param> /// <returns> /// The UcdEnumeration that matches the ucdRepresentation, or null. /// Returns the only instance that matches the requested value. /// Thus two calls will get the same instance. /// </returns> /// ------------------------------------------------------------------------------------ public static UcdProperty GetInstance(string ucdRepresentation, UcdCategories ucdCategory) { InitializeHashTables(); if (ucdCategory != UcdCategories.dontParse) { Dictionary<int, UcdProperty> propertyHash = s_ucdPropertyDict[ucdCategory]; foreach (UcdProperty ucdEnum in propertyHash.Values) { if (ucdEnum.m_ucdRepresentation == ucdRepresentation) { return ucdEnum; } } } else { // TODO: do we really want to add-non existant values? return new UcdProperty(ucdRepresentation, UcdCategories.dontParse); } // Special case: blank is the same as none for decompostion type if (ucdCategory == UcdCategories.compatabilityDecompositionType && ucdRepresentation == "") { return GetInstance(Icu.UDecompositionType.U_DT_NONE); } // If the specified a UcdProptery, but none was found, fall through to this error throw new ArgumentException("The specified UcdProperty does not exist. " + ucdCategory.ToString() + ":" + ucdRepresentation, "ucdProperty"); }