Beispiel #1
0
        public void Initialize()
        {
            SchemaFacade.InitSchemata();
            descriptions.Clear();
            hiddens.Clear();
            describedMarkers.Clear();

            descriptions.Add(CommonSchema.DescriptionMarker.Id);
            hiddens.Add(CommonSchema.DescriptionMarker.Id);

            IThingGraph markerGraph = new ThingGraph();
            var         markers     = Markers();

            GraphExtensions.MergeInto(Schema.IdentityGraph, markerGraph);
            ThingGraph.DeepCopy(markers, markerGraph);
            markerGraph.DeepCopy(markers, ThingGraph);

            foreach (var marker in markerGraph)
            {
                var markerId = marker.Id;
                foreach (var link in markerGraph.Edges(marker))
                {
                    if (link.Marker == null)
                    {
                        continue;
                    }

                    var idLink = (ILink <Id>)link;

                    if (ViewMetaSchemaHideEnabled &&
                        idLink.Marker == ViewMetaSchema.Hide.Id &&
                        idLink.Leaf == markerId)
                    {
                        hiddens.Add(markerId);
                    }

                    if (idLink.Marker == MetaSchema.DescriptionMarker.Id)
                    {
                        if (idLink.Leaf == markerId)
                        {
                            hiddens.Add(markerId);
                            descriptions.Add(markerId);
                        }
                        else
                        {
                            describedMarkers[markerId] = idLink.Leaf;
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public IThingGraph Use(IThingGraph source, IThingGraph sink)
        {
            Action <IThing> message  = null;
            var             i        = 0;
            var             iStreams = 0;
            var             count    = source.Count;
            bool            streams  = false;

            if (this.Progress != null)
            {
                message = thing => {
                    i++;
                    if (thing != null)
                    {
                        var type = thing.GetType();
                        if (!streams && Reflector.Implements(type, typeof(IStreamThing)))
                        {
                            iStreams++;
                        }
                        var icount = streams ? count : count + iStreams;
                        this.Progress(string.Format("merging {2} of {3} ({4} Streams / {1} {0} )", thing.Id.ToString("X"),
                                                    streams ? "Streams" : type.Name, i, icount, iStreams), i, icount);
                    }
                }
            }
            ;

            GraphExtensions.MergeInto(source, sink, message, thing => {
                var existing = sink.GetById(thing.Id);
                if (existing == null)
                {
                    sink.Add(thing);
                }
                else
                {
                    sink.UniqueThing(thing);
                }
                var streamThing = thing as IStreamThing;
                if (streamThing != null)
                {
                    var data = source.ContentContainer.GetById(thing.Id);
                    sink.ContentContainer.Add(data);
                }
            });

            return(sink);
        }