Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
124 | Developer’s <strong>Guide</strong> <strong>EPiServer</strong> Community 3.1<br />
In order to make <strong>EPiServer</strong> Community aware of this new type so instances of the type can be returned, we need to<br />
create an EntityProvider.This is done by creating a new class, implementing IEntityProvider in the StarSuite.Core.Data<br />
namespace.<br />
using System.Collections.Generic;<br />
using StarSuite.Core.Data;<br />
using StarCommunity.Modules.Blog;<br />
using StarCommunity.Modules.ImageGallery;<br />
namespace MyCommunity<br />
{<br />
//Implement the IEntityProvider interface<br />
public class MyEntryCommentEntityProvider :<br />
StarSuite.Core.Data.IEntityProvider<br />
{<br />
private static MyEntryCommentEntityProvider m_myEntryCommentEntityProvider =<br />
null;<br />
();<br />
//Singleton<br />
public static StarSuite.Core.Data.IEntityProvider GetProviderInstance()<br />
{<br />
if (m_myEntryCommentEntityProvider == null)<br />
m_myEntryCommentEntityProvider = new MyEntryCommentEntityProvider<br />
}<br />
return m_myEntryCommentEntityProvider;<br />
// Override the GetEntityInstance by reader method<br />
public object GetEntityInstance(Type type, DbDataReader reader)<br />
{<br />
//If the specified type is EntryComment or MyEntryComment, call<br />
//MyEntryComment constructor that will just pass the reader<br />
argument to<br />
//its base class<br />
if (type == typeof(EntryComment) || type == typeOf(MyEntryComment)<br />
return new MeEntryComment(reader);<br />
}<br />
// Override the GetEntityInstance by id method<br />
public object GetEntityInstance(Type type, int id)<br />
{<br />
//If the specified type is EntryComment or MyEntryComment, just get<br />
//EntryComment by id via BlogHandler<br />
if (type == typeof(EntryComment) || type == typeOf(MyEntryComment)<br />
return BlogHandler.GetEntryComment(id);<br />
}<br />
}<br />
}<br />
© <strong>EPiServer</strong> AB