|
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
namespace XDock
{
// TRANSMISSINGCOMMENT: Class Common
// following class was VB module
[Microsoft.VisualBasic.CompilerServices.StandardModule]
sealed public class Common
{
// TRANSMISSINGCOMMENT: Method LoadSaveData
public static bool LoadSaveData( bool LoadData, string pSection, string pKey, object pDefValue, ref object pValue, ref IniFile pIniFile )
{
if ( LoadData )
{
return LoadIniData( pSection, pKey, pDefValue, ref pValue, ref pIniFile );
}
else
{
SaveIniData( pSection, pKey, pDefValue, ref pValue, ref pIniFile );
return true;
}
}
// TRANSMISSINGCOMMENT: Method LoadIniData
private static bool LoadIniData( string pSection, string pKey, object pDefValue, ref object pValue, ref IniFile pIniFile )
{
Key pIniKey = null;
bool pChanged = false;
pIniKey = pIniFile.GetKey( pKey, pSection );
if ( pIniKey == null )
{
pChanged = pIniFile.AddKey( pKey, Cast( pDefValue, pValue ).ToString(), pSection, false, null );
pValue = Cast( pDefValue, pValue );
}
else
{
pValue = Cast( pIniKey.Value, pValue );
}
return pChanged;
}
// TRANSMISSINGCOMMENT: Method Cast
private static object Cast( object Value, object Variable )
{
object pReturnObject = null;
try
{
if ( Variable.GetType().Equals( System.Drawing.Color.Black.GetType() ) )
{
pReturnObject = Color.FromName( Value.ToString() );
}
else if ( Information.IsNumeric( Value ) )
{
pReturnObject = long.Parse( Value.ToString() );
}
else
{
pReturnObject = Value.ToString();
}
}
catch ( Exception ex )
{
pReturnObject = Convert.ChangeType( Value, Variable.GetType() );
// MessageBox.Show(ex.Message)
}
return pReturnObject;
}
// TRANSMISSINGCOMMENT: Method SaveIniData
private static void SaveIniData( string pSection, string pKey, object pDefValue, ref object pValue, ref IniFile pIniFile )
{
Key pIniKey = null;
bool pChanged = false;
pIniKey = pIniFile.GetKey( pKey, pSection );
if ( pIniKey == null )
{
pIniFile.AddKey( pKey, Cast( pValue, pDefValue ).ToString(), pSection, false, null );
}
else
{
pIniFile.ChangeValue( pKey, pSection, Cast( pValue, pDefValue ).ToString() );
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.