示例#1
0
        public virtual void CascadeRemove(MetadataField item)
        {
            Requires <InvalidKeyException> .GreaterThan(item.Id, 0);

            Log.Verbose("CascadeRemove({0})", item.ToString());
            //1==>X
            //1<==>X
            base.CascadeRemove(item);
        }
        /// <summary>
        /// Determine the text to be shown.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>
        /// The text
        /// </returns>
        protected override string GetText(WriterContext context)
        {
            DataElement data = context.CurrentDataElement;

            switch (MetadataField)
            {
            case MetadataField.Position:
                return((data.Position + 1).ToString(CultureInfo.InvariantCulture));

            default:
                throw new InvalidOperationException(MetadataField.ToString());
            }
        }
        public static string GetLabel(MetadataField metadataField)
        {
            MemberInfo memberInfo = typeof(MetadataField).GetMember(metadataField.ToString())
                                    .FirstOrDefault();

            if (memberInfo == null)
            {
                return(null);
            }

            DisplayAttribute attribute = (DisplayAttribute)
                                         memberInfo.GetCustomAttributes(typeof(DisplayAttribute), false)
                                         .Single();

            return(attribute.Name);
        }