示例#1
0
        //public static string ReplaceStlUserEntitiesByApiControllers(string content)
        //{
        //    var parsedBuilder = new StringBuilder(content);
        //    var stlEntityList = StlParserUtility.GetStlUserEntityList(parsedBuilder.ToString());

        //    var pageInfo = new PageInfo();

        //    foreach (var stlEntity in stlEntityList)
        //    {
        //        var startIndex = parsedBuilder.ToString().IndexOf(stlEntity, StringComparison.Ordinal);
        //        if (startIndex == -1) continue;
        //        var entityType = EStlEntityTypeUtils.GetEntityType(stlEntity);
        //        if (entityType != EStlEntityType.User) continue;
        //        var resultContent = StlUserEntities.Parse(stlEntity, null);
        //        parsedBuilder.Replace(stlEntity, resultContent, startIndex, stlEntity.Length);
        //    }
        //    return parsedBuilder.ToString();
        //}

        internal static string ParseStlEntity(string stlEntity, PageInfo pageInfo, ContextInfo contextInfo)
        {
            var parsedContent = string.Empty;

            var entityType = EStlEntityTypeUtils.GetEntityType(stlEntity);

            if (entityType == EStlEntityType.Stl)
            {
                parsedContent = StlStlEntities.Parse(stlEntity, pageInfo, contextInfo);
            }
            else if (entityType == EStlEntityType.StlElement)
            {
                parsedContent = StlElementEntities.Parse(stlEntity, pageInfo, contextInfo);
            }
            else if (entityType == EStlEntityType.Content)
            {
                parsedContent = StlContentEntities.Parse(stlEntity, pageInfo, contextInfo);
            }
            else if (entityType == EStlEntityType.Channel)
            {
                parsedContent = StlChannelEntities.Parse(stlEntity, pageInfo, contextInfo);
            }
            else if (entityType == EStlEntityType.Photo)
            {
                parsedContent = StlPhotoEntities.Parse(stlEntity, pageInfo, contextInfo);
            }
            else if (entityType == EStlEntityType.Comment)
            {
                parsedContent = StlCommentEntities.Parse(stlEntity, pageInfo, contextInfo);
            }
            else if (entityType == EStlEntityType.Request)
            {
                parsedContent = StlRequestEntities.Parse(stlEntity, pageInfo, contextInfo);
            }
            else if (entityType == EStlEntityType.Navigation)
            {
                parsedContent = StlNavigationEntities.Parse(stlEntity, pageInfo, contextInfo);
            }
            else if (entityType == EStlEntityType.Sql)
            {
                parsedContent = StlSqlEntities.Parse(stlEntity, pageInfo, contextInfo);
            }
            else if (entityType == EStlEntityType.User)
            {
                parsedContent = StlUserEntities.Parse(stlEntity, pageInfo);
            }

            return(parsedContent);
        }
示例#2
0
        public async Task <string> ParseStlEntityAsync(string stlEntity)
        {
            var parsedContent = string.Empty;

            var entityType = GetEntityType(stlEntity);

            if (entityType == StlEntityType.Stl)
            {
                parsedContent = await StlStlEntities.ParseAsync(stlEntity, this);
            }
            else if (entityType == StlEntityType.StlElement)
            {
                parsedContent = await StlElementEntities.ParseAsync(stlEntity, this);
            }
            else if (entityType == StlEntityType.Content)
            {
                parsedContent = await StlContentEntities.ParseAsync(stlEntity, this);
            }
            else if (entityType == StlEntityType.Channel)
            {
                parsedContent = await StlChannelEntities.ParseAsync(stlEntity, this);
            }
            else if (entityType == StlEntityType.Request)
            {
                parsedContent = await StlRequestEntities.ParseAsync(stlEntity, this);
            }
            else if (entityType == StlEntityType.Navigation)
            {
                parsedContent = await StlNavigationEntities.ParseAsync(stlEntity, this);
            }
            else if (entityType == StlEntityType.Sql)
            {
                parsedContent = StlSqlEntities.Parse(stlEntity, this);
            }
            else if (entityType == StlEntityType.User)
            {
                parsedContent = StlUserEntities.Parse(stlEntity, this);
            }

            return(parsedContent);
        }