📄 guestbookdataprovider.cs
字号:
//------------------------------------------------------------------------------
// <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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -