예제 #1
0
 protected override void Initialize(HttpControllerContext controllerContext)
 {
     base.Initialize(controllerContext);
     Log.Rename("2sApiC");
     SxcContext        = Helpers.GetSxcOfApiRequest(Request, true, Log);
     AppAndDataHelpers = new AppAndDataHelpers(SxcContext, SxcContext?.ModuleInfo, SxcContext?.Log ?? Log);
     controllerContext.Request.Properties.Add(Constants.DnnContextKey, Dnn); // must run after creating AppAndDataHelpers
 }
예제 #2
0
        // </2sic>

        #endregion

        #region BaseClass Overrides

        protected override void ConfigurePage(WebPageBase parentPage)
        {
            base.ConfigurePage(parentPage);

            // Child pages need to get their context from the Parent
            Context = parentPage.Context;

            // Return if parent page is not a SexyContentWebPage
            if (parentPage.GetType().BaseType != typeof(SexyContentWebPage))
            {
                return;
            }

            Html = ((SexyContentWebPage)parentPage).Html;
            Url  = ((SexyContentWebPage)parentPage).Url;
            AppAndDataHelpers = ((SexyContentWebPage)parentPage).AppAndDataHelpers;
        }
예제 #3
0
        // </2sic>

        #endregion

        #region BaseClass Overrides

        protected override void ConfigurePage(WebPageBase parentPage)
        {
            base.ConfigurePage(parentPage);

            // Child pages need to get their context from the Parent
            Context = parentPage.Context;

            // Return if parent page is not a SexyContentWebPage
            if (!(parentPage is SexyContentWebPage))
            {
                return;                                         // 2016-02-22 believe this is necessary with dnn 8 because this razor uses a more complex inheritance with Type<T>
            }
            //if (parentPage.GetType().BaseType != typeof(SexyContentWebPage)) return;

            Html = ((SexyContentWebPage)parentPage).Html;
            Url  = ((SexyContentWebPage)parentPage).Url;
            Sexy = ((SexyContentWebPage)parentPage).Sexy;
            AppAndDataHelpers = ((SexyContentWebPage)parentPage).AppAndDataHelpers;
        }
예제 #4
0
 public T CreateSource <T>(IDataSource inSource = null, IValueCollectionProvider configurationProvider = null)
 => AppAndDataHelpers.CreateSource <T>(inSource, configurationProvider);
예제 #5
0
 /// <inheritdoc />
 public IEnumerable <dynamic> AsDynamic(IEnumerable <IEntity> entities) => AppAndDataHelpers.AsDynamic(entities);
예제 #6
0
 public IDataSource CreateSource(string typeName = "", IDataSource inSource = null,
                                 IValueCollectionProvider configurationProvider = null)
 => AppAndDataHelpers.CreateSource(typeName, inSource, configurationProvider);
예제 #7
0
 /// <summary>
 /// In case AsDynamic is used with Data["name"]
 /// </summary>
 /// <param name="list"></param>
 /// <returns></returns>
 public IEnumerable <dynamic> AsDynamic(IDataStream stream)
 {
     return(AppAndDataHelpers.AsDynamic(stream.List));
 }
예제 #8
0
 private void InitDataHelper()
 {
     _dataHelper = new AppAndDataHelpers(Sexy);
 }
예제 #9
0
 public IDataSource CreateSource(string typeName = "", IDataSource inSource = null, IConfigurationProvider configurationProvider = null)
 {
     return(AppAndDataHelpers.CreateSource(typeName, inSource, configurationProvider));
 }
예제 #10
0
 /// <inheritdoc />
 public IEntity AsEntity(dynamic dynamicEntity) => AppAndDataHelpers.AsEntity(dynamicEntity);
