BranchPresets.AddFromBranchPreset.Process C# (CSharp) Méthode

Process() public méthode

public Process ( AddFromTemplateArgs args ) : void
args AddFromTemplateArgs
Résultat void
		public override void Process(AddFromTemplateArgs args)
		{
			Assert.ArgumentNotNull(args, nameof(args));

			if (args.Destination.Database.Name != "master") return;

			var templateItem = args.Destination.Database.GetItem(args.TemplateId);

			Assert.IsNotNull(templateItem, "Template did not exist!");

			// if this isn't a branch template, we can use the stock behavior
			if (templateItem.TemplateID != TemplateIDs.BranchTemplate) return;

			Assert.HasAccess((args.Destination.Access.CanCreate() ? 1 : 0) != 0, "AddFromTemplate - Add access required (destination: {0}, template: {1})", args.Destination.ID, args.TemplateId);

			// Create the branch template instance
			Item newItem = args.Destination.Database.Engines.DataEngine.AddFromTemplate(args.ItemName, args.TemplateId, args.Destination, args.NewId);

			// find all rendering data sources on the branch root item that point to an item under the branch template,
			// and repoint them to the equivalent subitem under the branch instance
			RewriteBranchRenderingDataSources(newItem, templateItem);

			args.Result = newItem;
		}