BlogEngine.NET Architecture and source Code Analysis series Part4:blog Global Settings

Source: Internet
Author: User
Tags time zones blogengine

Blogsettings

This is already the fourth part of this series, I used to read most of the article, I wrote to feel when the blogger is not easy ah, so we can review or read, we must respect the results of the work of Bo Master. Gossip less, in this article we will blogengine.net the global configuration of the analysis and discussion. About configuration This part of the individual take out to do an article is a bit far-fetched, but I always feel that this configuration is relatively independent, and blogengine.net design and implementation have a lot to refer to the place.

In an enterprise application system, it is necessary to configure some system global parameters, so how do we deal with these configurations?

Generally have the following three steps:

1. In the process of business module development, some variable parameters are extracted.

2. When all business modules are developed, these parameters are sorted and stored.

3. Develop the corresponding management functions, allowing users to set these parameters.

Believe that most developers are directly manipulating the data in the database, there may be some more perfect system will make a separate page for users to manage the use of the nature is directly related to the database, did not involve too much logic, more direct. However, this does not work on the BlogEngine.NET architecture model, we cannot modify the data in the BlogEngine.NET database and wish to be reflected in its operating system (unless the application is restarted). Because the BlogEngine.NET database only completes the data storage function, all the business logic is done by the object's state maintenance in the Blogengine.core layer (refer to my second article). One might wonder if it would be possible to further develop a dependency mechanism on a database table like the one in ASP.net, which I think needs to be seen in the blogengine.net.

So how does the global setting of blogengine.net actually achieve it?

After installing blogengine.net into the admin, we will see a lot of categories of configuration options, including themes, language culture, time zones, and so on. The logical processing of these configurations is done through a class in Blogengine.core, which is blogsettings. Blogsettings only complete the blogengine.net global configuration processing, for the later text of the widget's specific configuration is not done here, this is mainly for the purpose of configuring independent, so that the widget can be developed independently.

Blogsettings and the outside interaction diagram (this diagram uses the drawing program to make, everybody does not have to see it first):

  

In Blogsettings, in addition to the corresponding properties of various configuration items, there is a static changed event that notifies the external global configuration that a change has occurred, so that more extensions can be written. Blogsettings uses a single example pattern to implement (a good application of a design pattern and a global configuration with system uniqueness).

1/**//// <summary>
2/// Public event used to indicate in settings have been changed.
3/// </summary>
4public static event EventHandler<EventArgs> Changed;
5/**//// <summary>
6/// Private member to hold singleton instance.
7/// </summary>
8private static BlogSettings blogSettingsSingleton;
9
10Instance#region Instance
11/**//// <summary>
12/// Gets the singleton instance of the <see cref="BlogSettings"/> class.
13/// </summary>
14/// <value>A singleton instance of the <see cref="BlogSettings"/> class.</value>
15/// <remarks></remarks>
16public static BlogSettings Instance
17{
18  get
19  {
20    if (blogSettingsSingleton == null)
21    {
22      blogSettingsSingleton = new BlogSettings();
23    }
24    return blogSettingsSingleton;
25  }
26}
27#endregion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.