コード例 #1
0
ファイル: CalendarInfo.cs プロジェクト: panost/ecl.Unicode
        public string GetDayPeriod(string type, LocaleFieldSize width,
                                   LocaleFieldType compose = LocaleFieldType.Default)
        {
            LdmlNode dayPeriods = this.Select("dayPeriods");

            var node = dayPeriods.Select(new NodePathEntry("dayPeriodContext", compose.ToCode()));

            NodePathEntry[] path =
            {
                new NodePathEntry("dayPeriodWidth", width.ToCode()),
                new NodePathEntry("dayPeriod",      type)
            };
            foreach (int w in XUtil.GetClosest((int)width, (int)LocaleFieldSize.Wide))
            {
                path[0].Attributes[0].Value = ((LocaleFieldSize)w).ToCode();

                var rNode = node.Select(path);
                if (rNode != null)
                {
                    return(rNode.Value);
                }
            }
            //if ( compose == EntryCompose.StandAlone ) {
            //    return GetDayPeriod( type, width );
            //}
            return(null);
        }
コード例 #2
0
ファイル: CalendarInfo.cs プロジェクト: panost/ecl.Unicode
        public string[] GetDays(LocaleFieldSize width, LocaleFieldType compose = LocaleFieldType.Default)
        {
            var path = new[] {
                new NodePathEntry("days"),
                new NodePathEntry("dayContext", compose.ToCode())
            };
            var      ctx   = this.Select(path);
            LdmlNode found = null;

            if (ctx != null)
            {
                foreach (int i in XUtil.GetClosest((int)width, (int)LocaleFieldSize.Wide))
                {
                    found = ctx.Select("dayWidth", ((LocaleFieldSize)i).ToCode(), LdmlAttribute.Type);
                    if (found != null)
                    {
                        break;
                    }
                }
            }
            if (found == null && compose == LocaleFieldType.StandAlone)
            {
                path[1].Attributes[0].Value = LocaleFieldType.Default.ToCode();
                ctx = this.Select(path);
                if (ctx != null)
                {
                    foreach (int i in XUtil.GetClosest((int)width, (int)LocaleFieldSize.Wide))
                    {
                        found = ctx.Select("dayWidth", ((LocaleFieldSize)i).ToCode(), LdmlAttribute.Type);
                        if (found != null)
                        {
                            break;
                        }
                    }
                }
            }
            if (found == null)
            {
                return(null);
            }

            return(found.GetList("day", GetDayIndex));
        }