当前位置: 首页>>代码示例>>C#>>正文


C# TabInfo.Clone方法代码示例

本文整理汇总了C#中DotNetNuke.Entities.Tabs.TabInfo.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# TabInfo.Clone方法的具体用法?C# TabInfo.Clone怎么用?C# TabInfo.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotNetNuke.Entities.Tabs.TabInfo的用法示例。


在下文中一共展示了TabInfo.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateLocalizedCopy

        /// <summary>
        /// Creates the localized copy.
        /// </summary>
        /// <param name="originalTab">The original tab.</param>
        /// <param name="locale">The locale.</param>
        /// <param name="clearCache">Clear the cache?</param>
        public void CreateLocalizedCopy(TabInfo originalTab, Locale locale, bool clearCache)
        {
            try
            {
                Logger.TraceFormat("Localizing TabId: {0}, TabPath: {1}, Locale: {2}",originalTab.TabID,originalTab.TabPath,locale.Code);
                var defaultLocale = LocaleController.Instance.GetDefaultLocale(originalTab.PortalID);

                //First Clone the Tab
                TabInfo localizedCopy = originalTab.Clone();
                localizedCopy.TabID = Null.NullInteger;

                //Set Guids and Culture Code
                localizedCopy.UniqueId = Guid.NewGuid();
                localizedCopy.VersionGuid = Guid.NewGuid();
                localizedCopy.LocalizedVersionGuid = Guid.NewGuid();
                localizedCopy.CultureCode = locale.Code;
                localizedCopy.TabName = localizedCopy.TabName + " (" + locale.Code + ")";                    
                if (locale == defaultLocale)
                {
                    originalTab.DefaultLanguageGuid = localizedCopy.UniqueId;
                    UpdateTab(originalTab);
                }
                else
                {
                    localizedCopy.DefaultLanguageGuid = originalTab.UniqueId;                   
                }

                //Copy Permissions from original Tab for Admins only
                var portalCtrl = new PortalController();
                PortalInfo portal = portalCtrl.GetPortal(originalTab.PortalID);
                localizedCopy.TabPermissions.AddRange(
                    originalTab.TabPermissions.Where(p => p.RoleID == portal.AdministratorRoleId));

                //Get the original Tabs Parent
                //check the original whether have parent.
                if (!Null.IsNull(originalTab.ParentId))
                {
                    TabInfo originalParent = GetTab(originalTab.ParentId, originalTab.PortalID, false);

                    if (originalParent != null)
                    {
                        //Get the localized parent
                        TabInfo localizedParent = GetTabByCulture(originalParent.TabID, originalParent.PortalID, locale);

                        localizedCopy.ParentId = localizedParent.TabID;
                    }
                }

                //Save Tab
                AddTabInternal(localizedCopy, -1, -1, true);

                //Make shallow copies of all modules
                var moduleCtrl = new ModuleController();
                moduleCtrl.CopyModules(originalTab, localizedCopy, true);

                //Convert these shallow copies to deep copies
                foreach (KeyValuePair<int, ModuleInfo> kvp in moduleCtrl.GetTabModules(localizedCopy.TabID))
                {
                    moduleCtrl.LocalizeModule(kvp.Value, locale);
                }

                //Add Translator Role
                GiveTranslatorRoleEditRights(localizedCopy, null);
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                throw;
            }

            //Clear the Cache
            if (clearCache)
                ClearCache(originalTab.PortalID);
        }
开发者ID:ryanmalone,项目名称:BGDNNWEB,代码行数:80,代码来源:TabController.cs


注:本文中的DotNetNuke.Entities.Tabs.TabInfo.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。