コード例 #1
0
        /// <summary>
        /// Runs the processor.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public override void Process(ConfigurationPipelineArgs args)
        {
            object container = Context.Entity.Resolve(args.ConfigurationItemType, null);

            if (!(container is IEntity))
            {
                return;
            }

            Item item = args.CustomData["item"] as Item;

            if (item == null)
            {
                return;
            }

            LinkDatabase linkDatabase = Globals.LinkDatabase;

            ItemLink[] links = linkDatabase.GetReferrers(item);

            foreach (ItemLink link in links)
            {
                Item source = link.GetSourceItem();
                if (source.Parent.TemplateID != new ID(Configuration.Settings.GetSetting("Ecommerce.Settings.SettingsRootTemplateId")))
                {
                    continue;
                }

                this.RegisterInstance(args, (IEntity)container, source);
                args.AbortPipeline();

                break;
            }
        }
コード例 #2
0
        public TemplateInputTestFixture()
        {
            AliceTemplate       = CreateTemplate("Alice", "Hello", TemplateFieldTypes.TEXT_FIELD);
            BobTemplate         = CreateTemplate("Bob", "Hi", TemplateFieldTypes.TEXT_FIELD);
            AllisonTemplate     = CreateTemplate("Allison", "Child", TemplateFieldTypes.TEXT_FIELD, new[] { AliceTemplate.ID, BobTemplate.ID });
            FlowerChildTemplate = CreateTemplate("FlowerChild", "Grandchild", TemplateFieldTypes.TEXT_FIELD, new[] { AllisonTemplate.ID });

            _db = new Db("master")
            {
                new DbTemplate(TemplateIDs.TemplateFolder),
                new DbItem(TestingContants.TEMPLATE_FOLDER, TestingContants.TestTemplateFolderId)
                {
                    ParentID = ItemIDs.TemplateRoot, TemplateID = TemplateIDs.TemplateFolder
                },
                AliceTemplate,
                BobTemplate,
                AllisonTemplate,
                FlowerChildTemplate
            };

            _linkDbSwitcher = new LinkDatabaseSwitcher(_linkDb);
            var templateFieldTemplate = new TemplateItem(_db.GetItem(TemplateIDs.TemplateField));

            _linkDb.GetReferrers(templateFieldTemplate.InnerItem).Returns(new[]
            {
                MakeLink(AliceTemplate),
                MakeLink(BobTemplate),
                MakeLink(AllisonTemplate),
                MakeLink(FlowerChildTemplate)
            });
        }
コード例 #3
0
        private static IEnumerable <Item> GetAliasItems(Item item)
        {
            LinkDatabase           linkDatabase = Factory.GetLinkDatabase();
            IEnumerable <ItemLink> source       =
                from link in linkDatabase.GetReferrers(item)
                where link.SourceDatabaseName.Equals(item.Database.Name)
                where link.SourceFieldID.Equals(RedirectManager.FieldIDs.AliasLinkedItem)
                where link.GetSourceItem().TemplateID.Equals(Sitecore.TemplateIDs.Alias)
                select link;

            return
                (from link in source
                 select link.GetSourceItem());
        }