SPinjSettings.cs :  » Database » SQL-Power-Injector » SQLPowerInjector » 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 » Database » SQL Power Injector 
SQL Power Injector » SQLPowerInjector » SPinjSettings.cs
//*********************************************************************
//                                   //
//  SQL Power Injector 1.2 Copyright (c) 2006-2007 Francois Larouche //
//                                   //
//  Author  : francois.larouche@sqlpowerinjector.com         //
//  Web Site: www.sqlpowerinjector.com                 //
//                                   //
//*******************************************************************//
using System;
using System.Xml.Serialization;
using System.IO;
using System.Collections;

namespace SQLPowerInjector{
  /// <summary>
  /// Summary description for Session.
  /// </summary>
  [XmlRootAttribute("SQL_Power_Injector_Settings", Namespace="", IsNullable=false)]
  public class SPinjSettings
  {
    #region Members
    #region Private
    private bool _useCookie;
    private bool _autoDetectEncoding;
    private uint _startingLength;
    private uint _startingCount;
    private byte _numberThreads;
    private bool _characterSetCaseInsensitive; 
    private int _htmlMessageLength;
    private bool _trapErrorString;
    private bool _useProxy;
    private ushort _ttInitialDelay;
    private ushort _ttAutoPopDelay;
    private Referer_Type _refererType;
    private string _manualRefererUri;
    private ushort _userAgentSelectedIndex;
    private string _proxyAddress;
    private ushort _proxyPort;
    #endregion
    #region Constants
    const uint STARTING_LENGTH_MAX = 1000000;
    const uint STARTING_COUNT_MAX = 1000000;
    const byte NUMBER_THREADS_MAX = 50;
    const int HTML_MESSAGE_LENGTH_MAX = 100000000;
    const int TOOLTIP_INITIAL_DELAY_MAX = 32000;
    const int TOOLTIP_AUTOPOP_DELAY_MAX = 32000;
    const ushort PROXY_PORT_MAX = 65535;
    #endregion
    #endregion

    #region Public Enums
    public enum Referer_Type
    {
      None    = 0,
      Itself    = 1,
      Manual    = 2
    }
    #endregion

    #region Constructor
    public SPinjSettings() 
    {
      _useCookie = false;
      _autoDetectEncoding = true;
      _startingLength = 50;
      _startingCount = 100;
      _numberThreads = 1;
      _characterSetCaseInsensitive = false;
      _htmlMessageLength = 256;
      _trapErrorString = false;
      _useProxy = false;
      _ttInitialDelay = 500;
      _ttAutoPopDelay = 32000;
      _refererType = Referer_Type.Itself;
      _manualRefererUri = "";
      _userAgentSelectedIndex = 0;
      _proxyAddress = "";
      _proxyPort = 8080;
    }
    #endregion

    #region Public Attributes
    public bool UseCookie
    {
      get { return _useCookie; }
      set { _useCookie = value; }
    }

    public bool AutoDetectEncoding
    {
      get { return _autoDetectEncoding; }
      set { _autoDetectEncoding = value; }
    }

    public uint StartingLength
    {
      get { return _startingLength; }
      set
      { 
        if(value <= STARTING_LENGTH_MAX)
          _startingLength = value;
        else
          _startingLength = 50;
      }
    }

    public uint StartingCount
    {
      get { return _startingCount; }
      set
      { 
        if(value <= STARTING_COUNT_MAX)
          _startingCount = value;
        else
          _startingCount = 100;
      }
    }

    public byte NumberThreads
    {
      get { return _numberThreads; }
      set
      { 
        if(value <= NUMBER_THREADS_MAX)
          _numberThreads = value;
        else
          _numberThreads = 1;
      }
    }

    public bool CharacterSetCaseInSensitive
    {
      get { return _characterSetCaseInsensitive; }
      set { _characterSetCaseInsensitive = value; }
    }

    public int HtmlMessageLength
    {
      get { return _htmlMessageLength; }
      set
      { 
        if(value <= HTML_MESSAGE_LENGTH_MAX)
          _htmlMessageLength = value;
        else
          _htmlMessageLength = 256;
      }
    }

    public bool TrapErrorString
    {
      get { return _trapErrorString; }
      set { _trapErrorString = value; }
    }

    public bool UseProxy
    {
      get { return _useProxy; }
      set { _useProxy = value; }
    }

    public ushort TooltipInitialDelay
    {
      get { return _ttInitialDelay; }
      set
      { 
        if(value <= TOOLTIP_INITIAL_DELAY_MAX)
          _ttInitialDelay = value;
        else
          _ttInitialDelay = 500;
      }
    }

    public ushort TooltipAutoPopDelay
    {
      get { return _ttAutoPopDelay; }
      set
      { 
        if(value <= TOOLTIP_AUTOPOP_DELAY_MAX)
          _ttAutoPopDelay = value;
        else
          _ttAutoPopDelay = 50000;
      }
    }

    [XmlElementAttribute("RefererType", typeof(Referer_Type))]
    public Referer_Type RefererType
    {
      get { return _refererType; }
      set { _refererType = value; }
    }

    public string ManualRefererUri
    {
      get { return _manualRefererUri; }
      set { _manualRefererUri = value; }
    }

    public string ProxyAddress
    {
      get { return _proxyAddress; }
      set { _proxyAddress = value; }
    }

    public ushort ProxyPort
    {
      get { return _proxyPort; }
      set
      { 
        if(value <= PROXY_PORT_MAX)
          _proxyPort = value;
        else
          _proxyPort = 8080;
      }
    }

    public ushort UserAgentSelectedIndex 
    {
      get { return _userAgentSelectedIndex; }
      set 
      {
        if(value >= 0)
          _userAgentSelectedIndex = value; 
        else
          _userAgentSelectedIndex = 0;
      }
    }
    #endregion

    public bool SaveSettings(SPinjSettings SettingsToSave, string XMLFileName) 
    {  
      bool settingsSavedSuccessfully = false;

      settingsSavedSuccessfully = Utilities.SerializeXML(SettingsToSave, XMLFileName);

      return settingsSavedSuccessfully; 
    }

    public static SPinjSettings LoadSettings(string XMLFileName)
    {
      return LoadSerializedSettings(XMLFileName);
    }

    private static SPinjSettings LoadSerializedSettings(string XMLFileName)
    {     
      SPinjSettings loadedSettings = new SPinjSettings();
      TextReader txrTextReader = null;

      try
      {
        XmlSerializer xserDocumentSerializer = new XmlSerializer(typeof(SPinjSettings));

        txrTextReader = new StreamReader(XMLFileName);
        loadedSettings = (SPinjSettings)xserDocumentSerializer.Deserialize(txrTextReader);
      }
      catch(InvalidOperationException ex)
      {
        throw(new MyException(ex.Message, ex.InnerException));
      }
      catch(Exception ex)
      {
        throw(ex);
      }
      finally
      {
        //Make sure to close the file even if an exception is raised...
        if (txrTextReader != null)
          txrTextReader.Close();        
      }      

      return loadedSettings;
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.