Exemple #1
0
        private static Dictionary<Type, List<Guid>> LoadGuids(IZetboxContext ctx, IPackageProvider[] providers)
        {
            Log.Info("Loading Export Guids");

            Dictionary<Type, List<Guid>> guids = new Dictionary<Type, List<Guid>>();
            foreach (var reader in providers.Select(p => p.Reader))
            {
                XPathDocument doc = new XPathDocument(reader);
                XPathNavigator nav = doc.CreateNavigator();
                XPathNodeIterator it = nav.Select("//*[@ExportGuid]");

                while (it.MoveNext())
                {
                    string ns = it.Current.NamespaceURI;
                    string tn = it.Current.LocalName;
                    if (it.Current.MoveToAttribute("ExportGuid", String.Empty))
                    {
                        Guid exportGuid = it.Current.Value.TryParseGuidValue();
                        if (exportGuid != Guid.Empty)
                        {
                            string ifTypeName = string.Format("{0}.{1}", ns, tn);
                            ifTypeName = MigrateTypeNameMapping(ifTypeName);
                            Type t = ctx.GetInterfaceType(ifTypeName).Type;
                            if (t != null)
                            {
                                if (!guids.ContainsKey(t)) guids[t] = new List<Guid>();
                                guids[t].Add(exportGuid);
                            }
                            else
                            {
                                Log.WarnOnce(string.Format("Type {0} not found", ifTypeName));
                            }
                        }
                    }
                }
            }
            return guids;
        }