Пример #1
0
        private PageComponentDto CreatePageComponentDto(PageComponentBase component)
        {
            PageComponentDto dto = new PageComponentDto();

            dto.Id         = component.Id;
            dto.Name       = component.Name;
            dto.Sign       = component.Sign;
            dto.ParentSign = component.ParentSign;
            dto.OS         = component.ComponentOSType.OS;
            dto.PageComponentBaseSetting = _objectMapper.Map <PageComponentBaseSettingDto>(component.PageComponentBaseSetting);
            dto.PageComponentSettings    = new List <PageComponentSettingDto>();

            foreach (var item in component.PageComponentSettings)
            {
                PageComponentSettingDto pageComponentSetting = new PageComponentSettingDto()
                {
                    Id          = item.Id,
                    Name        = item.Name,
                    DisplayName = item.DisplayName,
                    SingleDatas = _objectMapper.Map <List <SingleSettingDataDto> >(item.SingleDatas)
                };

                dto.PageComponentSettings.Add(pageComponentSetting);
            }

            if (component is CompositeComponent)
            {
                dto.SetCompositeComponentType();
            }
            else if (component is PageLeafComponent)
            {
                var pageLeafComponent = (PageLeafComponent)component;
                dto.PageLeafSetting = _objectMapper.Map <PageLeafSettingDto>(pageLeafComponent.PageLeafSetting);

                dto.SetPageLeafComponentType();
            }
            else if (component is MenuComponent)
            {
                dto.MenuName = ((MenuComponent)component).MenuName;

                dto.SetMenuComponentType();
            }
            else
            {
                dto.SetLeafComponentType();
            }

            return(dto);
        }
        private PageComponentDto CreatePageComponentDto(PageComponentBase page)
        {
            PageComponentDto dto = new PageComponentDto();

            dto.Name       = page.Name;
            dto.Sign       = page.Sign;
            dto.ParentSign = page.ParentSign;
            dto.PageComponentBaseSetting = _objectMapper.Map <PageComponentBaseSettingDto>(page.PageComponentBaseSetting);
            dto.PageComponentSettings    = new List <PageComponentSettingDto>();

            foreach (var item in page.PageComponentSettings)
            {
                PageComponentSettingDto pageComponentSetting = new PageComponentSettingDto()
                {
                    Name        = item.Name,
                    DisplayName = item.DisplayName,
                    Field1      = item.Field1,
                    Field2      = item.Field2,
                    Field3      = item.Field3,
                    Field4      = item.Field4,
                    Field5      = item.Field5
                };

                dto.PageComponentSettings.Add(pageComponentSetting);
            }

            if (page is CompositeComponent)
            {
                dto.ComponentType = "CompositeComponent";
            }
            else if (page is PageLeafComponent)
            {
                var pageLeafComponent = (PageLeafComponent)page;

                dto.TargetPageId  = pageLeafComponent.TargetPageId;
                dto.ComponentType = "PageLeafComponent";
            }
            else
            {
                dto.ComponentType = "LeafComponent";
            }

            return(dto);
        }