public void InsertionTest()
        {
            LabelElement label = new LabelElement("Friends");

            labels.Add(label);

            Assert.AreEqual(1, labels.Count, "Label collection should have size 1 after insertion");
            Assert.AreEqual(0, labels.IndexOf(label), "Index of singleton label should be zero");
            Assert.IsTrue(labels.Contains(label), "Label collection does not contain label after insertion");
        }
Пример #2
0
        public void InsertionTest()
        {
            mailItemProperties.Add(MailItemPropertyElement.STARRED);

            Assert.AreEqual(1, mailItemProperties.Count,
                            "Mail item property collection should have size 1 after insertion");
            Assert.AreEqual(0, mailItemProperties.IndexOf(MailItemPropertyElement.STARRED),
                            "Index of singleton mail item property should be zero");
            Assert.IsTrue(mailItemProperties.Contains(MailItemPropertyElement.STARRED),
                          "Mail item property collection does not contain property after insertion");
        }
Пример #3
0
        /// <summary>
        /// Writes the XML file for getting infos about updates.
        /// </summary>
        /// <param name="xmlFile">is the filename where to save the infos to.</param>
        public bool WriteUpdateXml(string xmlFile)
        {
            if (String.IsNullOrEmpty(xmlFile))
            {
                Console.WriteLine("[MpeMaker] Error: Output file for Update.xml is not specified in package.");
                return(false);
            }

            if (!Path.IsPathRooted(xmlFile))
            {
                xmlFile = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(this.ProjectSettings.ProjectFilename), xmlFile));
            }

            ExtensionCollection list = ExtensionCollection.Load(xmlFile);

            PackageClass pakToAdd = Clone();

            pakToAdd.GeneralInfo.OnlineLocation = ReplaceInfo(pakToAdd.GeneralInfo.OnlineLocation);
            pakToAdd.GeneralInfo.Params.Items.Remove(pakToAdd.GeneralInfo.Params[ParamNamesConst.ICON]);

            list.Add(pakToAdd);
            list.Sort(true);
            list.Save(xmlFile);

            return(true);
        }
Пример #4
0
        private void PopulateInstallBtn()
        {
            ExtensionCollection collection = MpeCore.MpeInstaller.KnownExtensions.GetList(Package.GeneralInfo.Id);

            collection.Add(Package);
            foreach (PackageClass item in collection.GetList(Package.GeneralInfo.Id).Items)
            {
                ToolStripMenuItem testToolStripMenuItem = new ToolStripMenuItem();
                testToolStripMenuItem.Text = string.Format("Version - {0} [{1}]", item.GeneralInfo.Version,
                                                           item.GeneralInfo.DevelopmentStatus);
                PackageClass pak = MpeCore.MpeInstaller.InstalledExtensions.Get(Package.GeneralInfo.Id);
                if (pak != null && item.GeneralInfo.Version.CompareTo(pak.GeneralInfo.Version) == 0)
                {
                    testToolStripMenuItem.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold,
                                                          GraphicsUnit.Point, ((byte)(0)));
                }
                if (!item.CheckDependency(true))
                {
                    testToolStripMenuItem.ForeColor = Color.Red;
                }
                if (item.GeneralInfo.VersionDescription != null)
                {
                    testToolStripMenuItem.ToolTipText = item.GeneralInfo.VersionDescription.Length > 1024
                                                ? item.GeneralInfo.VersionDescription.Substring(0, 1024) + "..."
                                                : item.GeneralInfo.VersionDescription;
                }
                testToolStripMenuItem.Tag    = item;
                testToolStripMenuItem.Click += testToolStripMenuItem_Click;
                btn_install.DropDownItems.Add(testToolStripMenuItem);
            }
        }
Пример #5
0
        /// <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);
        }
    public static void ExtensionCollectionPublicMembersTest()
    {
        ExtensionCollection <IMyExtensibleObject> collection = new ExtensionCollection <IMyExtensibleObject>(new MyExtensibleObject(), "syncRoot");

        collection.Add(new MyExtension1());
        collection.Add(new MyExtension2());

        Assert.True(collection.Count == 2, $"Expected the collection to contain 2 items, instead it contained '{collection.Count}' items.");

        IMyExtension result = collection.Find <IMyExtension>();

        Assert.NotNull(result);

        Collection <IMyExtension> myCollection = collection.FindAll <IMyExtension>();

        Assert.True(myCollection.Count == 2, $"Expected the collection to contain 2 items of type 'IMyExtension', instead it contained: '{myCollection.Count}' items.");
    }
Пример #7
0
        /// <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);
        }
Пример #8
0
        /// <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);
        }
Пример #9
0
        /// <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);
        }
Пример #10
0
        private static void UpdateReminderList(ExtensionCollection <Reminder> reminders, Reminder newReminder)
        {
            int length = reminders.Count;

            for (int i = 0; i < length; i++)
            {
                if (reminders[i].Method == newReminder.Method)
                {
                    reminders[i] = newReminder;
                    return;
                }
            }

            reminders.Add(newReminder);
        }
Пример #11
0
        /// <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);
        }
Пример #12
0
        /// <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);
        }
Пример #13
0
        /// <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);
        }
        private void add_list_Click(object sender, EventArgs e)
        {
            string xmlFile            = txt_list1.Text;
            ExtensionCollection list  = new ExtensionCollection();
            ExtensionCollection list2 = new ExtensionCollection();

            if (File.Exists(xmlFile))
            {
                list = ExtensionCollection.Load(xmlFile);
            }
            if (File.Exists(txt_list2.Text))
            {
                list2 = ExtensionCollection.Load(txt_list2.Text);
            }
            list.Add(list2);
            list.Save(xmlFile);
        }
Пример #15
0
        /// <summary>
        /// Merges the specified google groups.
        /// </summary>
        /// <param name="groups">The groups.</param>
        /// <param name="outlookGroup">The outlook group.</param>
        /// <param name="googleGroups">All google groups.</param>
        /// <returns>
        /// True if Changed.
        /// </returns>
        public static bool Merge(this ExtensionCollection <GroupMembership> groups, string outlookGroup, IEnumerable <Group> googleGroups)
        {
            if (!string.IsNullOrWhiteSpace(outlookGroup))
            {
                var outlookGroupAsGoogleGroup = googleGroups.FirstOrInstance(g => (string.IsNullOrEmpty(g.SystemGroup) ? g.Title : g.SystemGroup) == outlookGroup);
                if (!string.IsNullOrWhiteSpace(outlookGroupAsGoogleGroup.Id))
                {
                    groups.Add(new GroupMembership {
                        HRef = outlookGroupAsGoogleGroup.Id
                    });

                    return(true);
                }
            }

            return(false);
        }
Пример #16
0
        /// <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);
        }