protected override string GetMessageToBeSent() { string proxySettings; switch (proxyStyle) { case HTTPHelper.ProxyStyle.SpecifiedProxy: proxySettings = String.Join(SEPARATOR.ToString(), new[] { HealthCheckSettings.PROXY_SETTINGS, ((Int32)HTTPHelper.ProxyStyle.SpecifiedProxy).ToString(), proxyAddress, proxyPort.ToString(), timeOut.ToString(), bypassProxyForServers.ToString(), provideProxyCredentials.ToString(), EncryptionUtils.ProtectForLocalMachine(proxyUsername), EncryptionUtils.ProtectForLocalMachine(proxyPassword), ((Int32)proxyAuthenticationMethod).ToString() }); return(proxySettings); case HTTPHelper.ProxyStyle.SystemProxy: proxySettings = String.Join(SEPARATOR.ToString(), new[] { HealthCheckSettings.PROXY_SETTINGS, ((Int32)HTTPHelper.ProxyStyle.SystemProxy).ToString() }); return(proxySettings); default: proxySettings = String.Join(SEPARATOR.ToString(), new[] { HealthCheckSettings.PROXY_SETTINGS, ((Int32)HTTPHelper.ProxyStyle.DirectConnection).ToString() }); return(proxySettings); } }
/// <see> /// http://blogs.microsoft.co.il/yuvmaz/2013/05/10/longest-common-prefix-with-c-and-linq/ /// </see> static string FindPrefix(string[] values) { if (values == null || values.Length == 0) { return(string.Empty); } const char SEPARATOR = '_'; List <string> parts; parts = new List <string>(values[0].Split(SEPARATOR)); for (int index = 1; index < values.Length; index++) { List <string> first = parts; List <string> second = new List <string>(values[index].Split(SEPARATOR)); int maxLength = Mathf.Min(first.Count, second.Count); List <string> tempParts = new List <string>(maxLength); for (int part = 0; part < maxLength; part++) { if (first[part] == second[part]) { tempParts.Add(first[part]); } } parts = tempParts; } return(string.Join(SEPARATOR.ToString(), parts.ToArray())); }
protected override string GetMessageToBeSent() { switch (proxyStyle) { case HTTPHelper.ProxyStyle.SpecifiedProxy: var proxyUsername = ""; try { if (!string.IsNullOrEmpty(protectedProxyUsername)) { proxyUsername = EncryptionUtils.Unprotect(protectedProxyUsername); } } catch (Exception e) { log.Error("Could not unprotect internet proxy username.", e); return(null); } var proxyPassword = ""; try { if (!string.IsNullOrEmpty(protectedProxyPassword)) { proxyPassword = EncryptionUtils.Unprotect(protectedProxyPassword); } } catch (Exception e) { log.Error("Could not unprotect internet proxy password.", e); return(null); } return(string.Join(SEPARATOR.ToString(), HealthCheckSettings.PROXY_SETTINGS, ((int)HTTPHelper.ProxyStyle.SpecifiedProxy).ToString(), proxyAddress, proxyPort.ToString(), timeOut.ToString(), bypassProxyForServers.ToString(), provideProxyCredentials.ToString(), EncryptionUtils.ProtectForLocalMachine(proxyUsername), EncryptionUtils.ProtectForLocalMachine(proxyPassword), ((int)proxyAuthenticationMethod).ToString())); case HTTPHelper.ProxyStyle.SystemProxy: return(string.Join(SEPARATOR.ToString(), HealthCheckSettings.PROXY_SETTINGS, ((int)HTTPHelper.ProxyStyle.SystemProxy).ToString())); default: return(string.Join(SEPARATOR.ToString(), HealthCheckSettings.PROXY_SETTINGS, ((int)HTTPHelper.ProxyStyle.DirectConnection).ToString())); } }
/// <summary> /// Serializes the keys present in the in-memory representation of the index. /// </summary> /// <returns>The keys.</returns> protected string SerializeKeys() { string[] data = new string[_INDEX.Count]; int index = 0; foreach (var kv in _INDEX) { data[index++] = string.Format("{0}:{1}", kv.Key, kv.Value); } return(string.Join(SEPARATOR.ToString(), data)); }
protected override string GetMessageToBeSent() { var host = Helpers.GetMaster(pool.Connection); if (host == null) { return(null); } if (healthCheckSettings.Status == HealthCheckStatus.Enabled && (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))) { return(null); // do not send empty/null username or password (when the Health Check is enabled), as they will be ignored } var credential = healthCheckSettings.Status == HealthCheckStatus.Enabled ? String.Join(SEPARATOR.ToString(), host.address, username, password) : String.Join(SEPARATOR.ToString(), host.address); return(EncryptionUtils.ProtectForLocalMachine(credential)); }
private string GetLongestCommonPrefix(IEnumerable <string> pathes) { if (pathes == null || pathes.Count() == 0) { return(String.Empty); } const char SEPARATOR = '/'; string[] prefixParts = pathes.Select(dir => dir.Split(SEPARATOR)) .Aggregate( (first, second) => first.Zip(second, (a, b) => new { First = a, Second = b }) .TakeWhile(pair => pair.First.Equals(pair.Second)) .Select(pair => pair.First) .ToArray() ); return(string.Join(SEPARATOR.ToString(), prefixParts)); }
/// <summary> /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>. /// </summary> /// <returns> /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>. /// </returns> public override string ToString() { return(String.Join(SEPARATOR.ToString(), new string[] { base.ToString(), EmailMsgId.ToString(), EmailAttachmentIndex.ToString() })); }
protected override string GetMessageToBeSent() { return(string.Join(SEPARATOR.ToString(), HealthCheckSettings.XENCENTER_METADATA, EncryptionUtils.ProtectForLocalMachine(metadata))); }
/// <summary> /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>. /// </summary> /// <returns> /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>. /// </returns> public override string ToString() { return(String.Join(SEPARATOR.ToString(), new string[] { base.ToString(), UniqueId.ToString(), HistoryId.ToString() })); }
/// <summary> /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>. /// </summary> /// <returns> /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>. /// </returns> public override string ToString() { return(String.Join(SEPARATOR.ToString(), new string[] { base.ToString(), UniqueId.ToString(), MetaObjectType, MetaObjectId.ToString(), MetaFieldName.ToString() }) + SEPARATOR); }
/// <summary> /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>. /// </summary> /// <returns> /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>. /// </returns> public override string ToString() { return(String.Join(SEPARATOR.ToString(), new string[] { base.ToString(), FileUID.ToString() })); }