Example #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;
         }
     }
 }
Example #2
0
        //internal UnitOfMeasure( LocaleData locale, string name ) {
        //    WellKnownUnit unit;
        //    if ( XUtil.TryParseUnit( name, out unit ) ) {
        //        Unit = unit;
        //        Name = unit.ToCode();
        //    } else {
        //        Name = name;
        //    }
        //}

        //internal UnitSlot Load( FormatSize size, JObject root ) {
        //    int idx = GetIndex( size );
        //    if ( idx < 0 ) {
        //        return null;
        //    }
        //    UnitSlot slot = new UnitSlot( this, size );
        //    _sizes[ idx ] = slot;
        //    slot.Load( root );
        //    return slot;
        //}

        internal UnitSlot Load(FormatLength size, LdmlTypeUnitNode root)
        {
            int idx = GetIndex(size);

            if (idx < 0)
            {
                return(null);
            }
            UnitSlot slot = new UnitSlot(this, size);

            _sizes[idx] = slot;
            slot.Load(root);
            return(slot);
        }