Ejemplo n.º 1
0
            public static SourceIndex Parse(string text)
            {
                SourceIndex sourceIndex = new SourceIndex();

                string[] parts = text.Split('*');
                string multiplier = (parts.Length > 1) ? parts[0].Trim() : "1";
                string channelIndex = (parts.Length > 1) ? parts[1].Trim() : parts[0].Trim();

                if (parts.Length > 2)
                    throw new FormatException($"Too many asterisks found in source index {text}.");

                if (!double.TryParse(multiplier, out sourceIndex.Multiplier))
                    throw new FormatException($"Incorrect format for multiplier {multiplier} found in source index {text}.");

                if (channelIndex == "NONE")
                    return null;

                if (!int.TryParse(channelIndex, out sourceIndex.ChannelIndex))
                    throw new FormatException($"Incorrect format for channel index {channelIndex} found in source index {text}.");

                if (channelIndex[0] == '-')
                {
                    sourceIndex.Multiplier *= -1.0D;
                    sourceIndex.ChannelIndex *= -1;
                }

                return sourceIndex;
            }
Ejemplo n.º 2
0
        Graph(Vertex <V>[] vertices, Edge <V>[] edges)
        {
            this.vertices = vertices;
            this.edges    = edges;

            for (var i = 0; i < edges.Length; i++)
            {
                var edge = edges[i];
                if (SourceIndex.TryGetValue(edge.Source, out List <V> targets))
                {
                    targets.Add(edge.Target);
                }
                else
                {
                    SourceIndex[edge.Source] = list(edge.Target);
                }

                if (TargetIndex.TryGetValue(edge.Target, out List <V> sources))
                {
                    sources.Add(edge.Source);
                }
                else
                {
                    TargetIndex[edge.Target] = list(edge.Source);
                }
            }
        }
Ejemplo n.º 3
0
 public override string ToString()
 {
     return(string.Format("{0} (Dest: {1},Source: {2}) {3}",
                          Status.ToString(),
                          DestIndex.ToString(),
                          SourceIndex.ToString(),
                          _length.ToString()));
 }
Ejemplo n.º 4
0
        public override int GetHashCode()
        {
            int code = 23;

            code = code * 31 + SourceIndex.GetHashCode();
            code = code * 31 + TargetIndex.GetHashCode();
            return(code);
        }
Ejemplo n.º 5
0
        public int CompareTo(AlignmentLink other)
        {
            int c1 = SourceIndex.CompareTo(other.SourceIndex);

            if (c1 != 0)
            {
                return(c1);
            }
            return(TargetIndex.CompareTo(other.TargetIndex));
        }
Ejemplo n.º 6
0
        public override int GetHashCode()
        {
#if NETCOREAPP
            return(HashCode.Combine(SourceIndex, Type));
#else
            var hashCode = 17;
            hashCode = hashCode * 31 + SourceIndex.GetHashCode();
            hashCode = hashCode * 31 + Type.GetHashCode();
            return(hashCode);
#endif
        }
Ejemplo n.º 7
0
        public override string ToString()
        {
            if (IsNullMove)
            {
                return("NULL_MOVE");
            }

            return(!string.IsNullOrEmpty(SAN)
                ? SAN
                : $"{SourceIndex.ToSquareString()}->{DestinationIndex.ToSquareString()}");
        }
Ejemplo n.º 8
0
 public IReadOnlyList <V> Sources(V target)
 {
     if (SourceIndex.TryGetValue(target, out List <V> sources))
     {
         return(sources);
     }
     else
     {
         return(EmptyList);
     }
 }
Ejemplo n.º 9
0
        /// <inheritdoc />
        public override bool Equals(object obj)
        {
            if (base.Equals(obj))
            {
                return(true);
            }

            MemoryIndexDataSource other = obj as MemoryIndexDataSource;

            if (other != null)
            {
                return(SourceIndex.Equals(other.SourceIndex) && SourceSnapshot.Equals(other.SourceSnapshot));
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 10
0
 public GamaError(string msg, ParserRuleContext rule, params object[] format)
 {
     Message = string.Format(msg, format);
     At      = new SourceIndex(rule.Start);
 }
Ejemplo n.º 11
0
 public GamaError(string msg, SourceIndex at, params object[] format)
 {
     Message = string.Format(msg, format);
     At      = at;
 }
Ejemplo n.º 12
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     return(SourceIndex.GetHashCode() ^ SourceSnapshot.GetHashCode());
 }
Ejemplo n.º 13
0
    private static void BuildPages(Arguments arguments, Site site, MarkdownPipeline pipeline)
    {
        var allResources = CollectPages(site);

        PageResourcesPostProcessors.Process(allResources, site);
        var allBuiltResources = new HashSet <string>();

        arguments.VerboseLog($"{allResources.Count} total un-processed pages");

        int builtPages = 0, skippedPages = 0, ignoredPages = 0;

        while (allBuiltResources.Count != allResources.Count)
        {
            int prevBuilt = allBuiltResources.Count;
            foreach ((string path, PageResource resource) in allResources)
            {
                // Do not re-build already built content
                if (allBuiltResources.Contains(path))
                {
                    continue;
                }

                // If this page has something un-built embedded in it then we cannot safely build it.
                if (!resource.Embedded?.IsSubsetOf(allBuiltResources) ?? false)
                {
                    continue;
                }

                // If the resource isn't in the site, and isn't embedded into anything, we can skip building it entirely.
                if (resource.Location == ResourceLocation.Embed && (resource.EmbeddedInto?.Count ?? 0) == 0)
                {
                    arguments.VerboseLog($"\"{resource.FullPath}\" is not used.");
                    resource.SetHtmlTextAsEmpty();
                    allBuiltResources.Add(path);
                    continue;
                }

                try
                {
                    resource.BuildText(site, allResources, pipeline);
                }
                catch (Exception e)
                {
                    throw new BuildException(e, $"{resource.FullPath} failed to build text.");
                }

                allBuiltResources.Add(path);
                switch (resource.WriteToDisk(arguments, site))
                {
                case PageResource.WriteStatus.Ignored:
                    ignoredPages++;
                    break;

                case PageResource.WriteStatus.Skipped:
                    skippedPages++;
                    break;

                case PageResource.WriteStatus.Written:
                    builtPages++;
                    break;
                }
            }

            if (prevBuilt == allBuiltResources.Count)
            {
                throw new BuildException("Build has soft-locked - infinite loop due to recursive embedding?");
            }
        }

        arguments.VerboseLog($"{builtPages} pages written to disk. {skippedPages} were skipped as identical, and {ignoredPages} were embeds.");

        SourceIndex.GeneratePageSourceLookup(arguments, allResources);
    }
 public override string ToString()
 {
     return(SourceTable + "." + SourceColumn + "[" + SourceIndex.ToString() + "] => " + DestTable + "." + DestColumn + "[" + DestIndex.ToString() + "]");
 }