Ejemplo n.º 1
0
 private void WriteAttribute(KeyValuePair <string, object> a)
 {
     _buffer.Append(a.Key);
     _buffer.Append(EQ);
     _buffer.Append(DotLanguageUtils.GetAttributeString(a.Key, a.Value));
     _buffer.Append(ATTRDELIMITER);
 }
Ejemplo n.º 2
0
 private void CorrectClusterCodes()
 {
     foreach (var c in EnumerateSubGraphs())
     {
         c.Code = DotLanguageUtils.GetClusterCode(c.Code);
     }
     foreach (var n in EnumerateNodes().Where(_ => !string.IsNullOrWhiteSpace(_.SubgraphCode)))
     {
         n.SubgraphCode = DotLanguageUtils.GetClusterCode(n.SubgraphCode);
     }
 }
Ejemplo n.º 3
0
 private void WriteGraphAttributes(SubGraph graph)
 {
     foreach (var a in graph.Attributes)
     {
         WriteLevel();
         _buffer.Append(a.Key);
         _buffer.Append(EQ);
         _buffer.Append(DotLanguageUtils.GetAttributeString(a.Key, a.Value));
         _buffer.Append(LINECLOSER);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public SubGraph ResolveSubgraph(string code)
        {
            var __code = DotLanguageUtils.GetClusterCode(code);

            if (Code == __code)
            {
                return(this);
            }
            var result = SubGraphs.Select(sg => sg.ResolveSubgraph(__code)).FirstOrDefault(_ => null != _);

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Метод резолюции узлов
        /// </summary>
        /// <param name="code"></param>
        /// <param name="cached"></param>
        /// <returns></returns>
        public Node ResolveNode(string code, bool cached = true)
        {
            if (null != Parent)
            {
                return(Parent.ResolveNode(code));
            }
            var __code = DotLanguageUtils.EscapeCode(code);

            if (cached && _nodeResolutionCache.ContainsKey(__code))
            {
                return(_nodeResolutionCache[__code]);
            }

            var resolved = EnumerateNodes().FirstOrDefault(_ => _.Code == __code);

            if (cached && null != resolved)
            {
                _nodeResolutionCache[__code] = resolved;
            }
            return(resolved);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Метод резолюции узлов
        /// </summary>
        /// <returns></returns>
        public Edge[] ResolveEdges(string from, string to, bool cached = true)
        {
            if (null != Parent)
            {
                return(Parent.ResolveEdges(from, to));
            }
            var __from = DotLanguageUtils.EscapeCode(from);
            var __to   = DotLanguageUtils.EscapeCode(to);
            var key    = from + "->" + to;

            if (cached && _edgeResolutionCache.ContainsKey(key))
            {
                return(_edgeResolutionCache[key]);
            }
            var resolved = EnumerateEdges().Where(_ => _.From == __from && _.To == __to).ToArray();

            if (cached)
            {
                _edgeResolutionCache[key] = resolved;
            }
            return(resolved);
        }