/// <summary>
 /// Identifies if the item in the args belongs to a method token collection
 /// </summary>
 /// <param name="args"></param>
 public void Process(GetTokenCollectionTypeArgs args)
 {
     if (args.CollectionItem.TemplateID.ToString() == Constants.TokenMethodCollectionTemplateId)
     {
         if (string.IsNullOrWhiteSpace(args.CollectionItem["type"]))
         {
             args.AbortPipeline();
             return;
         }
         try
         {
             string[]        tmp  = args.CollectionItem["type"].Split(',');
             Type            t    = Assembly.Load(tmp[1]).GetType(tmp[0]);
             ConstructorInfo ctor = t.GetConstructor(new[] { typeof(Item) });
             if (ctor == null)
             {
                 return;
             }
             args.Collection = (ITokenCollection <IToken>)ctor.Invoke(new object[] { args.CollectionItem });
             args.AbortPipeline();
         }
         catch (Exception e)
         {
             Log.Error("Unable to resolve dynamic token type", e, this);
         }
     }
 }
        public virtual ITokenCollection <IToken> GetCollectionFromItem(Item item)
        {
            var args = new GetTokenCollectionTypeArgs()
            {
                CollectionItem = item
            };
            var pipeline = CorePipelineFactory.GetPipeline("getTokenCollection", string.Empty);

            pipeline.Run(args);
            return(args.Collection);
        }
		/// <summary>
		/// Identifies if the current item in the args is a SitecoreTokenCollection item
		/// </summary>
		/// <param name="args"></param>
		public void Process(GetTokenCollectionTypeArgs args)
		{
			if (args.CollectionItem.TemplateID.ToString() != Constants.TokenCollectionTemplateId) return;
			try
			{
				args.Collection = new SimpleSitecoreTokenCollection(args.CollectionItem, new ID(Constants.TokenTemplateId));
				args.AbortPipeline();
			}
			catch (Exception e)
			{
				Log.Error("Unable to load sitecore based token", e, this);
			}
		}
        /// <summary>
        /// Identifies if the item in the args belongs to a method token collection
        /// </summary>
        /// <param name="args"></param>
        public void Process(GetTokenCollectionTypeArgs args)
        {
	        if (args.CollectionItem.TemplateID.ToString() != Constants.TokenRenderingCollectionTemplateId) return;
	        try
	        {
		        args.Collection = new RenderingTokenCollection(args.CollectionItem,
			        new ID(Constants.TokenRenderingTokenTemplateId)); //rendering token template guid
		        args.AbortPipeline();
	        }
	        catch (Exception e)
	        {
		        Log.Error("unable to load rendering token", e,this);
	        }
        }
		/// <summary>
		/// Identifies if the current item in the args is a SitecoreTokenCollection item
		/// </summary>
		/// <param name="args"></param>
		public void Process(GetTokenCollectionTypeArgs args)
		{
			if (args.CollectionItem.TemplateID.ToString() != "{147C5339-DB74-413F-A749-AE4C29B7C1F0}") return;
			try
			{
				args.Collection = new RulesTokenCollection(args.CollectionItem, new ID("{7D6A72CC-D346-43D2-A279-EF6CA27BCF31}"));
				//rules token template guid
				args.AbortPipeline();
			}
			catch (Exception e)
			{
				Log.Error("Unable to load rules token", e, this);
			}
		}
 /// <summary>
 /// Identifies if the item in the args belongs to a method token collection
 /// </summary>
 /// <param name="args"></param>
 public void Process(GetTokenCollectionTypeArgs args)
 {
     if (args.CollectionItem.TemplateID.ToString() != Constants.TokenSharedLinkCollectionTemplateId) return;
     try
     {
         args.Collection = new SharedLinkTokenCollection(args.CollectionItem,
             new ID(Constants.TokenSharedLinkTemplateId)); //rules token template guid
         args.AbortPipeline();
     }
     catch (Exception e)
     {
         Log.Error("Unable to load shared link token" , e, this);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Identifies if the current item in the args is a SitecoreTokenCollection item
 /// </summary>
 /// <param name="args"></param>
 public void Process(GetTokenCollectionTypeArgs args)
 {
     try
     {
         var collection = TokenIdentifier.Current.ResolveCollection <ITokenCollection <IToken> >(args.CollectionItem);
         if (collection != null)
         {
             args.Collection = collection;
             args.AbortPipeline();
         }
     }
     catch (Exception e)
     {
         Log.Error("Issue resolving token collection " + args.CollectionItem + " this could be due to the link database needing to be rebuilt or a database cleanup operation needs to be run", e, this);
     }
 }