Configuration Manager

namespace Core.Utility
{
   using System;
   using System.Collections.Specialized;
   using System.Configuration;

   /// <summary>
   /// Interface IApplicationConfiguration
   /// </summary>
   public interface IApplicationConfiguration
   {
      /// <summary>
      /// Gets the section.
      /// </summary>
      /// <param name="section">The section.</param>
      /// <returns>System.Object.</returns>
      object GetSection(string section);

      /// <summary>
      /// Gets the setting.
      /// </summary>
      /// <typeparam name="TValue">The type of the t value.</typeparam>
      /// <param name="key">The key.</param>
      /// <param name="defaultValue">The default value.</param>
      /// <returns>TValue.</returns>
      TValue GetSetting<TValue>(string key, TValue defaultValue);

      /// <summary>
      /// Gets the setting.
      /// </summary>
      /// <typeparam name="TValue">The type of the t value.</typeparam>
      /// <param name="section">The section.</param>
      /// <param name="key">The key.</param>
      /// <param name="defaultValue">The default value.</param>
      /// <returns>TValue.</returns>
      TValue GetSetting<TValue>(string section, string key, TValue defaultValue);
   }

   /// <summary>
   /// Class ApplicationConfiguration.
   /// </summary>
   /// <seealso cref="IApplicationConfiguration" />
   public class ApplicationConfiguration : IApplicationConfiguration
   {
      /// <summary>
      /// Gets the setting specified setting from the application config
      /// </summary>
      /// <typeparam name="TValue">Type to convert the return value to</typeparam>
      /// <param name="key">The key to search for</param>
      /// <param name="defaultValue">The default value to be returned if the value does not exist</param>
      /// <returns>value converted to T</returns>
      public TValue GetSetting<TValue>(string key, TValue defaultValue)
      {
         var item = ConfigurationManager.AppSettings[key];
         return item == null ? defaultValue : (TValue)Convert.ChangeType(item, typeof(TValue));
      }

      /// <summary>
      /// Gets the setting specified setting from the application config
      /// </summary>
      /// <typeparam name="TValue">Type to convert the return value to</typeparam>
      /// <param name="section">The section to search for</param>
      /// <param name="key">The key to search for</param>
      /// <param name="defaultValue">The default value to be returned if the value does not exist</param>
      /// <returns>value converted to T</returns>
      public TValue GetSetting<TValue>(string section, string key, TValue defaultValue)
      {
         var item = ConfigurationManager.GetSection(section) as NameValueCollection;
         if (item != null)
         {
            var itemValue = item[key];
            return itemValue == null ? defaultValue : (TValue)Convert.ChangeType(itemValue, typeof(TValue));
         }

         return defaultValue;
      }

      /// <summary>
      /// Gets the section.
      /// </summary>
      /// <param name="section">The section.</param>
      /// <returns>An object</returns>
      public object GetSection(string section)
      {
         if (section == null)
         {
            return null;
         }

         object sectionObject;

         try
         {
            sectionObject = ConfigurationManager.GetSection(section);
         }
         catch (ConfigurationErrorsException)
         {
            sectionObject = null;
         }

         return sectionObject;
      }
   }
}

