示例#1
0
        private SourceFileSet FindSourceFileSet(string file, bool createIfMissing)
        {
            // Find the SourceFileSet that has a given file...
            SourceFileSet sourceFileSet = this.sourceFileSets.FirstOrDefault(set => set.HasSourceFile(file));

            if (sourceFileSet == null && createIfMissing)
            {
                // The crazy try/catch/try/finally is to keep StyleCop from thinking we're going to missing
                // calling Dispose on an exception.
                sourceFileSet = new SourceFileSet(file);
                try
                {
                    sourceFileSet.AddSourceFiles(this.GetContextFiles(file));
                    this.sourceFileSets.Add(sourceFileSet);

                    sourceFileSet.SetClosed       += SourceFileSet_SetClosed;
                    sourceFileSet.CompileComplete += SourceFileSet_CompileComplete;
                }
                catch (Exception)
                {
                    try
                    {
                        sourceFileSet.SetClosed       -= SourceFileSet_SetClosed;
                        sourceFileSet.CompileComplete -= SourceFileSet_CompileComplete;
                        this.sourceFileSets.Remove(sourceFileSet);
                    }
                    finally
                    {
                        sourceFileSet.Dispose();
                    }
                }
            }

            return(sourceFileSet);
        }
示例#2
0
        void SourceFileSet_SetClosed(object sender, EventArgs e)
        {
            SourceFileSet sourceFileSet = sender as SourceFileSet;

            sourceFileSet.SetClosed       -= SourceFileSet_SetClosed;
            sourceFileSet.CompileComplete -= SourceFileSet_CompileComplete;
            this.sourceFileSets.Remove(sourceFileSet);
            sourceFileSet.Dispose();
            this.UpdateErrorList();
        }