コード例 #1
0
        public void OptionSetBeanTest01()
        {
            LocalizedLabel lLabel = new LocalizedLabel("Option1", 1041);
            LocalizedLabel lLabel2 = new LocalizedLabel("Option2", LANG_CODE);

            PicklistAttributeMetadata meta = new PicklistAttributeMetadata();
            meta.OptionSet = new OptionSetMetadata()
            {
                Name = "optionSet",
                DisplayName = new Label("optiondisplay", LANG_CODE),
                Options =
                {
                     new OptionMetadata(new Label(lLabel, null), 1),
                     new OptionMetadata(new Label("Option2", LANG_CODE), 2),
                     new OptionMetadata(new Label(lLabel2, null), 3)
                }
            };

            OptionSetBean cls = new OptionSetBean(meta);

            Assert.True(cls.HasOptionSet());
            Assert.AreEqual("Option1", cls.GetValue(1), "ラベルあり");
            Assert.Null(cls.GetValue(2), "ラベルなし");
            Assert.AreEqual("Option2", cls.GetValue(3), "ラベルあり");
        }
コード例 #2
0
        public void OptionSetBeanTest04()
        {
            LocalizedLabel lLabel = new LocalizedLabel("Option1", 1041);

            StringAttributeMetadata meta = new StringAttributeMetadata();

            OptionSetBean cls = new OptionSetBean(meta);

            Assert.False(cls.HasOptionSet());
        }
コード例 #3
0
        public void OptionSetBeanTest03()
        {
            LocalizedLabel lLabel = new LocalizedLabel("Option1", 1041);

            StatusAttributeMetadata meta = new StatusAttributeMetadata();
            meta.OptionSet = new OptionSetMetadata()
            {
                Name = "optionSet",
                DisplayName = new Label("optiondisplay", LANG_CODE),
                Options =
                {
                     new OptionMetadata(new Label(lLabel, null), 1)
                }
            };

            OptionSetBean cls = new OptionSetBean(meta);

            Assert.True(cls.HasOptionSet());
            Assert.AreEqual("Option1", cls.GetValue(1), "ラベルあり");
        }
コード例 #4
0
        /// <summary>
        /// 選択リストの表示値を取得する
        /// </summary>
        /// <param name="attributes"></param>
        public void SetOptionSetData(AttributeMetadata[] attributes)
        {
            _optionSetMap = new Dictionary<string, OptionSetBean>();

            foreach (AttributeMetadata attr in attributes)
            {
                // 表示用にオプションセットのマップを保持しておく
                OptionSetBean bean = new OptionSetBean(attr);

                if (bean.HasOptionSet())
                {
                    _optionSetMap.Add(attr.LogicalName, bean);
                }
            }
        }