Click here to Skip to main content
15,885,933 members
Articles / Programming Languages / C#

Customize an application with XML fragments

Rate me:
Please Sign up or sign in to vote.
1.44/5 (3 votes)
22 May 20073 min read 28.2K   124   10  
How to customize an application using XML fragments
using System;
using System.Collections.Generic;
using System.Text;
using Bulasoft.Common.Elements;
using System.Reflection;

namespace Bulasoft.Common.Serialization
{
    public class Logger : List<LoggerEntry>
    {
        public LoggerEntry LogError(IElement element, string message, params string[] param)
        {
            return AddEntry(LoggerEntryKind.Error, element, null, message, param);
        }

        public LoggerEntry LogWarning(IElement element, string message, params string[] param)
        {
            return AddEntry(LoggerEntryKind.Warning, element, null, message, param);
        }

        public LoggerEntry LogError(IElement element, PropertyInfo property, string message, params string[] param)
        {
            return AddEntry(LoggerEntryKind.Error, element, property, message, param);
        }

        public LoggerEntry AddEntry(LoggerEntryKind entryKind, IElement element, PropertyInfo property, string message, params string[] param)
        {
            LoggerEntry entry = new LoggerEntry();

            entry.element = element;
            entry.Kind = entryKind;
            entry.property = property;
            if (param.Length == 0)
                entry.Message = message;
            else
                entry.Message = string.Format(message, param);
            Add(entry);

            return entry;
        }
    }
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions