Click here to Skip to main content
15,886,362 members
Articles / Programming Languages / C#

Attribute-flavored Domain Driven Design

Rate me:
Please Sign up or sign in to vote.
4.00/5 (2 votes)
6 Apr 2008CPOL8 min read 39.1K   231   25  
A centralized business domain with a common base
using System;
using System.ComponentModel;
using System.Globalization;
using Codebasement.DomainDrivenDesign.Basement.Utilities;

namespace Codebasement.DomainDrivenDesign.Model.Converters
{
    /// <summary>
    /// The passwordstring converter can be used to mask the display of a password setting.
    /// </summary>
    public class PasswordStringConverter : StringConverter
    {
        /// <summary>
        /// This method is implemented to tell that the converter cannot convert from the given format.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="sourceType"></param>
        /// <returns>false</returns>
        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
        {
            return false;
        }


        /// <summary>
        /// This method returns a masked string that will be displayed in the design pane.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="culture"></param>
        /// <param name="value"></param>
        /// <param name="destinationType"></param>
        /// <returns>A string containing password-dots.</returns>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value,
                                         Type destinationType)
        {
            return String.Empty.PadLeft(((string) value).Length, RegexExpressions.PasswordChar);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Netherlands Netherlands
Software engineer & architect.

Comments and Discussions