Example #1
0
        private bool AddSubgraphsAsNeeded(MainGraphExportContext mainExportContext,
                                          IGraphElement element, AttributeType attrType, Object value, StreamWriter writer)
        {
            if (!GRSExport.IsGraphUsedInAttribute(attrType))
            {
                return(false);
            }

            if (value == null)
            {
                return(false);
            }

            if (!(value is INamedGraph))
            {
                return(false);
            }

            bool wasAdded = GRSExport.AddSubgraphAsNeeded(mainExportContext, (INamedGraph)value);

            if (wasAdded)
            {
restart:
                foreach (KeyValuePair <string, GraphExportContext> kvp in mainExportContext.nameToContext)
                {
                    GraphExportContext context = kvp.Value;
                    if (!context.isExported)
                    {
                        wasAdded = GRSExport.ExportSingleGraph(mainExportContext, context, writer);
                        if (wasAdded)
                        {
                            goto restart;
                        }
                    }
                }
                AddGraphAttributes(mainExportContext, writer);
                writer.WriteLine("in \"" + mainExportContext.graphToContext[graph].name + "\" # after emitting new subgraph for attribute");
                return(true);
            }
            return(false);
        }
Example #2
0
        private static bool AddSubgraphsAsNeeded(INamedGraph potentialNewGraph, RecordingState recordingState)
        {
            bool wasAdded = GRSExport.AddSubgraphAsNeeded(recordingState.mainExportContext, potentialNewGraph);

            if (wasAdded)
            {
restart:
                foreach (KeyValuePair <string, GraphExportContext> kvp in recordingState.mainExportContext.nameToContext)
                {
                    GraphExportContext context = kvp.Value;
                    if (!context.isExported)
                    {
                        wasAdded = GRSExport.ExportSingleGraph(recordingState.mainExportContext, context, recordingState.writer);
                        if (wasAdded)
                        {
                            goto restart;
                        }
                    }
                }
                AddGraphAttributes(recordingState.mainExportContext, recordingState.writer);
                return(true);
            }
            return(false);
        }