// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.AspNet.Mvc.Razor
{
///
/// An entry in that contain metadata about precompiled and dynamically compiled file.
///
public class CompilerCacheEntry
{
///
/// Initializes a new instance of for a file that was precompiled.
///
/// Metadata about the precompiled file.
/// The compiled .
public CompilerCacheEntry([NotNull] RazorFileInfo info, [NotNull] Type compiledType)
{
CompiledType = compiledType;
RelativePath = info.RelativePath;
Length = info.Length;
LastModified = info.LastModified;
Hash = info.Hash;
}
///
/// Initializes a new instance of for a file that was dynamically compiled.
///
/// Metadata about the file that was compiled.
/// The compiled .
public CompilerCacheEntry([NotNull] RelativeFileInfo info, [NotNull] Type compiledType)
{
CompiledType = compiledType;
RelativePath = info.RelativePath;
Length = info.FileInfo.Length;
LastModified = info.FileInfo.LastModified;
}
///
/// Gets the produced as a result of compilation.
///
public Type CompiledType { get; private set; }
///
/// Gets the path of the compiled file relative to the root of the application.
///
public string RelativePath { get; private set; }
///
/// Gets the size of file (in bytes) on disk.
///
public long Length { get; private set; }
///
/// Gets the last modified for the file that was compiled at the time of compilation.
///
public DateTime LastModified { get; private set; }
///
/// Gets the file hash, should only be available for pre compiled files.
///
public string Hash { get; private set; }
///
/// Gets a flag that indicates if the file is precompiled.
///
public bool IsPreCompiled { get { return Hash != null; } }
}
}