public DataModel() { JiraEmail = RegistryOperation.GetBinaryKeyValueInString(RegistryOperation.szAppRegPathGeneral, RegistryOperation.szKeyNameJiraEmail); bToEmail = RegistryOperation.GetBinaryKeyValueInBool(RegistryOperation.szAppRegPathGeneral, RegistryOperation.szKeyNamebToEmail); bCcEmail = RegistryOperation.GetBinaryKeyValueInBool(RegistryOperation.szAppRegPathGeneral, RegistryOperation.szKeyNamebCcEmail); bRemoveRecipients = RegistryOperation.GetBinaryKeyValueInBool(RegistryOperation.szAppRegPathGeneral, RegistryOperation.szKeyNamebRemoveRecipients); // if we create using public property then it will crash at setter because of null reference. _DefaultTemplate = new JiraTemplate(); if (bToEmail == false && bCcEmail == false) { bToEmail = true; // create registry for next time as well RegistryOperation.CreateBinaryKeyValue(RegistryOperation.szAppRegPathGeneral, RegistryOperation.szKeyNamebToEmail, "1"); } JiraTemplates = new List <JiraTemplate>(); string[] TemplateSubKeys = RegistryOperation.GetAppSubKeys(RegistryOperation.szAppRegPathTemplates); if (TemplateSubKeys != null && TemplateSubKeys.Length > 0) { string DefaultTemp = RegistryOperation.GetBinaryKeyValueInString(RegistryOperation.szAppRegPathTemplates, RegistryOperation.szKeyNameTemplateDefault); foreach (string keyName in TemplateSubKeys) { string data = RegistryOperation.GetBinaryKeyValueInString(RegistryOperation.szAppRegPathTemplates + "\\" + keyName, RegistryOperation.szKeyNameTemplateContent); if (data != null && data.Length > 0) { JiraTemplate jt = new JiraTemplate(); jt.Name = keyName; jt.Content = data; JiraTemplates.Add(jt); if (0 == String.Compare(keyName, DefaultTemp, true)) { DefaultTemplate = jt; } } } } else { // create default template and update the registry for next time. string szDefaultTemplate = JiraTemplate.GetDefaultTemplateContent(); RegistryOperation.CreateSubKey(RegistryOperation.szAppRegPathTemplates, RegistryOperation.szSubKeyNameTemplateDefault); RegistryOperation.CreateBinaryKeyValue(RegistryOperation.szAppRegPathTemplates + "\\" + RegistryOperation.szSubKeyNameTemplateDefault, RegistryOperation.szKeyNameTemplateContent, szDefaultTemplate); JiraTemplate jt = new JiraTemplate(); jt.Name = RegistryOperation.szSubKeyNameTemplateDefault; jt.Content = szDefaultTemplate; JiraTemplates.Add(jt); DefaultTemplate = jt; } }
void WriteJiraTemplateItemToRegistry(JiraTemplate jiraTemplate) { if (jiraTemplate == null) { return; } RegistryOperation.CreateSubKey(RegistryOperation.szAppRegPathTemplates, jiraTemplate.Name); RegistryOperation.CreateBinaryKeyValue(RegistryOperation.szAppRegPathTemplates + "\\" + jiraTemplate.Name, RegistryOperation.szKeyNameTemplateContent, jiraTemplate.Content); }
void WriteJiraTemplateListToRegistry() { // delete an existing subkey and re-populate from data model RegistryOperation.DeleteRegistrySubKey(RegistryOperation.szAppRegPath, RegistryOperation.szSubkeyTemplate); // Add all what is in datamodel jira list. foreach (JiraTemplate item in JiraTemplates) { if ( item.Name != null && item.Name.Length > 0 && item.Content != null && item.Content.Length > 0 ) { RegistryOperation.CreateSubKey(RegistryOperation.szAppRegPathTemplates, item.Name); RegistryOperation.CreateBinaryKeyValue(RegistryOperation.szAppRegPathTemplates + "\\" + item.Name, RegistryOperation.szKeyNameTemplateContent, item.Content); } } }