Пример #1
0
        private Identity ReadId(string name)
        {
            var value = ReadAttribute(name);

            if (value.IndexOf(':') > 0)
            {
                return(Identity.Parse(value));
            }
            return(_domain.CreateId(value));
        }
Пример #2
0
        private void PopulateLibraryDomain(IDomainModel domain)
        {
            // All changes must be include in a session
            using (var session = store.BeginSession())
            {
                // Forcing the id is optional by necessary for the synchronization sample
                Library      = new Library(id: domain.CreateId("0")); // Force an unique id
                Library.Name = "The shop around the corner";
                session.AcceptChanges();
            }

            // Add some books
            Parallel.For(0, 10, i =>
            {
                using (var session = store.BeginSession())
                {
                    var book    = new Book(id: domain.CreateId("B" + i.ToString()));
                    book.Copies = i + 1;
                    book.Author = "Author " + i.ToString();
                    book.Title  = "Book " + i.ToString();
                    Library.Books.Add(book);
                    session.AcceptChanges();
                }
            });

            // And some members
            Parallel.For(0, 10, i =>
            {
                using (var session = store.BeginSession())
                {
                    var member  = new Member(id: domain.CreateId("M" + i.ToString()));
                    member.Name = "Member " + i.ToString();
                    Library.Members.Add(member);
                    session.AcceptChanges();
                }
            });
        }
        private void PopulateLibraryDomain(IDomainModel domain)
        {
            // All changes must be include in a session
            using (var session = store.BeginSession())
            {
                // Forcing the id is optional by necessary for the synchronization sample
                Library = new Library(id:domain.CreateId("0")); // Force an unique id
                Library.Name = "The shop around the corner";
                session.AcceptChanges();
            }

            // Add some books
            Parallel.For(0, 10, i =>
            {
                using (var session = store.BeginSession())
                {
                    var book = new Book(id: domain.CreateId("B" + i.ToString()));
                    book.Copies = i + 1;
                    book.Author = "Author " + i.ToString();
                    book.Title = "Book " + i.ToString();
                    Library.Books.Add(book);
                    session.AcceptChanges();
                }
            });

            // And some members
            Parallel.For(0, 10, i =>
            {
                using (var session = store.BeginSession())
                {
                    var member = new Member(id: domain.CreateId("M" + i.ToString()));
                    member.Name = "Member " + i.ToString();
                    Library.Members.Add(member);
                    session.AcceptChanges();
                }
            });
        }