using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel;
using dasBlog.Storage;
using dasBlog.Storage.SqlServer;
using dasBlog.Storage.Ntfs;
namespace dasBlog.Services{
public class Host : CommunicationObject
{
Uri[] baseAddresses;
Dictionary<string, EndpointAddress> hostedServices = new Dictionary<string, EndpointAddress>();
public Host(params Uri[] baseAddresses)
{
this.baseAddresses = baseAddresses;
}
void RegisterHostedService(string name, EndpointAddress address )
{
hostedServices.Add(name, address);
}
public void CreateBlog(string blogScope)
{
IStorageNode textEntryNode = StorageNodeFactory.CreateStorageNode<TextEntryStorageProvider>();
IStorageNode streamNode = StorageNodeFactory.CreateStorageNode<StreamStorageProvider>(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ".\\content"));
CreateBlog(blogScope, textEntryNode, streamNode);
}
public void CreateBlog(string blogScope, IStorageNode textEntryNode, IStorageNode streamNode)
{
StorageBus bus = StorageBus.Current;
var posts = new NodeDescription(textEntryNode);
var pictures = new NodeDescription(streamNode);
var media = new NodeDescription(streamNode);
posts.Paths.Add(PathSegmentName.Comments, posts);
posts.Paths.Add(PathSegmentName.Annotations, posts);
posts.Paths.Add(PathSegmentName.Media, media);
posts.Paths.Add(PathSegmentName.Pictures, pictures);
pictures.Paths.Add(PathSegmentName.Comments, posts);
pictures.Paths.Add(PathSegmentName.Annotations, posts);
media.Paths.Add(PathSegmentName.Comments, posts);
media.Paths.Add(PathSegmentName.Annotations, posts);
ScopeDescription scope = new ScopeDescription(blogScope);
scope.Paths.Add(PathSegmentName.Posts, posts);
scope.Paths.Add(PathSegmentName.Pictures, pictures);
scope.Paths.Add(PathSegmentName.Media, media);
bus.AddStorageScope(scope);
}
public void CreateAlbum(string albumScope, IStorageNode textEntryNode, IStorageNode tagNode, IStorageNode streamNode)
{
StorageBus bus = StorageBus.Current;
var comments = new NodeDescription(textEntryNode);
var pictures = new NodeDescription(streamNode);
pictures.Paths.Add(PathSegmentName.Comments, comments);
pictures.Paths.Add(PathSegmentName.Annotations, comments);
ScopeDescription scope = new ScopeDescription(albumScope);
scope.Paths.Add(PathSegmentName.Pictures, pictures);
bus.AddStorageScope(scope);
}
protected override TimeSpan DefaultCloseTimeout
{
get { throw new NotImplementedException(); }
}
protected override TimeSpan DefaultOpenTimeout
{
get { throw new NotImplementedException(); }
}
protected override void OnAbort()
{
throw new NotImplementedException();
}
protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)
{
throw new NotImplementedException();
}
protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state)
{
throw new NotImplementedException();
}
protected override void OnClose(TimeSpan timeout)
{
throw new NotImplementedException();
}
protected override void OnEndClose(IAsyncResult result)
{
throw new NotImplementedException();
}
protected override void OnEndOpen(IAsyncResult result)
{
throw new NotImplementedException();
}
protected override void OnOpen(TimeSpan timeout)
{
throw new NotImplementedException();
}
}
}
|