static void Main(string[] args) { Console.WriteLine("Starting..."); var w = Stopwatch.StartNew(); var dir = args[0]; var users = new UserReader(dir).ReadAll(); var groups = new GroupReader(dir).ReadAll(); var memberships = new MembershipReader(dir).ReadAll(); var scores = new CommunityScoreReader(dir).ReadAll(); var valuations = new SemesterValuationReader(dir).ReadAllIntoList(); new MembershipConnector(memberships, groups, users).Connect(); new CommunitiyScoreConnector(scores, users).Connect(); new SemesterValuationConnector(valuations, users, groups).Connect(); List <INode> allNodes = new List <INode>(); allNodes.AddRange(users.Values.Select(e => e.Entity)); allNodes.AddRange(groups.Values.Select(e => e.Entity)); allNodes.AddRange(memberships.Values.Select(e => e.Entity)); allNodes.AddRange(scores.Values.Select(e => e.Entity)); allNodes.AddRange(valuations.Select(e => e.Entity)); ModelXmlSerializer s = new ModelXmlSerializer(new VirEntityFactory(), new ContextFactory()); using (var modelWriter = XmlWriter.Create("model.xml")) { s.Serialize(modelWriter, new Model(allNodes)); } w.Stop(); Console.WriteLine("Elapsed: {0} sec", w.ElapsedMilliseconds / 1000.0); Console.ReadKey(); }
private XDocument SaveModel() { Node n1 = EntityHelper.CreateNode(), n2 = EntityHelper.CreateNode(); n1.ConnectTo(n2, Interfaces.EdgeDirection.Both); Model m = new Model(new Node[] { n1, n2 }); MemoryStream target = new MemoryStream(); using (var w = XmlWriter.Create(target)) { serializer.Serialize(w, m); } target.Seek(0, SeekOrigin.Begin); var doc = XDocument.Load(target); return(doc); }
public void ModelXmlSerializer_SerializeOf() { // Arrange var modelSerializer = new ModelXmlSerializer(); var modelToSerialize = new ModelToSerialize() { Name = "Name", Surname = "Surname" }; var expectedSerialization = "<?xml version=\"1.0\" encoding=\"utf-8\"?><ModelToSerialize xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Name>Name</Name><Surname>Surname</Surname></ModelToSerialize>"; //Act var response = modelSerializer.Serialize <ModelToSerialize>(modelToSerialize); //Assert Assert.NotNull(response); Assert.Equal(expectedSerialization, response); }