Beispiel #1
0
 private static void LoadUnit( FormatLength size, LdmlNode root,
     Dictionary<CldrUnit, UnitOfMeasure> map, FormatSizeEntry compoundUnitPattern)
 {
     foreach ( LdmlNode node in root.Children ) {
         switch ( node.Name ) {
         case "compoundUnit":
             foreach ( LdmlNode child in node.Children ) {
                 if ( child.Name == "compoundUnitPattern" ) {
                     compoundUnitPattern[size] = child.Value;
                     break;
                 }
             }
             break;
         case "unit":
             LdmlTypeUnitNode unitNode = node as LdmlTypeUnitNode;
             if ( unitNode != null ) {
                 UnitOfMeasure measure;
                 if ( !map.TryGetValue( unitNode.Unit, out measure ) ) {
                     measure = new UnitOfMeasure( unitNode.Unit );
                     map.Add( unitNode.Unit, measure );
                 }
                 measure.Load( size, unitNode );
             }
             break;
         }
     }
 }
Beispiel #2
0
        public FormatSizeEntry GetDateTimeFormat()
        {
            LdmlNode        node  = this.Select("dateTimeFormats");
            FormatSizeEntry entry = new FormatSizeEntry();

            entry.LoadEntries(node, "dateTimeFormatLength", "dateTimeFormat", "pattern");
            return(entry);
        }
Beispiel #3
0
        private Dictionary<CldrUnit, UnitOfMeasure> LoadUnits()
        {
            LdmlNode root = ResolveRootNode( "units" );
            if ( root.Document != this ) {
                _unitPatternPer = ((CldrLocale)root.Document).UnitPatternPer;
                return ((CldrLocale)root.Document).Units;
            }
            _unitPatternPer = new FormatSizeEntry();

            var map = new Dictionary<CldrUnit, UnitOfMeasure>();
            foreach ( LdmlNode child in root.Children ) {
                LdmlTypeLengthNode lnode = child as LdmlTypeLengthNode;
                if ( lnode != null && lnode.Name == "unitLength" ) {
                    LoadUnit( lnode.Length, lnode, map, _unitPatternPer );
                }
            }
            return map;
        }