public override bool AutoSaveUpdates() { if (ElementIndex < 0 || !base.Dirty && String.IsNullOrEmpty(richUpdate.Text)) // can not be empty { return(true); } string xml = richUpdate.Xml; skinString currString = newEnList[ElementIndex]; if (base.Dirty) { if (String.IsNullOrEmpty(xml)) { base.SetError(richUpdate.XmlError); return(false); } else { Exception exeption; skin testSkin = XmlSerializerBase <skin> .ReadString(String.Format(Envelope, xml), out exeption); if (testSkin == null || exeption != null) { base.SetError(exeption.InnerException != null ? exeption.InnerException.Message : exeption.Message); return(false); } else { if (testSkin.strings == null || testSkin.strings.Length == 0) { base.SetError(Settings.Default.InvalidXml); return(false); } if (currString.id != testSkin.strings[0].id) { base.SetError(Settings.Default.InvalidId); return(false); } if (testSkin.strings[0].Text != null) { base.SetError(Settings.Default.TextJunk); return(false); } if (testSkin.strings[0].junk != null) { base.SetError(Settings.Default.ExtraText); return(false); } base.Dirty = false; } } } if (!updatedXmlDic.ContainsKey(currString.id)) { updatedXmlDic.Add(currString.id, xml); } else { updatedXmlDic[currString.id] = xml; } return(true); }
public override bool AutoSaveUpdates() { if (ElementIndex < 0 || !base.Dirty && String.IsNullOrEmpty(richUpdate.Text)) // can not be empty { return(true); } string xml = richUpdate.Xml; skinDialog currDialog = newEnList[ElementIndex]; if (base.Dirty) { if (String.IsNullOrEmpty(xml)) { base.SetError(richUpdate.XmlError); return(false); } else { Exception exeption; skin testSkin = XmlSerializerBase <skin> .ReadString(String.Format(Envelope, xml), out exeption); if (testSkin == null || exeption != null) { base.SetError(exeption.InnerException != null ? exeption.InnerException.Message : exeption.Message); return(false); } else { if (testSkin.dialogs == null || testSkin.dialogs.Length == 0) { base.SetError(Settings.Default.InvalidXml); return(false); } if (currDialog.cookie != testSkin.dialogs[0].cookie) { base.SetError(Settings.Default.InvalidCookie); return(false); } if (currDialog.name != testSkin.dialogs[0].name) { base.SetError(Settings.Default.InvalidDialogName); return(false); } if (!String.IsNullOrEmpty(currDialog.caption) && String.IsNullOrEmpty(testSkin.dialogs[0].caption)) { base.SetError(Settings.Default.MissingCaption); return(false); } if (testSkin.dialogs[0].Text != null) { base.SetError(Settings.Default.TextJunk); return(false); } if (testSkin.dialogs[0].junk != null) { base.SetError(Settings.Default.ExtraText); return(false); } int count = currDialog.controls == null ? 0 : currDialog.controls.Length; int trCount = testSkin.dialogs[0].controls == null ? 0 : testSkin.dialogs[0].controls.Length; if (trCount != count) { base.SetError(Settings.Default.InvalidControlCount); return(false); } for (int i = 0; i < count; i++) { if (testSkin.dialogs[0].controls[i].junk != null) { base.SetError(String.Format(Settings.Default.ExtraControlAttributes, i + 1)); return(false); } if (currDialog.controls[i].caption == String.Empty && testSkin.dialogs[0].controls[i].caption != String.Empty || currDialog.controls[i].caption != String.Empty && testSkin.dialogs[0].controls[i].caption == String.Empty) { base.SetError(String.Format(Settings.Default.InvalidControl, i + 1)); return(false); } } base.Dirty = false; } } } if (!updatedXmlDic.ContainsKey(currDialog.name)) { updatedXmlDic.Add(currDialog.name, xml); } else { updatedXmlDic[currDialog.name] = xml; } return(true); }