예제 #1
0
        public static ServiceDocument ToServiceDocument(IEnumerable<string> userStreams, 
                                                        IEnumerable<string> systemStreams,
                                                        IPEndPoint httpEndPoint)
        {
            if (userStreams == null || systemStreams == null || httpEndPoint == null)
                return null;

            var document = new ServiceDocument();

            var userWorkspace = new WorkspaceElement();
            userWorkspace.SetTitle("User event streams");

            var systemWorkspace = new WorkspaceElement();
            systemWorkspace.SetTitle("System event streams");

            foreach (var userStream in userStreams)
            {
                var collection = new CollectionElement();

                collection.SetTitle(userStream);
                collection.SetUri(httpEndPoint.ToHttpUrl("/streams/{0}", userStream));

                collection.AddAcceptType(ContentType.Xml);
                collection.AddAcceptType(ContentType.Atom);
                collection.AddAcceptType(ContentType.Json);
                collection.AddAcceptType(ContentType.AtomJson);

                userWorkspace.AddCollection(collection);
            }

            foreach (var systemStream in systemStreams)
            {
                var collection = new CollectionElement();

                collection.SetTitle(systemStream);
                collection.SetUri(httpEndPoint.ToHttpUrl("/streams/{0}", systemStream));

                collection.AddAcceptType(ContentType.Xml);
                collection.AddAcceptType(ContentType.Atom);
                collection.AddAcceptType(ContentType.Json);
                collection.AddAcceptType(ContentType.AtomJson);

                systemWorkspace.AddCollection(collection);
            }

            document.AddWorkspace(userWorkspace);
            document.AddWorkspace(systemWorkspace);

            return document;
        }
예제 #2
0
        public static ServiceDocument ToServiceDocument(IEnumerable<string> userStreams, IEnumerable<string> systemStreams, string userHostName)
        {
            if (userStreams == null || systemStreams == null || userHostName == null)
                return null;

            var document = new ServiceDocument();

            var userWorkspace = new WorkspaceElement();
            userWorkspace.SetTitle("User event streams");

            var systemWorkspace = new WorkspaceElement();
            systemWorkspace.SetTitle("System event streams");

            foreach (var userStream in userStreams)
            {
                var collection = new CollectionElement();

                collection.SetTitle(userStream);
                collection.SetUri(HostName.Combine(userHostName, "/streams/{0}", Uri.EscapeDataString(userStream)));

                collection.AddAcceptType(ContentType.Xml);
                collection.AddAcceptType(ContentType.Atom);
                collection.AddAcceptType(ContentType.Json);
                collection.AddAcceptType(ContentType.AtomJson);

                userWorkspace.AddCollection(collection);
            }

            foreach (var systemStream in systemStreams)
            {
                var collection = new CollectionElement();

                collection.SetTitle(systemStream);
                collection.SetUri(HostName.Combine(userHostName, "/streams/{0}", Uri.EscapeDataString(systemStream)));

                collection.AddAcceptType(ContentType.Xml);
                collection.AddAcceptType(ContentType.Atom);
                collection.AddAcceptType(ContentType.Json);
                collection.AddAcceptType(ContentType.AtomJson);

                systemWorkspace.AddCollection(collection);
            }

            document.AddWorkspace(userWorkspace);
            document.AddWorkspace(systemWorkspace);

            return document;
        }
예제 #3
0
 public void SetUp()
 {
     _writer = XmlWriter.Create(new MemoryStream());
     _collection = new CollectionElement();
 }
예제 #4
0
 public void AddCollection(CollectionElement collection)
 {
     Ensure.NotNull(collection, "collection");
     Collections.Add(collection);
 }
예제 #5
0
 public void AddCollection(CollectionElement collection)
 {
     Ensure.NotNull(collection, "collection");
     Collections.Add(collection);
 }