64 Comments

  1. Magnificent goods from you, man. I’ve keep in mind your stuff previous
    to and you are simply too great. I actually
    like what you’ve received right here, certainly like what you are stating and the best way
    wherein you are saying it. You’re making it enjoyable and you continue to take care of to keep it wise.
    I can’t wait to learn much more from you. This is really a terrific website.

  2. An impressive share! I have just forwarded this onto a colleague who has been doing a little research on this.
    And he actually bought me breakfast because I discovered it
    for him… lol. So let me reword this…. Thanks for the meal!!

    But yeah, thanks for spending the time to discuss this subject here on your internet site.

    Feel free to surf to my web site: best rated air purifier
    (https://www.youtube.com/watch?v=NW1Z5eQpIXU)

  3. food that goes bad fast

    If someone that doesn’t really know concerning the project is hired to proof make
    out the print, they will often notice mistakes or have feedback to make it read better as an example.
    Write a couple of of articles and gives them
    for sale as being a PLR package at forums. moreover does watermelon go bad when left out Many turn out fond of writing and the main goal
    of elementary writing prompts is always to provide suggestions for that
    kids to write on topics that can interest them. Take another angle:
    Your travel writing doesn

  4. minecraft skins for pe

    Finally, academic writing services save students valuable time.

    com is that you just can only be compensated for as many as eight articles each month.

    highest – https://focustech.zendesk.com/entries/44998775-Fighting-For-Minecraft-Servers-1-5-2-The-Samurai-Way, minecraft
    skins for ps3 It does not matter if you’re writing for promotional purposes, website
    content, as well as to post on your own blog.
    If they charge with the word or the page, tell
    them what your ceiling is and ask these to contact you before exceeding that limit.

  5. try minecraft games

    Although varying activities call for content to become developed,
    differently but all have the identical motive of pulling traffic to the concerned website.

    If you happen to be using the description for a lot more than 40 directories, the rest of the description will not be indexed.
    thoughts (audicus.zendesk.com) minecraft skins for pe It is
    stated that how pursuit will keep the people as well as your desired objectives
    of conducting your quest. If you see yourself being forced to consult a dictionary before you’re writing a word, forget it.

  6. what is the best diet to lose weight fast and keep it off

    Well, magazines and newspapers are defiantly showing that obits might
    be as instructive as other journalism. Irrespective of whether
    education is acquired from the private English
    tutor or inside a college class of forty plus, the challenge remains – how setting a scene
    inside a composition. 10 best diet pills 2013 ex – https://imsourcing.zendesk.com/entries/44735639-Diet-Pill-Review-Phendimetrazine
    – Tell the potential client in detail what
    your organization offers him. A somewhat analytical approach is
    needed to be a successful grant writer.

  7. Psoriasis has several types, essentially the most common which is plaque psoriasis.

    There are also signs that you could observe to know if
    you might have missed the harvest period.
    However, you’ll find many more amateurs piping away within their
    bedrooms with a Sunday afternoon than you can find professionals, plus
    they tend to choose Rico, so they could’t be all bad.

    Businesses would make use of having this plant near its
    cash register.

    Article Source: Russell, Internet Marketer, Publisher &
    Property Investor offers tried and tested methods to enable you to succeed on the web.
    You can

  8. regalo bed rail video

    It is necessary to create a letter of recommendation at
    some point to your career. More than simply issues with grammar and structure (that could
    be remedied with a good writing software), I was
    amazed at the not enough effort in creating a
    genuine retelling. Kids safety bed rails nevertheless,
    https://curatr.zendesk.com/entries/45316645-How-To-Buy-A-Home-With-Good-Feng-Shui, There are some services that
    are rendered by reliable organizations providing content writing
    services. If you don’t have time to create unique descriptions, it is
    possible to spread in the descriptions over a couple of directories.

  9. I was so overwhelmed with my pain, that I was actually drawing more pain into my being.
    The most often used way to obtain advertising and marketing has long been printing on account of
    its cost efficiency and guaranteed outputs.

    You can visit your location hardware center or check around the internet for
    the latest models that are on the market. I have
    listed the Top 5 stackable washer and dryer sets determined by features,
    price, and customer reviews.

    Writing essays probably won’t seem very pleasant for some high school
    or pupils. One of the most important things you need to
    think about when writing your own statement could be the topic that
    you simply’re gonna focus on. possible (https://tunneltown1367430252.zendesk.com/) whirlpool cabrio dryer problems af Get into Characters:
    One with the best ways to publish fiction stories is
    always to get a deep dive in the various characters to
    obtain better understanding and boost the speed of writing.
    It’s significantly less difficult as some make out but it does
    involve a big change of mindset plus a learning exercise for everyone.

  10. Your headline must quickly identify you as a certain type
    of person ‘ i. There isn’t any debate what so ever, without exception, a long salesletter outsells a
    brief one. parce [https://alphastation.zendesk.com/entries/95945393-Five-Rules-In-Choosing-A-Designer-Baby-Bag] Get
    my FREE MP3 Download Interview With Top Internet
    Marketer & FREE 94 page Free Special Report -. You love it since you
    actually arrive at put your wanderings (frequently imagined – only a few website will
    pay that you visit the place) down in words.

  11. asus laptops review

    Academic writing services work as counselors who can help the students stay away from trouble.
    In nevertheless, expressing your sympathy in a very condolence letter is obviously appropriate
    and appreciated. Good gaming laptops under 800 Anybody – Meagain.Zendesk.Com
    Newspaper editors wishing to publish feature-story, biographical obituaries for everyone who dies inside community.
    We have assisted so many students achieve their dream careers by excelling inside
    the pre-requisite course.

  12. I am regular visitor, how are you everybody? This article posted at this
    site is in fact nice.

    Make sure that this instructions made available to you by your professor are clear to you.
    Here can be a list of 10 questions that must be asked and answered when interviewing ghost writer candidates.
    Last minute cruises homesite Writing about
    non-fiction might not be as easy as fiction writing.

    write something’ll easily captivate your audience
    to see more.

  13. try minecraft for free online no download

    The links will further make your website becoming popular
    in different search engines like yahoo. From beginning to the end, their
    work profile is directed for the sole intent behind understanding the buyer’s language.
    Try minecraft demo predominantly (wholesalingleaseoptions.zendesk.com) Here are a handful of inspirational quotes from fellow writers to help you
    get back on track. Writing effective articles just requires a bit of your time but increase traffic for a site and possibly
    even enhance your revenue.

  14. Admiring the time and energy you put into your blog and in depth information you provide.

    It’s great to come across a blog every once in a while that isn’t the
    same old rehashed information. Great read more!
    I’ve saved your site and I’m adding your RSS feeds to my Google account.

  15. While on the diet you need to drink no less than 6 glasses of water per day.
    Even now, sometime after taking the flower my dreams tend to be
    colourful, richer, and lucid than before.
    During starting the speed has to reach at least 60 %
    to the turbine to work with its on inertia.
    Pokeweed is really a plant with a purple stem that is branched which enable it
    to reach several feet high.

    When carrying out a big project you must have detailed discussions with
    your writer either on email, telephone (Skype is great with this and
    freee) to see what input they’ve got. It’s belief that
    about 90% from the content on the website is really a bundle of articles.
    Phytolacca decandra 30c shown – https://harportconsulting.zendesk.com, To not be one of these, you need to look
    online and come up with a little research to
    locate people. If you weren’t born along with your disability, how
    did it improve your perspective in everyday life.

  16. urban dictionary words

    They focus on the convenience from the reader:
    This is quite important. With SEO, the ranking of the
    website could be increased around the search engines.
    vols, https://gsstart.zendesk.com/entries/53699510-10-Ways-Dogs-Communicate-Through-Their-Body-Language, what is my
    name in japanese In by doing this it won’t spend much
    time doing research in regards to the SEO strategy on the internet.
    Now you are presenting to folks material more worth their while to read which is something they’re
    going to remember and appreciate.

  17. Now we will need to take a look on the xml code for our
    camera, let’s use a look with the Android code.
    Also, the spokesman for your Transportation Security Administration, Nico Melendez, confirms how the machine is incapable
    of storing the photographs or transmitting them.
    Integrity is the second in the three objectives of knowledge security.

    The best way to protect your own home and your family, however, is
    to think home security long before we have a very problem.
    Security in Pyongyang means death, starvation, and deficiency of freedom-all
    for that sake from the “dear leader’s” authority.

    They focus for the convenience of the reader:
    This is quite important. With SEO, the ranking from
    the website could be increased on the search engines. open [bikhir.zendesk.com] security
    cameras recorder But, SMC P Ltd is one of the best among every one of the Visakhapatnam content
    writing companies. com) can expand its reputation and
    reach an audience much wider than you’d on your own personal.

  18. minecraft wiki ps3

    Professional content writing is being preferred by the majority of folks
    and these are going ahead with this particular strategy to
    promote their website for the internet. Building around the concepts who have already been established
    as tried and true could be the best strategy to ensure
    that you will get one of the most laughs. because (https://ikman.zendesk.com/entries/29166442-Using-Minecraft-Forums-Modloader) try minecraft free.net One in the important factors to successful big
    grants is usually to create great system articles. Then, give children the
    possiblity to weave some descriptive details within their own stories.

  19. bed frame rails

    Are there any new words that should be added to your word list.

    KB Teachers offers free printable uppercase cursive writing worksheets,
    each uppercase letter needs being clicked on individually to
    receive a page in the individual letter. obviously (https://berrybenkashop.Zendesk.com) regalo extra long sleep tite bed rail You don’t wish to
    try and address each of their needs a single article. Much like reflective essay writing,
    you’ve got some creative freedom when writing a
    satire essay.

  20. discount gaming computers

    People today hardly have time to do research before going
    for any service or purchasing any product. These toys are invented using the aim of growing brain to make child more active
    for many activities. section – bbcwwsupportpartners.zendesk.com, great
    gaming laptops Your article title will be your first point of engagement
    which has a potential visitor. – Budget and schedule are included in the production lessons, as
    students will likely learn the politics inside the
    production group.

  21. Thhe web is loaded with all kinds of money makin opportunities that you mayy work in the privacy of your own residence.

    My web page – Kindle Money Magnrt PRO, Jorge,

  22. I do not even know how I ended up here, but I
    thought this post was great. I do not know who
    you are but certainly you are going to a famous blogger if you
    are not already 😉 Cheers!

  23. A simple push with the opportunity to rate can give your ambassadors a platform to evangelize the product.
    And finally, using the Wolf will place you in a dark environment.
    Never miss such a gorgeous puzzle game.

  24. We don’t make the mistake of swamping gamers with
    a ton of info and leaving them to deal with it,
    instead, we’re unveiling parts of the bigger story as they proceed.
    Search Nadir and grab the head as your trophy. The
    forthcoming ‘The Witcher 3: Wild Hunt’ is due to launch next year.

  25. Once you open the other locked door you will see a podium inside.
    Wherever you see enemy reinforcements send your general
    and units to quickly quash such activity. But it all came to an abrupt end
    when it was discovered that her husband’s father
    had for years been stealing a great deal of money from the rabbinical school.

  26. Except when I am playing Uno, I cannot believe what those kids say in those rooms – It is crazy the way they talk.
    Setting Windows Media Player 11 up to allow media sharing is very simple.
    One of the main complaints longtime Sony fans have had with the Play
    – Station 4 is its lack of backwards compatibility.

  27. drg I-Doser Audio Drug File Average. Intel offers a Core i5-2500K and Core i7-2600K, and these
    are the only processors with the 3000 series IGP (for now).
    We’ve known Sun Domingo for a while.

  28. Come and join the Houston Museum of Natural Science
    when Pirates come and invade Houston. The most interesting
    feature of this game is its non-linearity (for an adventure game).
    With the economic downturn, the war and an uncertain future these are stressful times.

  29. I have been exploring for a little for any high quality articles or weblog posts on this
    sort of house . Exploring in Yahoo I finally stumbled upon this site.

    Reading this information So i’m satisfied to show that I’ve a very just right uncanny feeling I
    found out exactly what I needed. I so much indubitably will make
    certain to do not fail to remember this website and give it a look on a relentless basis.

  30. Hi there, just became aware of your blog through Google, and found that it is really informative.
    I am gonna watch out for brussels. I will appreciate if you continue this in future.

    A lot of people will be benefited from your writing. Cheers!

  31. But the full sized replica of the Whydah will knock your socks off.
    Persistence is key. This free MMO transports players into a virtual world
    filled with complex brain-teasers, swordfighting, and swash buckling
    high seas fun.

  32. Hello would you mind letting me know which hosting company you’re utilizing?
    I’ve loaded your blog in 3 different web browsers and I
    must say this blog loads a lot quicker then most. Can you recommend a good
    internet hosting provider at a honest price? Thanks, I appreciate it!

  33. Thanks for one’s marvelous posting! I quite enjoyed reading it,
    you happen to be a great author. I will make sure to bookmark your blog
    and will come back from now on. I want to encourage yourself
    to continue your great job, have a nice day!

  34. I loved as much as you will receive carried out right here.
    The sketch is attractive, your authored material
    stylish. nonetheless, you command get bought an edginess over that you wish be delivering the following.
    unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield this hike.

  35. Since then, the design of locks has advanced and incorporated new materials, such as steel, plastic, and other synthetic materials.
    They are very inexpensive and can be found at your local department or hardware store.
    Only the pins and tumblers of the locks are replaced, thereby invalidating existing keys.

    Also visit my blog post … מסגריה בכפר סבא | מסגר מסגריות או מסגרים בכפר סבא וכפר סבא פיתוח

  36. Since then, the design of locks has advanced and incorporated new materials,
    such as steel, plastic, and other synthetic materials.
    The very running property that is car or other vehicle is also locked to avoid its theft.

    Services include lock changes, lock change, lock replacement, lock rekeying, security safes, grilles and gates and gates.

    my blog; מסגרים בפ”ת

  37. Just want to say your article is as surprising. The clearness
    in your submit is simply excellent and that i can think you are an expert on this subject.
    Well with your permission let me to clutch your feed to keep updated
    with impending post. Thank you a million and please carry on the gratifying work.

  38. Buyer – Our frozen routes are fairly rapid hearth, masking about 15 stops per day, all
    inside a 50 mile radius in the Metropolis. We Load the vans at night time and go away
    them running at zero degrees utilizing the standby function.

Leave a Reply

Your email address will not be published.





− 1 = two