Ejemplo n.º 1
0
        /// <summary>
        /// Gets information about an object in this repository.
        /// Will add missing source objects to the repository as needed.
        /// </summary>
        /// <param name="obj">The object to look up.</param>
        /// <returns>Information about the object.</returns>
        /// <remarks>
        /// Returns null if obj isn't in this run's cache.
        /// Cannot return value.disposition==Stale, I guess?
        /// </remarks>
        private RepositoryEntry GetValue(BuildObject obj)
        {
            if (this.entries.ContainsKey(obj))
            {
                return(this.entries[obj]);
            }
            else
            {
                SourcePath src = obj as SourcePath;
                if (src != null)
                {
                    // Special case to get local source files into the
                    // repository (and the item cache).
                    // REVIEW: Should we require that source files are explicitly added?
                    try
                    {
                        // Complain if someone uses tabs or non-CRLF line endings in a source file.
                        // Visual Studio is pretty insistent on using tabs in solution (.sln) files, so we let it.
                        if ((src.Type == SourcePath.SourceType.Src) && (src.getExtension() != ".sln"))
                        {
                            if (!Util.CheckSourceFileForBadCharacters(IronRootDirectory.PathTo(obj)))
                            {
                                throw new SourceConfigurationError("Bad characters (tabs?) or non-CRLF line endings in source file " + obj.getRelativePath());
                            }
                        }

                        string hash = Util.hashFilesystemPath(IronRootDirectory.PathTo(obj));
                        this.itemCache.StoreItemFromFile(ItemCacheContainer.Sources, hash, IronRootDirectory.PathTo(obj));
                        this.Add(obj, new Fresh(), hash, null);
                    }
                    catch (IOException)
                    {
                        throw new SourceConfigurationError("Cannot find source path " + obj.getRelativePath());
                    }

                    return(this.entries[obj]);
                }
                else
                {
                    return(null);
                }
            }
        }