private void AssignHostingData(Microsoft.Exchange.Data.ApplicationLogic.TextMessaging.TextMessagingHostingData data) { if (data == null) { data = new Microsoft.Exchange.Data.ApplicationLogic.TextMessaging.TextMessagingHostingData(); } TextMessagingHostingDataCache.SetNullFieldsEmpty(data); try { this.rwLock.EnterWriteLock(); this.data = data; } finally { try { this.rwLock.ExitWriteLock(); } catch (SynchronizationLockException) { } } }
private void LoadFromFiles() { TimeSpan timeout = TimeSpan.FromSeconds(1.0); Microsoft.Exchange.Data.ApplicationLogic.TextMessaging.HostingData.Site.TextMessagingHostingData textMessagingHostingData = new Microsoft.Exchange.Data.ApplicationLogic.TextMessaging.HostingData.Site.TextMessagingHostingData(); XmlReaderSettings xmlReaderSettings = new XmlReaderSettings(); using (Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TextMessagingHostingData-Site.xsd")) { xmlReaderSettings.ValidationType = ValidationType.Schema; xmlReaderSettings.ValidationFlags = (XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation | XmlSchemaValidationFlags.ReportValidationWarnings | XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.AllowXmlAttributes); xmlReaderSettings.Schemas.Add(XmlSchema.Read(manifestResourceStream, null)); } int num = 0; while (2 > num) { try { using (XmlReader xmlReader = XmlReader.Create(TextMessagingHostingDataCache.SiteHostingDataFilePath, xmlReaderSettings)) { textMessagingHostingData.ReadXml(xmlReader); } break; } catch (FileNotFoundException) { break; } catch (SystemException ex) { if (!(ex is IOException) || 1 <= num) { this.IssueRedEvent(ex, TextMessagingHostingDataCache.SiteHostingDataFilePath); textMessagingHostingData = null; break; } Thread.Sleep(timeout); } num++; } XmlReaderSettings xmlReaderSettings2 = new XmlReaderSettings(); using (Stream manifestResourceStream2 = Assembly.GetExecutingAssembly().GetManifestResourceStream("TextMessagingHostingData-System.xsd")) { xmlReaderSettings2.ValidationType = ValidationType.Schema; xmlReaderSettings2.ValidationFlags = (XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation | XmlSchemaValidationFlags.ReportValidationWarnings | XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.AllowXmlAttributes); xmlReaderSettings2.Schemas.Add(XmlSchema.Read(manifestResourceStream2, null)); } int num2 = 0; while (2 > num2) { try { Microsoft.Exchange.Data.ApplicationLogic.TextMessaging.HostingData.System.TextMessagingHostingData textMessagingHostingData2 = new Microsoft.Exchange.Data.ApplicationLogic.TextMessaging.HostingData.System.TextMessagingHostingData(); Microsoft.Exchange.Data.ApplicationLogic.TextMessaging.HostingData.System.TextMessagingHostingData textMessagingHostingData3 = new Microsoft.Exchange.Data.ApplicationLogic.TextMessaging.HostingData.System.TextMessagingHostingData(); using (FileStream fileStream = new FileStream(TextMessagingHostingDataCache.SystemHostingDataFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (XmlReader xmlReader2 = XmlReader.Create(fileStream, xmlReaderSettings2)) { textMessagingHostingData2.ReadXml(xmlReader2); } textMessagingHostingData2.AcceptChanges(); if (textMessagingHostingData != null) { fileStream.Seek(0L, SeekOrigin.Begin); using (XmlReader xmlReader3 = XmlReader.Create(fileStream, xmlReaderSettings2)) { textMessagingHostingData3.ReadXml(xmlReader3); } } textMessagingHostingData3.AcceptChanges(); } if (textMessagingHostingData != null) { try { textMessagingHostingData2.Merge(textMessagingHostingData); textMessagingHostingData2.AcceptChanges(); this.IssueGreenEvent(); } catch (ConstraintException e) { this.IssueRedEvent(e, TextMessagingHostingDataCache.SiteHostingDataFilePath); textMessagingHostingData2 = textMessagingHostingData3; } } this.AssignHostingData(TextMessagingHostingDataCache.Convert(textMessagingHostingData2)); break; } catch (SystemException ex2) { if (!(ex2 is IOException) || 1 <= num2) { this.IssueRedEvent(ex2, TextMessagingHostingDataCache.SystemHostingDataFilePath); this.AssignHostingData(null); break; } Thread.Sleep(timeout); } num2++; } if (this.Changed != null) { this.Changed(this.data); } }