KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In our SharePoint/ASP.NET environment we have a series of data retriever classes that all derive from a common interface. I was assigned the task of creating a data retriever that could communicate remotely with other SharePoint farms using WCF. The way I have it implemented at the moment is a singleton ChannelFactory<T> is created in a static constructor and then reused by each instance of the remote data retriever to create an individual proxy instance. I figured that this would work well because then the ChannelFactory only gets instantiated once in an app domain and its creation is guaranteed to be thread-safe . My code looks something like this: public class RemoteDataRetriever : IDataRetriever { protected static readonly ChannelFactory<IRemoteDataProvider> RequestChannelFactory; protected IRemoteDataProvider _channel; static RemoteDataRetriever() { WSHttpBinding binding = new WSHttpBinding( SecurityMode.TransportWithMessageCredential, true); binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows; RequestChannelFactory = new ChannelFactory<IRemoteDataProvider>(binding); } public RemoteDataRetriever(string endpointAddress) { _channel = RemoteDataRetriever.RequestChannelFactory. CreateChannel(new EndpointAddress(endpointAddress)); } } My question is, is this a good design? I figured that once the ChannelFactory is created I don't need to worry about thread-safety because I'm merely using it to call CreateChannel() but am I mistaken? Is it changing state or otherwise doing something funky behind the scenes that could cau
Tags (comma-separated)
Save Edits
Cancel