Beispiel #1
0
        /// <summary>
        /// creates a visual, backed by a
        /// StreamThing, created and assigned with content
        /// </summary>
        /// <param name="graph"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public virtual IVisual VisualOfContent(IGraph <IVisual, IVisualEdge> graph, Content <Stream> content)
        {
            if (content == null)
            {
                return(null);
            }

            IVisual result      = null;
            var     sourceGraph = graph.Source <IVisual, IVisualEdge, IThing, ILink>();

            if (sourceGraph != null)
            {
                var    thingGraph = graph.ThingGraph();
                var    factory    = graph.ThingFactory();
                IThing thing      = null;
                if (content.Data != null)
                {
                    thing = new ThingContentFacade(factory).AssignContent(thingGraph, null, content);
                }
                else
                {
                    thing = factory.CreateItem(content.Description);
                    thingGraph.Add(thing);
                }

                result = sourceGraph.Get(thing);
            }
            return(result);
        }
        public virtual void Test()
        {
            ReportDetail("ThingContentFacade");
            var graph = this.Graph;
            var thingContentFacade = new ThingContentFacade();

            var thing = thingContentFacade.CreateAndAdd(
                graph, new Content <Stream>(stream, CompressionType.None));

                        #if !__ANDROID__
            Assert.IsInstanceOf(typeof(Thing), thing);
                        #else
                        #endif
            Assert.AreEqual(((IThing <Stream>)thing).Data.Length, stream.Length);
        }
Beispiel #3
0
        public bool SaveStreamInGraph(Stream source, IGraph <IVisual, IVisualEdge> target, SceneInfo info)
        {
            var thingGraph = GetThingGraph(target);
            var thing      = GetSheetThing(thingGraph, info.Id) as IStreamThing;

            var content = new Content <Stream> (source, CompressionType.bZip2, ContentTypes.LimadaSheet)
            {
                Description = info.Name
            };

            if (thing is IStreamThing || thing == null)
            {
                var factory = target.ThingFactory();
                var result  = new ThingContentFacade(factory).AssignContent(thingGraph, thing, content) != null;
                info.State.Hollow = false;
                info.State.Clean  = true;
                return(result);
            }

            return(false);
        }