예제 #11
0
 /// <summary>
 /// Provides an Adam instance for this item and field
 /// </summary>
 /// <param name="entity">The entity, often Content or similar</param>
 /// <param name="fieldName">The field name, like "Gallery" or "Pics"</param>
 /// <returns>An Adam object for navigating the assets</returns>
 public AdamNavigator AsAdam(IEntity entity, string fieldName) => AppAndDataHelpers.AsAdam(entity, fieldName);
예제 #12
0
 /// <inheritdoc />
 public dynamic AsDynamic(IEntity entity) => AppAndDataHelpers.AsDynamic(entity);
예제 #13
0
 /// <summary>
 /// Makes sure a dynamicEntity could be wrapped in AsDynamic()
 /// </summary>
 /// <param name="dynamicEntity"></param>
 /// <returns></returns>
 public dynamic AsDynamic(dynamic dynamicEntity)
 {
     return(AppAndDataHelpers.AsDynamic(dynamicEntity));
 }
예제 #14
0
        /// <summary>
        /// Renders a Token Template
        /// </summary>
        /// <returns>Rendered template as string</returns>
        protected override string RenderTemplate()
        {
            var h = new AppAndDataHelpers(Sexy, ModuleInfo, (ViewDataSource)DataSource, App);

            var listContent      = h.ListContent;
            var listPresentation = h.ListPresentation;
            var elements         = h.List;

            // Prepare Source Text
            string sourceText = System.IO.File.ReadAllText(HostingEnvironment.MapPath(TemplatePath));
            string repeatingPart;

            // Prepare List Object
            var list = new Dictionary <string, string>
            {
                { "Index", "0" },
                { "Index1", "1" },
                { "Count", "1" },
                { "IsFirst", "First" },
                { "IsLast", "Last" },
                { "Alternator2", "0" },
                { "Alternator3", "0" },
                { "Alternator4", "0" },
                { "Alternator5", "0" }
            };

            list["Count"] = elements.Count.ToString();

            // If the SourceText contains a <repeat>, define Repeating Part. Else take SourceText as repeating part.
            bool containsRepeat = sourceText.Contains("<repeat>") && sourceText.Contains("</repeat>");

            if (containsRepeat)
            {
                repeatingPart = Regex.Match(sourceText, @"<repeat>(.*?)</repeat>", RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Captures[0].Value;
            }
            else
            {
                repeatingPart = "";
            }

            string renderedTemplate = "";

            foreach (var element in elements)
            {
                // Modify List Object
                list["Index"]       = elements.IndexOf(element).ToString();
                list["Index1"]      = (elements.IndexOf(element) + 1).ToString();
                list["IsFirst"]     = elements.First() == element ? "First" : "";
                list["IsLast"]      = elements.Last() == element ? "Last" : "";
                list["Alternator2"] = (elements.IndexOf(element) % 2).ToString();
                list["Alternator3"] = (elements.IndexOf(element) % 3).ToString();
                list["Alternator4"] = (elements.IndexOf(element) % 4).ToString();
                list["Alternator5"] = (elements.IndexOf(element) % 5).ToString();

                // Replace Tokens
                var tokenReplace = new TokenReplace((DynamicEntity)element.Content, (DynamicEntity)element.Presentation, (DynamicEntity)listContent, (DynamicEntity)listPresentation, list, App);
                tokenReplace.ModuleId       = ModuleInfo.ModuleID;
                tokenReplace.PortalSettings = PortalSettings.Current;
                renderedTemplate           += tokenReplace.ReplaceEnvironmentTokens(repeatingPart);
            }

            // Replace repeating part
            renderedTemplate = Regex.Replace(sourceText, "<repeat>.*?</repeat>", renderedTemplate, RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.Singleline);

            // Replace tokens outside the repeating part
            var tr2 = new TokenReplace(elements.Any() ? elements.First().Content : null, elements.Any() ? elements.First().Presentation : null, listContent, listPresentation, list, App);

            tr2.ModuleId       = ModuleInfo.ModuleID;
            tr2.PortalSettings = PortalSettings.Current;
            renderedTemplate   = tr2.ReplaceEnvironmentTokens(renderedTemplate);

            return(renderedTemplate);
        }
예제 #15
0
 /// <summary>
 /// Transform a DynamicEntity dynamic object back to a IEntity instance
 /// </summary>
 /// <param name="dynamicEntity"></param>
 /// <returns></returns>
 public IEntity AsEntity(dynamic dynamicEntity)
 {
     return(AppAndDataHelpers.AsEntity(dynamicEntity));
 }
예제 #16
0
 /// <summary>
 /// Create a source with initial stream to attach...
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="inStream"></param>
 /// <returns></returns>
 public T CreateSource <T>(IDataStream inStream)
 {
     return(AppAndDataHelpers.CreateSource <T>(inStream));
 }
예제 #17
0
 public T CreateSource <T>(IDataSource inSource = null, IConfigurationProvider configurationProvider = null)
 {
     return(AppAndDataHelpers.CreateSource <T>(inSource, configurationProvider));
 }
예제 #18
0
 /// <inheritdoc />
 public T CreateSource <T>(IDataStream inStream) => AppAndDataHelpers.CreateSource <T>(inStream);
예제 #19
0
 /// <inheritdoc />
 public dynamic AsDynamic(KeyValuePair <int, IEntity> entityKeyValuePair) => AppAndDataHelpers.AsDynamic(entityKeyValuePair.Value);
예제 #20
0
 /// <summary>
 /// Provides an Adam instance for this item and field
 /// </summary>
 /// <param name="entity">The entity, often Content or similar</param>
 /// <param name="fieldName">The field name, like "Gallery" or "Pics"</param>
 /// <returns>An Adam object for navigating the assets</returns>
 public AdamNavigator AsAdam(DynamicEntity entity, string fieldName)
 => AppAndDataHelpers.AsAdam(AsEntity(entity), fieldName);
예제 #21
0
 /// <summary>
 /// Returns a list of DynamicEntities
 /// </summary>
 /// <param name="entities">List of entities</param>
 /// <returns></returns>
 public IEnumerable <dynamic> AsDynamic(IEnumerable <IEntity> entities)
 {
     return(AppAndDataHelpers.AsDynamic(entities));
 }
예제 #22
0
 /// <inheritdoc />
 public IEnumerable <dynamic> AsDynamic(IDictionary <int, IEntity> list) => AppAndDataHelpers.AsDynamic(list);
예제 #23
0
 private void InitDataHelper()
 {
     dataHelper = new AppAndDataHelpers(Sexy);//, ModuleInfo, (ViewDataSource)DataSource);//, App);
 }
예제 #24
0
 /// <inheritdoc />
 public dynamic AsDynamic(dynamic dynamicEntity) => AppAndDataHelpers.AsDynamic(dynamicEntity);
예제 #25
0
        public static IAppAndDataHelpers CodingHelpers(ISxcInstance sxc)
        {
            var appAndDataHelpers = new AppAndDataHelpers(sxc as SxcInstance);

            return(appAndDataHelpers);
        }
예제 #26
0
 /// <inheritdoc />
 public IEnumerable <dynamic> AsDynamic(IDataStream stream) => AppAndDataHelpers.AsDynamic(stream.List);
예제 #27
0
파일: TokenEngine.cs 프로젝트: 2sic/2sxc
 private void InitDataHelper()
 {
     _dataHelper = new AppAndDataHelpers(Sexy);
 }
예제 #28
0
파일: Factory.cs 프로젝트: 2sic/2sxc
        public static IAppAndDataHelpers CodingHelpers(ISxcInstance sxc)
        {
            var appAndDataHelpers = new AppAndDataHelpers(sxc as SxcInstance);

            return appAndDataHelpers;
        }
예제 #29
0
 private void InitDataHelper()
 {
     dataHelper = new AppAndDataHelpers(Sexy, ModuleInfo, (ViewDataSource)DataSource, App);
 }