Imagine that I need a color palette for my Winforms application to have a consistent look.
What I did was create a static helper class and helper methods that I can call from anywhere in my code, and invoke what I need from the App.settings
file.
Here for example, I am getting the school name from the App.config
file, so I can sell this application to other schools with minimal changes on my part.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="schoolName" value="Uboldi"/>
</appSettings>
</configuration>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace Uboldi.Helpers
{
public static class CustomizationHelper
{
public static string GetSchoolName()
{
return ConfigurationManager.AppSettings["schoolName"];
}
}
}
Usage:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Uboldi.Helpers;
namespace Uboldi
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
LoadFormTitle();
}
private void LoadFormTitle()
{
var schoolName = CustomizationHelper.GetSchoolName();
this.Text = String.Format("Sistema {0} - Pagina Principal", schoolName);
}
}
}
Are there any glaring mistakes I'm making by choosing this type of architecture?