Main Page | Class Hierarchy | Class List | File List | Class Members

CommonSettings.cs

00001 using System;
00002 using Microsoft.Win32;
00003 
00004 namespace Common
00005 {
00009         public class CommonSettings     {
00010                 private RegistryKey regKey;
00011 
00012                 public CommonSettings() {
00013                         regKey = Registry.CurrentUser.OpenSubKey("Software\\University of Cambridge\\GPRSWeb\\Common", true);
00014                 }
00015 
00016                 private string cacheLocation = null; 
00017                 public string CacheLocation {
00018                         get {
00019                                 if (cacheLocation == null) {
00020                                         cacheLocation = (string)regKey.GetValue("CacheLocation");
00021                                 } // it may return null if we can't find it, so do 2nd check
00022                                 if (cacheLocation != null) {
00023                                         return cacheLocation;
00024                                 } else {
00025                                         throw new ApplicationException("Unable to fetch Cache Location: none set in registry");
00026                                 }
00027                         }
00028                 }
00029 
00030                 private string cacheFileExtension = null;
00031                 public string CacheFileExtension {
00032                         get {
00033                                 if (cacheFileExtension == null) {
00034                                         cacheFileExtension = (string)regKey.GetValue("CacheFileExtension");
00035                                 } // it may return null if we can't find it, so do 2nd check
00036                                 if (cacheFileExtension != null) {
00037                                         return cacheFileExtension;
00038                                 } else {
00039                                         throw new ApplicationException("Unable to fetch Cache File Extension: none set in registry");
00040                                 }
00041                         }
00042                 }
00043         }
00044 }

Generated on Mon May 8 22:07:27 2006 by  doxygen 1.3.9.1