private static bool LoadBinaryComponents()
        {
            bool conflictingGuid = false;

            X509Chain certChain = new X509Chain();

            foreach (string location in componentDirectories)
            {
                foreach (string file in System.IO.Directory.GetFiles(location, "*.cdcom", SearchOption.TopDirectoryOnly))
                {
                    var binLoader = new CircuitDiagram.IO.Descriptions.BinaryDescriptionReader();
                    binLoader.CertificateChain = certChain;

                    using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        if (binLoader.Read(fs))
                        {
                            var descriptions = binLoader.ComponentDescriptions;
                            ComponentDescriptionSource source = new ComponentDescriptionSource(file, new System.Collections.ObjectModel.ReadOnlyCollection <ComponentDescription>(descriptions));
                            foreach (ComponentDescription description in descriptions)
                            {
                                description.Metadata.Location = ComponentDescriptionMetadata.LocationType.Installed;
                                description.Source            = source;

                                // Check if duplicate GUID
                                if (!conflictingGuid && description.Metadata.GUID != Guid.Empty)
                                {
                                    foreach (ComponentDescription compareDescription in ComponentHelper.ComponentDescriptions)
                                    {
                                        if (compareDescription.Metadata.GUID == description.Metadata.GUID)
                                        {
                                            conflictingGuid = true;
                                        }
                                    }
                                }

                                ComponentHelper.AddDescription(description);
                                if (ComponentHelper.WireDescription == null && description.ComponentName.ToLowerInvariant() == "wire" && description.Metadata.GUID == new Guid("6353882b-5208-4f88-a83b-2271cc82b94f"))
                                {
                                    ComponentHelper.WireDescription = description;
                                }
                            }
                        }
                    }
                }
            }

            return(conflictingGuid);
        }
        private static bool LoadXmlComponents()
        {
            bool conflictingGuid = false;

            var xmlLoader = new XmlLoader();

            foreach (string location in componentDirectories)
            {
                foreach (string file in System.IO.Directory.GetFiles(location, "*.xml", SearchOption.TopDirectoryOnly))
                {
                    using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        xmlLoader.Load(fs);
                        if (xmlLoader.LoadErrors.Count() == 0)
                        {
                            ComponentDescription description = xmlLoader.GetDescriptions()[0];
                            description.Metadata.Location = ComponentDescriptionMetadata.LocationType.Installed;
                            description.Source            = new ComponentDescriptionSource(file, new System.Collections.ObjectModel.ReadOnlyCollection <ComponentDescription>(new ComponentDescription[] { description }));

                            // Check if duplicate GUID
                            if (!conflictingGuid && description.Metadata.GUID != Guid.Empty)
                            {
                                foreach (ComponentDescription compareDescription in ComponentHelper.ComponentDescriptions)
                                {
                                    if (compareDescription.Metadata.GUID == description.Metadata.GUID)
                                    {
                                        conflictingGuid = true;
                                    }
                                }
                            }

                            ComponentHelper.AddDescription(description);
                            if (ComponentHelper.WireDescription == null && description.ComponentName.ToLowerInvariant() == "wire" && description.Metadata.GUID == new Guid("6353882b-5208-4f88-a83b-2271cc82b94f"))
                            {
                                ComponentHelper.WireDescription = description;
                            }
                        }
                    }
                }
            }

            return(conflictingGuid);
        }