示例#1
0
        public PolymorphismDto Polymorphism(int appId)
        {
            var callLog = Log.Call <dynamic>($"a#{appId}");
            var cms     = new CmsRuntime(appId, Log, true);
            var poly    = new Polymorphism.Polymorphism(cms.Data, Log);
            var result  = new PolymorphismDto
            {
                Id       = poly.Entity?.EntityId,
                Resolver = poly.Resolver,
                TypeName = PolymorphismConstants.Name
            };

            return(callLog(null, result));
        }
示例#2
0
        public PolymorphismDto Polymorphism(int appId)
        {
            var callLog  = Log.Call <dynamic>($"a#{appId}");
            var appState = State.Get(appId);
            var poly     = new Polymorphism.Polymorphism(appState.List, Log);
            var result   = new PolymorphismDto
            {
                Id       = poly.Entity?.EntityId,
                Resolver = poly.Resolver,
                TypeName = PolymorphismConstants.Name
            };

            return(callLog(null, result));
        }
示例#3
0
        private string TryToFindPolymorphPath(string root, IView view, string subPath)
        {
            var wrapLog   = Log.Call <string>($"{root}, {subPath}");
            var polymorph = new Polymorphism.Polymorphism(Block.App.Data.List, Log);
            var edition   = polymorph.Edition();

            if (edition == null)
            {
                return(wrapLog("no edition detected", null));
            }
            Log.Add($"edition {edition} detected");

            var testPath = Helpers.LinkPaths.ToAbsolute($"{root}/{edition}/", subPath);

            if (File.Exists(Helpers.ServerPaths.FullAppPath(testPath)))
            {
                view.Edition = edition;
                return(wrapLog($"edition {edition}", testPath));
            }

            Log.Add("tried inserting path, will check if sub-path");
            var firstSlash = subPath.IndexOf('/');

            if (firstSlash == -1)
            {
                return(wrapLog($"edition {edition} not found", null));
            }

            subPath  = subPath.Substring(firstSlash + 1);
            testPath = Helpers.LinkPaths.ToAbsolute($"{root}/{edition}/", subPath);
            if (File.Exists(Helpers.ServerPaths.FullAppPath(testPath)))
            {
                view.Edition = edition;
                return(wrapLog($"edition {edition} up one path", testPath));
            }

            return(wrapLog($"edition {edition} never found", null));
        }
示例#4
0
        private string TryToFindPolymorphPath(string root, IView view, string subPath)
        {
            var wrapLog   = Log.Call <string>($"{root}, {subPath}");
            var polymorph = new Polymorphism.Polymorphism(BlockBuilder.App.Data, Log);
            var edition   = polymorph.Edition();

            if (edition == null)
            {
                return(wrapLog("no edition detected", null));
            }
            Log.Add($"edition {edition} detected");

            var testPath = VirtualPathUtility.Combine($"{root}/{edition}/", subPath);

            if (File.Exists(HostingEnvironment.MapPath(testPath)))
            {
                view.Edition = edition;
                return(wrapLog($"edition {edition}", testPath));
            }

            Log.Add("tried inserting path, will check if sub-path");
            var firstSlash = subPath.IndexOf('/');

            if (firstSlash == -1)
            {
                return(wrapLog($"edition {edition} not found", null));
            }

            subPath  = subPath.Substring(firstSlash + 1);
            testPath = VirtualPathUtility.Combine($"{root}/{edition}/", subPath);
            if (File.Exists(HostingEnvironment.MapPath(testPath)))
            {
                view.Edition = edition;
                return(wrapLog($"edition {edition} up one path", testPath));
            }

            return(wrapLog($"edition {edition} never found", null));
        }