Microsoft.SourceBrowser.BuildLogParser.LogAnalyzer.ProcessCopyingFileFrom C# (CSharp) Method

ProcessCopyingFileFrom() private method

private ProcessCopyingFileFrom ( string line ) : bool
line string
return bool
        private bool ProcessCopyingFileFrom(string line)
        {
            if (line.Contains("Copying file from \"") || line.Contains("Moving file from \""))
            {
                int from = line.IndexOf("\"") + 1;
                int to = line.IndexOf("\" to \"");
                string intermediateAssemblyPath = line.Substring(from, to - from);
                if (intermediateAssemblyPath.Contains(".."))
                {
                    intermediateAssemblyPath = Path.GetFullPath(intermediateAssemblyPath);
                }

                string outputAssemblyPath = line.Substring(to + 6, line.Length - to - 8);

                if (!outputAssemblyPath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) &&
                    !outputAssemblyPath.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) &&
                    !outputAssemblyPath.EndsWith(".netmodule", StringComparison.OrdinalIgnoreCase))
                {
                    // not even an assembly, we don't care about it
                    return true;
                }

                var assemblyName = Path.GetFileNameWithoutExtension(outputAssemblyPath);

                if ((outputAssemblyPath.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) ||
                    outputAssemblyPath.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) ||
                    outputAssemblyPath.EndsWith(".module", StringComparison.OrdinalIgnoreCase) ||
                    outputAssemblyPath.EndsWith(".netmodule", StringComparison.OrdinalIgnoreCase)) &&
                    !outputAssemblyPath.EndsWith(".resources.dll", StringComparison.OrdinalIgnoreCase) &&
                    !outputAssemblyPath.EndsWith(".XmlSerializers.dll", StringComparison.OrdinalIgnoreCase))
                {
                    int tempPlacingIndex = intermediateAssemblyPath.IndexOf(@"\\TempPlacing");
                    if (tempPlacingIndex > -1)
                    {
                        intermediateAssemblyPath = intermediateAssemblyPath.Remove(tempPlacingIndex, 13);
                    }

                    intermediateAssemblyPath = intermediateAssemblyPath.Replace(@"\\", @"\");
                    lock (this.intermediateAssemblyPathToOutputAssemblyPathMap)
                    {
                        string existing;
                        if (!this.intermediateAssemblyPathToOutputAssemblyPathMap.TryGetValue(intermediateAssemblyPath, out existing))
                        {
                            this.intermediateAssemblyPathToOutputAssemblyPathMap[intermediateAssemblyPath] = outputAssemblyPath;
                        }
                        else if (!string.Equals(existing, outputAssemblyPath))
                        {
                            List<string> bucket;
                            if (!ambiguousFinalDestinations.TryGetValue(assemblyName, out bucket))
                            {
                                bucket = new List<string>();
                                ambiguousFinalDestinations.Add(assemblyName, bucket);
                                bucket.Add(existing);
                            }

                            bucket.Add(outputAssemblyPath);

                            if (outputAssemblyPath.Length < existing.Length)
                            {
                                this.intermediateAssemblyPathToOutputAssemblyPathMap[intermediateAssemblyPath] = outputAssemblyPath;
                            }
                        }
                    }
                }

                return true;
            }

            return false;
        }