示例#1
0
        public void ThingIdSerializerTest()
        {
            IThingGraph graph = new ThingGraph();
            IThing      thing = factory.CreateItem();

            graph.Add(thing);
            graph.Add(factory.CreateItem());

            ThingXmlIdSerializer serializer = new ThingXmlIdSerializer();

            serializer.Graph  = graph;
            serializer.Things = graph;

            foreach (IThing t in graph)
            {
                Assert.IsTrue(serializer.Things.Contains(t));
            }

            Stream s = new MemoryStream();

            serializer.Write(s);
            s.Position = 0;

            serializer       = new ThingXmlIdSerializer();
            serializer.Graph = graph;
            serializer.Read(s);
            foreach (IThing t in graph)
            {
                Assert.IsTrue(serializer.Things.Contains(t));
            }
        }
示例#2
0
        /// <summary>
        /// returns all things of source
        /// extract all things of source stored in a sheet
        /// and returns them
        /// </summary>
        /// <param name="sourceView"></param>
        /// <param name="sink"></param>
        public virtual IEnumerable <IThing> ExpandThings(IThingGraph thingGraph, IEnumerable <IThing> source)
        {
            var result = new Stack <IThing>(source);

            while (result.Count > 0)
            {
                var thing = result.Pop();
                yield return(thing);

                var streamThing = thing as IStreamThing;
                if (streamThing != null && streamThing.StreamType == ContentTypes.LimadaSheet)
                {
                    var ser = new ThingXmlIdSerializer();
                    ser.Graph = thingGraph;

                    streamThing.DeCompress();

                    ser.Read(streamThing.Data);

                    streamThing.ClearRealSubject();
                    ser.Things.ForEach(t => result.Push(t));
                }
            }
        }