示例#1
0
        public static int GetEnumItemNumber(IMgaFCO IMgaFCO, string attributeName)
        {
            Contract.Requires(IMgaFCO != null);
            Contract.Requires(IMgaFCO.MetaBase is MgaMetaFCO);
            Contract.Requires(string.IsNullOrEmpty(attributeName) == false);

            try
            {
                MgaMetaFCO       meta = (IMgaFCO.MetaBase as MgaMetaFCO);
                MgaMetaAttribute attr = meta.AttributeByName[attributeName];

                string selectedItemValue = IMgaFCO.Attribute[attr].StringValue;
                int    i = 0;
                foreach (MgaMetaEnumItem item in attr.EnumItems)
                {
                    if (item.Value == selectedItemValue)
                    {
                        return(i);
                    }
                    i++;
                }
                throw new Exception("Attribute / selected item was not found.");
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#2
0
        public static void SetEnumItem(IMgaFCO IMgaFCO, string attributeName, int index)
        {
            Contract.Requires(IMgaFCO != null);
            Contract.Requires(IMgaFCO.MetaBase is MgaMetaFCO);
            Contract.Requires(string.IsNullOrEmpty(attributeName) == false);

            try
            {
                MgaMetaFCO       meta = (IMgaFCO.MetaBase as MgaMetaFCO);
                MgaMetaAttribute attr = meta.AttributeByName[attributeName];

                IMgaFCO.Attribute[attr].StringValue = attr.EnumItems[index + 1].Value;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }