internal static bool CatchNonFatalExceptions(Action action, string diagnosticsDataToLog = null) { bool result = false; try { action(); } catch (Exception ex) { if (ex is OutOfMemoryException || ex is StackOverflowException || ex is ThreadAbortException) { throw; } result = true; diagnosticsDataToLog = (diagnosticsDataToLog ?? string.Empty); if (!(ex is StoragePermanentException) && !(ex is StorageTransientException)) { ReportOptions options = ActivityLoggingConfig.Instance.IsDumpCollectionEnabled ? ReportOptions.None : ReportOptions.DoNotCollectDumps; ExWatson.SendReport(ex, options, diagnosticsDataToLog); } InferenceDiagnosticsLog.Log("CatchNonFatalExceptions", new List <string> { diagnosticsDataToLog, ex.ToString() }); } return(result); }
public override Dictionary <string, string> Deserialize(byte[] byteArray, out bool isTruncatedResult) { ArgumentValidator.ThrowIfNull("byteArray", byteArray); Dictionary <string, string> dictionary = new Dictionary <string, string>(); isTruncatedResult = false; if (byteArray.Length > 1024) { InferenceDiagnosticsLog.Log("CustomPropertySerializerV1.Deserialize", string.Format("Byte Array length '{0}' is greater than ByteLimit '{1}'. Possible data corruption.", byteArray.Length, 1024)); return(dictionary); } using (MemoryStream memoryStream = new MemoryStream(byteArray)) { using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8)) { try { long length = memoryStream.Length; if (length < 3L) { InferenceDiagnosticsLog.Log("CustomPropertySerializerV1.Deserialize", "Stream length cannot be lesser than header length"); return(dictionary); } binaryReader.ReadByte(); int num = (int)binaryReader.ReadByte(); if (this.Version < num) { InferenceDiagnosticsLog.Log("CustomPropertySerializerV1.Deserialize", string.Format("Serializer version '{0}' cannot be lesser than min supported version '{1}'", this.Version, num)); return(dictionary); } byte b = binaryReader.ReadByte(); isTruncatedResult = ((b & 1) == 1); string text = string.Empty; string value = string.Empty; while (memoryStream.Position < length) { text = binaryReader.ReadString(); value = binaryReader.ReadString(); if (!dictionary.ContainsKey(text)) { dictionary.Add(text, value); } else { InferenceDiagnosticsLog.Log("CustomPropertySerializerV1.Deserialize", string.Format("Found duplicate key '{0}'", text)); } } } catch (EndOfStreamException ex) { InferenceDiagnosticsLog.Log("CustomPropertySerializerV1.Deserialize", ex.ToString()); } } } return(dictionary); }
protected ClutterNotification(MailboxSession session, VariantConfigurationSnapshot snapshot, IFrontEndLocator frontEndLocator) { ArgumentValidator.ThrowIfNull("session", session); ArgumentValidator.ThrowIfNull("snapshot", snapshot); if (frontEndLocator == null) { InferenceDiagnosticsLog.Log("ClutterNotification.ctor", "FrontEndLocator was not provided (it must be dependency injected). Using default OWA path."); } this.Session = session; this.Snapshot = snapshot; this.FrontEndLocator = frontEndLocator; this.Culture = ClutterNotification.GetPreferredCulture(this.Session); }
private static CultureInfo GetPreferredCulture(MailboxSession session) { foreach (CultureInfo cultureInfo in session.MailboxOwner.PreferredCultures.Concat(new CultureInfo[] { session.InternalPreferedCulture })) { if (ClutterNotification.SupportedClientLanguages.Contains(cultureInfo)) { return(cultureInfo); } } if (ClutterNotification.SupportedClientLanguages.Contains(CultureInfo.CurrentCulture)) { return(CultureInfo.CurrentCulture); } InferenceDiagnosticsLog.Log("ClutterNotification.GetPreferredCulture", string.Format("No supported culture could be found for mailbox '{0}'. Falling back to default {1}.", session.MailboxGuid, ClutterNotification.ProductDefaultCulture.Name)); return(ClutterNotification.ProductDefaultCulture); }
public static AbstractCustomPropertySerializer GetDeserializer(byte[] bytes) { ArgumentValidator.ThrowIfNull("bytes", bytes); if (bytes.Length < 3) { InferenceDiagnosticsLog.Log("CustomPropertySerializerFactory.GetDeserializer", string.Format("Cannot deserialize a byte array that does not have a header. Length of bytes: '{0}'", bytes.Length)); return(null); } int num = (int)bytes[0]; int num2 = (int)bytes[1]; if (num <= CustomPropertySerializerFactory.maxVersion) { return(CustomPropertySerializerFactory.GetSerializer(num)); } if (num2 <= CustomPropertySerializerFactory.maxVersion) { return(CustomPropertySerializerFactory.GetSerializer(CustomPropertySerializerFactory.maxVersion)); } InferenceDiagnosticsLog.Log("Activity.DeserializeCustomPropertiesDictionary", string.Format("Unable to find a serializer for deserializing. Version used for serializing '{0}', MinVersion supported '{1}', MaxVersion understood by factory '{2}'", num, num2, CustomPropertySerializerFactory.maxVersion)); return(null); }