⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 postview.cs

📁 community server 源码
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;using System.Web.UI;using CommunityServer.Components;
using CommunityServer.Discussions.Components;
using CommunityServer.Discussions.Controls.PostDisplay;namespace CommunityServer.Discussions.Controls 
{

    // *********************************************************************
    //  PostView
    //
    /// <summary>
    /// This server control is used to display a Post
    /// </summary>
    /// 
    // ********************************************************************/
    public class PostView : Control, INamingContainer 
    {
        ForumPost post;
		CSContext csContext = CSContext.Current;

        // *********************************************************************
        //  CreateChildControls
        //
        /// <summary>
        /// Initializes the user control loaded in CreateChildControls. Initialization
        /// consists of finding well known control names and wiring up any necessary events.
        /// </summary>
        /// 
        // ********************************************************************/ 
        protected override void CreateChildControls() 
        {
            TextPost textPost;

            // What kind of post are we working with (XML check is used to support pre-2.0 polls)
			if (this.Post.PostType == PostContentType.Xml)
			{
				PollPost pollPost = new PollPost(this.Post);

				if (csContext.User.IsAnonymous)
					pollPost.Enabled = false;
				else 
				{
					if (Permissions.ValidatePermissions(post.Section,Permission.Vote,csContext.User))
						pollPost.Enabled = true;
				}

				Controls.Add(pollPost);
			}
			else
			{
                textPost = new TextPost();
                textPost.Post = Post;
                Controls.Add(textPost);
            }

        }

        public ForumPost Post 
        {
            get 
            {
                if ( post == null ) 
                {
                    Object state = ViewState["Post"];
                    if ( state != null ) 
                    {
                        Int32 postID = (Int32)state;
                        post = Posts.GetPost( postID, csContext.User.UserID, false );
                    }
                }
                return post;
            }
            set 
            {
                post = value;
                if ( post != null ) 
                {
                    ViewState[ "Post" ] = post.PostID;
                } 
                else 
                {
                    ViewState.Remove( "Post" );
                }
            }
        }


    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -