Archive for Luglio, 2008
Class for write and read Strings to Registry
CodeKeep C# Feed Luglio 31st, 2008
Description: This is a class for Registryaccess, so far only string values are supported.Link: http://www.codekeep.net/snippets/5fe1259d-b0eb-4e25-b80a-ad8804c32b44.aspx
/// <summary>
/// Class for Registry String Access.
/// </summary>
class CREGISTRYACCESS
{
// Konstanten
private const string SOFTWARE_KEY = "Software";
private const string COMPANY_NAME = "Florianus";
private const string APPLICATION_NAME = "Protec";
/// <summary>
/// Method to read string value.
/// </summary>
/// <param name="sKey">Der Schlüsselwert.</param>
/// <param name="sDefaultValue">Standard value.</param>
/// <returns>the value</returns>
static public string GetStringRegistryValue(string sKey, string sDefaultValue)
{
RegistryKey rkCompany;
RegistryKey rkApplication;
rkCompany = Registry.CurrentUser.OpenSubKey(SOFTWARE_KEY, false).OpenSubKey(COMPANY_NAME, false);
if (rkCompany != null)
{
rkApplication = rkCompany.OpenSubKey(APPLICATION_NAME, true);
if (rkApplication != null)
{
foreach (string sRKey in rkApplication.GetValueNames())
{
if (sRKey == sKey)
{
return (string)rkApplication.GetValue(sRKey);
}
}
}
}
return sDefaultValue;
}
/// <summary>
/// Method to write string value.
/// </summary>
/// <param name="sKey">The Key.</param>
/// <param name="sStringValue">The value.</param>
static public void SetStringRegistryValue(string sKey, string sStringValue)
{
RegistryKey rkSoftware;
RegistryKey rkCompany;
RegistryKey rkApplication;
rkSoftware = Registry.CurrentUser.OpenSubKey(SOFTWARE_KEY, true);
rkCompany = rkSoftware.CreateSubKey(COMPANY_NAME);
if (rkCompany != null)
{
rkApplication = rkCompany.CreateSubKey(APPLICATION_NAME);
if (rkApplication != null)
{
rkApplication.SetValue(sKey, sStringValue);
}
}
}
}deneme
CodeKeep C# Feed Luglio 31st, 2008
Description: denemeLink: http://www.codekeep.net/snippets/65653a41-bcb6-466a-ae3b-cf6fed75d30f.aspx
test
check for html tags regular expression
CodeKeep C# Feed Luglio 30th, 2008
Description: checks a string for any text that looks to be an html tags.Link: http://www.codekeep.net/snippets/d4fdda36-75f0-47f6-904c-66b969d4f3ed.aspx
</?(\w+)(?:[^">]|\"[^"]*")*>
Stop Watch
CodeKeep C# Feed Luglio 30th, 2008
Description: use this to find out how long it take to execute a line(s) of codeLink: http://www.codekeep.net/snippets/f07e36d8-6d3e-4869-ab8c-96dae6ee8ebb.aspx
System.Diagnostics.Stopwatch sp = new System.Diagnostics.Stopwatch(); sp.Start(); sp.Stop(); sp.Elapsed.ToString();
POUAnalyser
CodeKeep C# Feed Luglio 30th, 2008
Description: Temporary nested classes of HSCPTOVariableRules.csLink: http://www.codekeep.net/snippets/3c5b7817-5f93-40a8-b095-998c2c9e5631.aspx
#region Nested Class
internal class POUAnalyser
{
#region Private Members
private POUs _activePOUs;
#endregion
#region Contructors / Desctructors
public POUAnalyser(IBuildAnalyserRule analyser)
{
}
#endregion
}
internal class POUs: CollectionBase, IList, ICollection, IEnumerable
{
#region Contructors / Desctructors
public POUs()
{
}
#endregion
#region Public Methods
#endregion
#region Private Methods
/// <summary>
/// Returns the list of the active POUs which are configured in the task configuration.
/// </summary>
/// <param name="analyser"></param>
/// <returns></returns>
private List<IPouObject> GetActivePOUs(IBuildMessageLogger analyser)
{
List<IPouObject> activePOUs = new List<IPouObject>();
// get the application meta object passed in the arguments
IMetaObject appMetaObj = SystemInstances.ObjectMgr.GetObjectToRead(analyser.ProjectHandle, analyser.Application);
foreach (Guid subGuid in appMetaObj.SubObjectGuids)
{
// Search in all the child objects, the application object
IMetaObject childMetaObj = SystemInstances.ObjectMgr.GetObjectToRead(analyser.ProjectHandle, subGuid);
//get the "Embedded Functions" object
//if (childMetaObj.Object.GetType().ToString().Equals("_3S.CoDeSys.TaskConfigObject.TaskConfigObject"))
if (childMetaObj.Object is ITaskConfigObject)
{
ITaskConfigObject taskConfig = childMetaObj.Object as ITaskConfigObject;
foreach (ITaskObject task in taskConfig.Tasks)
{
foreach (IPouObject pou in task.POUs)
{
activePOUs.Add(pou);
}
}
}
}
return activePOUs;
}
/// <summary>
/// Returns the list of all the POUs which are stored in the project.
/// </summary>
/// <param name="analyser"></param>
private Dictionary<string, IPOUObject> GetAllPOUs(IBuildMessageLogger analyser)
{
Dictionary<string, IPOUObject> POUs = new Dictionary<string, IPOUObject>();
foreach (Guid guid in SystemInstances.ObjectMgr.GetAllObjects(analyser.ProjectHandle))
{
IMetaObject metaObject = SystemInstances.ObjectMgr.GetObjectToRead(analyser.ProjectHandle, guid);
if (metaObject.Object is IPOUObject)
{
IPOUObject pouObj = metaObject.Object as IPOUObject;
POUs.Add(pouObj.MetaObject.Name, pouObj);
}
}
return POUs;
}
#endregion
}
#endregionWeb Hosting Control Panels
WebReference News Luglio 29th, 2008
Web hosting is a highly competitive field. Extra features, such as free domain names, site builder and pricing vary widely, but the control panel makes a difference and you have to pick the service which suits your requirements. By IHBO. 0701Avoid Shutdown of a Win-Application if ‘x’ is pressed
CodeKeep C# Feed Luglio 29th, 2008
Description: This short code avoid a Shutdown of a Win-Application if the 'x' Button is pressed. You need only one line of Code in the FormClosing Event.Link: http://www.codekeep.net/snippets/16f43fa1-99f1-48f7-8275-2e6187520aab.aspx
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
}
Use Your Blog for Fast Search Engine Rankings
WebReference News Luglio 29th, 2008
If you run a Web site and are looking to get it listed quickly with the search engines, there's no easier way than to also include a blog. By Terry Detty. 0625Refactoring HTML: Well-Formedness - Part 3
WebReference News Luglio 29th, 2008
UTF-8 is a standard encoding that works across all Web browsers and is supported by all major text editors and other tools. It supports all Unicode characters and is a good basis for internationalization and localization of pages. By Elliotte Rusty Harold. 0623




