AppConfig.cs :  » Web-Testing » IeUnit-web-testing-framework » QuickFocus » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Web Testing » IeUnit web testing framework 
IeUnit web testing framework » QuickFocus » AppConfig.cs
/// <copyright from="2004" to="2006" company="VisuMap Technologies Inc.">
///   Copyright (C) VisuMap Technologies Inc.
/// 
///   Permission to use, copy, modify, distribute and sell this 
///   software and its documentation for any purpose is hereby 
///   granted without fee, provided that the above copyright notice 
///   appear in all copies and that both that copyright notice and 
///   this permission notice appear in supporting documentation. 
///   VisuMap Technologies Company makes no representations about the 
///   suitability of this software for any purpose. It is provided 
///   "as is" without explicit or implied warranty. 
/// </copyright>
using System;
using System.Collections;
using System.Xml;
using System.Reflection;
using System.IO;
using System.Xml.Serialization;
using System.Windows.Forms;

namespace QuickFocus{
    /// <summary>
    /// Summary description for AppConfig.
    /// </summary>
    public class AppConfig {
        public AppConfig() {}

        private static string        appCfgFile;
        
        public int  focusLevel      = 0;     // default focus level
        public bool outActionSnip   = true;
        public bool outAssertSnip   = true;
        public int  historyMaxLen   = 32;
        public bool autoClear       = false;
        public int  infoWinTop      = 250;
        public int  infoWinLeft     = 250;
        public int  infoWinWidth    = 900;
        public int  infoWinHeight   = 300;
        public bool pageAttached    = true;
        public int  focusFrameWidth = 2;
        public int  mainWinTop      = -1;
        public int  mainWinLeft     = -1;
        public int  mainWinWidth    = -1;
        public int  mainWinHeight   = -1;

        public string   appDirectory= null;   // the directory of the application's executable
        public string   appHome     = null;        // Home directory of IeUnit
        public int      browserPanelHeight  = -1;
        public bool     showAlternatives    = false;
        public bool     commentOutAlt       = true;
        public int      maxKeyTextLength    = 16;
        public string   currentFileDir      = ".";
        public string   currentScriptDir    = ".";
        public bool     simulationMode       = false;

        public ArrayList historyList = new ArrayList();

        public static AppConfig LoadConfiguration() {
            string exeLocation    = Assembly.GetExecutingAssembly().Location;
            string appDir = exeLocation.Substring(0, exeLocation.LastIndexOf('\\'));
            appCfgFile = appDir + "\\QuickFocus.xml";

            XmlSerializer serializer = new XmlSerializer(typeof(AppConfig));            
            FileStream fs = null;
            AppConfig  appCfg;
            try {
                fs = new FileStream(appCfgFile, FileMode.Open);
                appCfg = (AppConfig) serializer.Deserialize(fs);
                fs.Close();
            } catch(FileNotFoundException) {
                if ( fs != null ) {
                    fs.Close();
                }
                appCfg = new AppConfig();
            }
            
            appCfg.appDirectory = appDir;
            int idx = appDir.LastIndexOf("\\IeUnit\\");
            if ( idx >= 0) {
                appCfg.appHome = appDir.Substring(0, idx + 7);
            } else {               
                idx = appDir.LastIndexOf("\\QuickFocus\\");
                if ( idx >= 0 ) {
                    // QuickFocus is installed in separat directory.
                    appCfg.appHome = appDir.Substring(0, idx + 11);
                } else {
                    MsgBox.Alert("QuickFocus can only be installed in IeUnit or QuickFocus directory");
                    Application.Exit();
                }
            }
            Root.appConfig = appCfg;
            return appCfg;
        }

        public void SaveConfiguration() {
            if ( historyList.Count > historyMaxLen ) {
                historyList.RemoveRange(historyMaxLen, historyList.Count-historyMaxLen);
            }

            XmlSerializer serializer = new XmlSerializer(typeof(AppConfig));
            StreamWriter writer = new StreamWriter(appCfgFile);
            serializer.Serialize(writer, this);
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.