Beispiel #1
0
 public static Item GetActionItem(this RenderingContext renderingContext, string templateIdentifier = null, IDataliftStrategy strategy = null)
 {
     return(GetActionItem(null, renderingContext.Rendering.DataSource, templateIdentifier, renderingContext.ContextItem, strategy));
 }
Beispiel #2
0
        public static Item GetActionItem(this IController controller, string datasourceString = null, string templateIdentifier = null, Item contextItem = null, IDataliftStrategy strategy = null)
        {
            IDataliftAttribute att = null;

            if (controller != null)
            {
                att = GetStrategyAttribute(controller);
            }

            if (strategy == null && att != null)
            {
                strategy = att.Strategy;
            }

            if (templateIdentifier == null && att != null)
            {
                templateIdentifier = att.TemplateIdentifier;
            }

            if (datasourceString == null)
            {
                datasourceString = RenderingContext.CurrentOrNull?.Rendering.DataSource;
            }

            if (strategy == null)
            {
                strategy = new DatasourceOrSelfStrategy();
            }

            if (contextItem == null)
            {
                contextItem = Context.Item;
            }

            return(strategy.Resolve(datasourceString, contextItem, templateIdentifier));
        }