/// <summary> /// Merges the specified organizations. /// </summary> /// <param name="organizations">The organizations.</param> /// <param name="organization">The organization.</param> /// <returns>True if Changed.</returns> public static bool Merge(this ExtensionCollection <Organization> organizations, Organization organization) { if ((!string.IsNullOrWhiteSpace(organization.Name) || !string.IsNullOrWhiteSpace(organization.Department))) { var result = false; if (organizations.Any(e => e.Name == organization.Name)) { var org = organizations.First(e => e.Name == organization.Name); result |= org.ApplyProperty(o => o.Department, organization.Department); result |= org.ApplyProperty(o => o.Title, organization.Title); } else { organizations.Add(organization); result = true; } if (organizations.Any() && !organizations.Any(e => e.Primary)) { organizations.First().Primary = true; } return(result); } return(false); }
/// <summary> /// Merges the specified websites. /// </summary> /// <param name="websites">The websites.</param> /// <param name="website">The website.</param> /// <returns>True if Changed.</returns> public static bool Merge(this ExtensionCollection <Website> websites, Website website) { if (!string.IsNullOrWhiteSpace(website.Href) && !websites.Any(e => e.Href == website.Href)) { websites.Add(website); if (websites.Any() && !websites.Any(e => e.Primary)) { websites.First().Primary = true; } return(true); } return(false); }
/// <summary> /// Merges the specified ims. /// </summary> /// <param name="ims">The ims.</param> /// <param name="im">The im.</param> /// <returns>True if Changed.</returns> public static bool Merge(this ExtensionCollection <IMAddress> ims, IMAddress im) { if (!string.IsNullOrWhiteSpace(im.Address) && !ims.Any(e => e.Address == im.Address)) { ims.Add(im); if (ims.Any() && !ims.Any(e => e.Primary)) { ims.First().Primary = true; } return(true); } return(false); }
/// <summary> /// Merges the specified emails. /// </summary> /// <param name="emails">The emails.</param> /// <param name="mail">The mail.</param> /// <returns>True if Changed.</returns> public static bool Merge(this ExtensionCollection <EMail> emails, EMail mail) { if (!string.IsNullOrWhiteSpace(mail.Address) && !emails.Any(e => e.Address == mail.Address)) { emails.Add(mail); if (emails.Any() && !emails.Any(e => e.Primary)) { emails.First().Primary = true; } return(true); } return(false); }
/// <summary> /// Merges the specified phone numbers. /// </summary> /// <param name="phoneNumbers">The phone numbers.</param> /// <param name="phone">The phone.</param> /// <returns>True if Changed.</returns> public static bool Merge(this ExtensionCollection <PhoneNumber> phoneNumbers, PhoneNumber phone) { if (!string.IsNullOrWhiteSpace(phone.Value) && !phoneNumbers.Any(e => e.Value.FormatPhoneClean() == phone.Value.FormatPhoneClean())) { phoneNumbers.Add(phone); return(true); } return(false); }
/// <summary> /// Merges the specified addresses. /// </summary> /// <param name="addresses">The addresses.</param> /// <param name="address">The address.</param> /// <returns>True if Changed.</returns> public static bool Merge(this ExtensionCollection <StructuredPostalAddress> addresses, StructuredPostalAddress address) { if (!string.IsNullOrWhiteSpace(address.Street) && !string.IsNullOrWhiteSpace(address.City) && !string.IsNullOrWhiteSpace(address.Postcode) && !string.IsNullOrWhiteSpace(address.Country) && !addresses.Any(e => (address.Street != null && address.Street.StartsWith(e.Street)) && e.City == address.City && e.Postcode == address.Postcode && e.Country == address.Country)) { addresses.Add(address); return(true); } return(false); }
/// <summary> /// Merges the specified locations. /// </summary> /// <param name="locations">The locations.</param> /// <param name="location">The location.</param> /// <returns>True if Changed.</returns> public static bool Merge(this ExtensionCollection <Where> locations, string location) { if (!string.IsNullOrWhiteSpace(location) && !locations.Any(e => e.ValueString == location)) { locations.Add(new Where { ValueString = location, Rel = Where.RelType.EVENT }); return(true); } return(false); }
public static void Initialize(Context context) { var extensions = new ExtensionCollection( context: context, where : DataSources.Rds.ExtensionsWhere() .Disabled(false)); if (extensions.Any()) { Parameters.ExtendedSqls = Parameters.ExtendedSqls ?? new List <ExtendedSql>(); Parameters.ExtendedStyles = Parameters.ExtendedStyles ?? new List <ExtendedStyle>(); Parameters.ExtendedScripts = Parameters.ExtendedScripts ?? new List <ExtendedScript>(); Parameters.ExtendedHtmls = Parameters.ExtendedHtmls ?? new List <ExtendedHtml>(); extensions.ForEach(extension => { switch (extension.ExtensionType) { case "Sql": var extendedSql = extension.ExtensionSettings.Deserialize <ExtendedSql>(); if (extendedSql != null) { extendedSql.Name = Strings.CoalesceEmpty( extension.ExtensionName, extendedSql.Name); if (!extension.Body.IsNullOrEmpty()) { extendedSql.CommandText = extension.Body; } Parameters.ExtendedSqls.Add(extendedSql); } break; case "Style": var extendedStyle = extension.ExtensionSettings.Deserialize <ExtendedStyle>(); if (extendedStyle != null) { extendedStyle.Name = Strings.CoalesceEmpty( extension.ExtensionName, extendedStyle.Name); if (!extension.Body.IsNullOrEmpty()) { extendedStyle.Style = extension.Body; } Parameters.ExtendedStyles.Add(extendedStyle); } break; case "Script": var extendedScript = extension.ExtensionSettings.Deserialize <ExtendedScript>(); if (extendedScript != null) { extendedScript.Name = Strings.CoalesceEmpty( extension.ExtensionName, extendedScript.Name); if (!extension.Body.IsNullOrEmpty()) { extendedScript.Script = extension.Body; } Parameters.ExtendedScripts.Add(extendedScript); } break; case "Html": var extendedHtml = extension.ExtensionSettings.Deserialize <ExtendedHtml>(); if (extendedHtml != null) { extendedHtml.Name = Strings.CoalesceEmpty( extension.ExtensionName, extendedHtml.Name); if (!extension.Body.IsNullOrEmpty()) { var listDisplay = new Dictionary <string, List <DisplayElement> >(); var name = extendedHtml.Name; var displayElement = new DisplayElement { Language = extendedHtml.Language, Body = extension.Body }; listDisplay .AddIfNotConainsKey(name, new List <DisplayElement>()) .Get(name) .Add(displayElement); extendedHtml.Html = listDisplay; } Parameters.ExtendedHtmls.Add(extendedHtml); } break; default: break; } }); } }
public static void Initialize(Context context) { var extensions = new ExtensionCollection( context: context, where : DataSources.Rds.ExtensionsWhere() .Disabled(false)); if (extensions.Any()) { Parameters.ExtendedSqls = Parameters.ExtendedSqls ?? new List <ExtendedSql>(); Parameters.ExtendedStyles = Parameters.ExtendedStyles ?? new List <ExtendedStyle>(); Parameters.ExtendedScripts = Parameters.ExtendedScripts ?? new List <ExtendedScript>(); extensions.ForEach(extension => { switch (extension.ExtensionType) { case "Sql": var extendedSql = extension.ExtensionSettings.Deserialize <ExtendedSql>(); if (extendedSql != null) { extendedSql.Name = Strings.CoalesceEmpty( extension.ExtensionName, extendedSql.Name); if (!extension.Body.IsNullOrEmpty()) { extendedSql.CommandText = extension.Body; } Parameters.ExtendedSqls.Add(extendedSql); } break; case "Style": var extendedStyle = extension.ExtensionSettings.Deserialize <ExtendedStyle>(); if (extendedStyle != null) { extendedStyle.Name = Strings.CoalesceEmpty( extension.ExtensionName, extendedStyle.Name); if (!extension.Body.IsNullOrEmpty()) { extendedStyle.Style = extension.Body; } Parameters.ExtendedStyles.Add(extendedStyle); } break; case "Script": var extendedScript = extension.ExtensionSettings.Deserialize <ExtendedScript>(); if (extendedScript != null) { extendedScript.Name = Strings.CoalesceEmpty( extension.ExtensionName, extendedScript.Name); if (!extension.Body.IsNullOrEmpty()) { extendedScript.Script = extension.Body; } Parameters.ExtendedScripts.Add(extendedScript); } break; default: break; } }); } }
/// <summary> /// Merges the specified participants. /// </summary> /// <param name="participants">The participants.</param> /// <param name="outlookCalendarItem">The outlook calendar item.</param> /// <returns>True if Changed.</returns> public static bool Merge(this ExtensionCollection <Who> participants, AppointmentItem outlookCalendarItem) { var result = false; foreach (Recipient recipient in outlookCalendarItem.Recipients.Cast <Recipient>().Where(recipient => !participants.Any(e => e.Email == (recipient.Address ?? recipient.Name)))) { participants.Add(new Who { Attendee_Type = ((OlMeetingRecipientType)Enum.Parse(typeof(OlMeetingRecipientType), recipient.Type.ToString())).GetRecipientType(), Email = recipient.Address ?? recipient.Name, Rel = Who.RelType.EVENT_ATTENDEE }); result |= true; } return(result); }