guestbookdataprovider.cs

来自「本系统是在asp版《在线文件管理器》的基础上设计制作」· CS 代码 · 共 93 行

CS
93
字号
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Data;
using System.Collections;
using CommunityServer.Components;
using CommunityServer.Configuration;


namespace CommunityServer.GuestBooks.Components
{

	/// <summary>
	/// The DataProvider class contains a single method, Instance(), which returns an instance of the
	/// user-specified data provider class.
	/// </summary>
	/// <remarks>  The data provider class must inherit the GuestBookDataProvider
	/// interface.</remarks>
	public abstract class GuestBookDataProvider 
	{

		public static readonly string CommonDataProviderName = "GuestBookDataProvider";

		#region Instance

		private static GuestBookDataProvider _defaultInstance = null;

		static GuestBookDataProvider()
		{
			CreateDefaultCommonProvider();
		}

		/// <summary>
		/// Returns an instance of the user-specified data provider class.
		/// </summary>
		/// <returns>An instance of the user-specified data provider class.  This class must inherit the
		/// GuestBookDataProvider interface.</returns>
		public static GuestBookDataProvider Instance() 
		{
			return _defaultInstance;
		}

		public static GuestBookDataProvider Instance (Provider dataProvider) 
		{
			GuestBookDataProvider fdp = CSCache.Get(dataProvider.Name) as GuestBookDataProvider;
			if(fdp == null)
			{
				fdp = DataProviders.Invoke(dataProvider) as GuestBookDataProvider;
				CSCache.Max(dataProvider.Name,fdp);
			}
			return fdp;
		}

		/// <summary>
		/// Creates the Default GuestBookDataProvider
		/// </summary>
		private static void CreateDefaultCommonProvider()
		{
			// Get the names of the providers
			//
			CSConfiguration config = CSConfiguration.GetConfig();

			// Read the configuration specific information
			// for this provider
			//
			Provider sqlForumsProvider = (Provider) config.Providers[CommonDataProviderName];

			// Read the connection string for this provider
			//
            
			_defaultInstance = DataProviders.CreateInstance(sqlForumsProvider) as GuestBookDataProvider;
		}
        
		#endregion

		#region Books

		public abstract Book GetBook(int bookID, string appKey);

		#endregion

		public abstract int AddPost(GBPost post, User user);

		public abstract void DeletePost(int SectionID, int PostID);

		public abstract PostSet GetPosts(int SectionID, int PageIndex, int PageSize, bool sortByNewest);

	}
}

⌨️ 快捷键说明

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