示例#1
0
        private void RegisterProduct(IProduct product, Assembly assembly)
        {
            try
            {
                var productContext = new ProductContext {
                    AssemblyName = assembly.FullName
                };

                product.Init(productContext);
                ProductContexts.Add(product.ID, productContext);
                WebItemManager.Instance.RegistryItem(product);

                if (productContext.GlobalHandler != null)
                {
                    GlobalHandlers.Add(productContext.GlobalHandler);
                }
                foreach (var module in product.Modules)
                {
                    try
                    {
                        if (module.Context != null && module.Context.UserActivityPublishers != null)
                        {
                            module.Context.UserActivityPublishers.ForEach(p => p.DoUserActivity += DoUserActivityHandler);
                        }
                        if (module.Context != null && module.Context.SearchHandler != null)
                        {
                            SearchHandlerManager.Registry(module.Context.SearchHandler);
                        }
                    }
                    catch (Exception exc)
                    {
                        log.Error(string.Format("Couldn't load module activity publisher {0}", module.Name), exc);
                    }
                }
                if (product.Context.UserActivityPublishers != null)
                {
                    product.Context.UserActivityPublishers.ForEach(p => p.DoUserActivity += DoUserActivityHandler);
                }

                Products.Add(product);
                Products.Sort((p1, p2) => p1.Context.DefaultSortOrder.CompareTo(p2.Context.DefaultSortOrder));

                log.DebugFormat("product {0} loaded", product.Name);
            }
            catch (Exception exc)
            {
                log.Error(string.Format("Couldn't load product {0}", product.Name), exc);
            }
        }