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


C# Topic.Save方法代码示例

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


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

示例1: Save

        /*==========================================================================================================================
        | METHOD: SAVE
        \-------------------------------------------------------------------------------------------------------------------------*/
        /// <summary>
        ///   Will save any topic and, optionally, its children.
        /// </summary>
        /// <remarks>
        ///   <para>
        ///     In addition to acting as a pass-through for <see cref="Topic.Save(bool, bool)"/>, this also ensures that a) the 
        ///     topic is saved twice (to account for serialized topic references, such as <c>ParentId</c>), and b) the <see 
        ///     cref="ContentTypes"/> collection is first synchronized with the <see cref="TopicRepository"/>, and then the 
        ///     TopicRepository state is restored to its original.
        ///   </para>
        ///   <para>
        ///     The one dependency that remains on the TopicRepository is in the Save() method, which relies on it as a centralized
        ///     source for attribute metadata - and, specifically, whether an attribute should be indexed or not.To mitigate this,
        ///     this method will ensure all local content types are saved to the TopicRepository.
        ///   </para>
        /// </remarks>
        /// <note>
        ///   IMPORTANT: If a <see cref="ContentType"/> with the same key exists, it will be overwritten. This ensures any
        ///   attributes added via the configuration scripts are reflected in the database. It also means, however, that the
        ///   TopicRepository's <see cref="TopicRepository.ContentTypes"/> collection will be orphaned from the TopicRepository's
        ///   configuration namespace. For that reason, the ContentTypes collection must be reset after a Save();
        /// </note>
        /// <param name="topic">The topic object.</param>
        /// <param name="isRecursive">
        ///   Boolean indicator nothing whether to recurse through the topic's descendants and save them as well.
        /// </param>
        /// <param name="isDraft">Boolean indicator as to the topic's publishing status.</param>
        void Save(Topic topic, bool isRecursive = false, bool isDraft = false)
        {
            /*------------------------------------------------------------------------------------------------------------------------
              | Validate input
              \-----------------------------------------------------------------------------------------------------------------------*/
              Contract.Requires<ArgumentNullException>(topic != null, "The topic must be specified.");

              /*------------------------------------------------------------------------------------------------------------------------
              | Ensure TopicRepository references the local instances of the ContentTypes
              \-----------------------------------------------------------------------------------------------------------------------*/
              TopicRepository.ContentTypes = ContentTypes;

              /*------------------------------------------------------------------------------------------------------------------------
              | Save new configuration
              \-----------------------------------------------------------------------------------------------------------------------*/
              topic.Save(isRecursive, isDraft);

              /*------------------------------------------------------------------------------------------------------------------------
              | Update Derived Topic references to ensure any newly assigned IDs are available
              \-----------------------------------------------------------------------------------------------------------------------*/
              UpdateDerivedTopics(topic, isRecursive);

              /*------------------------------------------------------------------------------------------------------------------------
              | Update TopicID references
              \-----------------------------------------------------------------------------------------------------------------------*/
              topic.Save(isRecursive, isDraft);

              /*------------------------------------------------------------------------------------------------------------------------
              | Reset the TopicRepository's ContentType's cache so it isn't orphaned from the TopicRepository's configuration
              \-----------------------------------------------------------------------------------------------------------------------*/
              TopicRepository.ContentTypes = null;
        }
开发者ID:Ignia,项目名称:Topics-Library,代码行数:62,代码来源:TopicsSetup.cs


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