Esempio n. 1
0
        public UcdCodeProperty GetCodeProperty(CodePointProperty property)
        {
            foreach (UcdCodeProperty p in CodeProperties)
            {
                if (p.Value == property)
                {
                    return(p);
                }
            }

            return(null);
        }
Esempio n. 2
0
        private void LoadProperties()
        {
            var all                      = new List <UcdRange <UcdCodeProperty> >();
            var map                      = new Dictionary <string, UcdCodeProperty>(StringComparer.OrdinalIgnoreCase);
            var list                     = new List <UcdCodeProperty>();
            var _codePropMap             = Util.GetPropertyMap();
            CodePointProperty _lastValue = (CodePointProperty)(Enum.GetValues(typeof(CodePointProperty)).Length + 1);

            foreach (var value in Enum.GetValues(typeof(CodePointProperty)))
            {
                Debug.WriteLine(value.ToString());
            }
            void ReadFile(string fileName, bool isDerived)
            {
                using (LineReader reader = OpenLineReader(fileName)) {
                    foreach (NamedRange range in GetNamedRanges(reader))
                    {
                        UcdCodeProperty prop;
                        if (!map.TryGetValue(range.Name, out prop))
                        {
                            CodePointProperty propVal;
                            if (!_codePropMap.TryGetValue(range.Name, out propVal))
                            {
                                propVal = _lastValue++;
                                _codePropMap.Add(range.Name, propVal);
                                //Debug.WriteLine( $"New Property {range.Name}:{(int)propVal} ({isDerived})" );
                            }
                            //var val = ParseCodeProperty( range.Name );
                            prop = new UcdCodeProperty(range.Name, propVal)
                            {
                                IsDerived = isDerived
                            };
                            map.Add(range.Name, prop);
                            list.Add(prop);
                        }
                        var propRange = new UcdRange <UcdCodeProperty>(range.Begin, range.End, prop);
                        prop.Ranges.Add(propRange);
                        all.Add(propRange);
                    }
                }
            }

            ReadFile("PropList.txt", false);
            ReadFile("DerivedCoreProperties.txt", true);
            _allProperties  = list.ToArray();
            _propertyRanges = all.ToArray();
            UcdRange.Sort(_propertyRanges);
        }
Esempio n. 3
0
 public static string GetCode(this CodePointProperty property)
 {
     return(_unicodeProperties[(int)property]);
 }