﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Configuration.CodeSubDirectory
// Assembly: System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 7E68A73E-4066-4F24-AB0A-F147209F50EC
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Web.dll

using System.ComponentModel;
using System.Configuration;
using System.Runtime;
using System.Web;
using System.Web.Compilation;
using System.Web.Hosting;
using System.Web.UI;
using System.Web.Util;

namespace System.Web.Configuration
{
  /// <summary>
  /// References a directory location that is used during compilation of a dynamic resource. This class cannot be inherited.
  /// </summary>
  public sealed class CodeSubDirectory : ConfigurationElement
  {
    private static readonly ConfigurationProperty _propDirectoryName = new ConfigurationProperty("directoryName", typeof (string), (object) null, StdValidatorsAndConverters.WhiteSpaceTrimStringConverter, StdValidatorsAndConverters.NonEmptyStringValidator, ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
    private static ConfigurationPropertyCollection _properties = new ConfigurationPropertyCollection();
    private const string dirNameAttribName = "directoryName";

    protected override ConfigurationPropertyCollection Properties
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return CodeSubDirectory._properties;
      }
    }

    /// <summary>
    /// Gets or sets the name of the directory that contains files compiled at run time.
    /// </summary>
    /// 
    /// <returns>
    /// A string value specifying the name of the directory reference used during compilation.
    /// </returns>
    [TypeConverter(typeof (WhiteSpaceTrimStringConverter))]
    [ConfigurationProperty("directoryName", DefaultValue = "", IsKey = true, IsRequired = true)]
    public string DirectoryName
    {
      get
      {
        return (string) this[CodeSubDirectory._propDirectoryName];
      }
      set
      {
        this[CodeSubDirectory._propDirectoryName] = (object) value;
      }
    }

    internal string AssemblyName
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this.DirectoryName;
      }
    }

    static CodeSubDirectory()
    {
      CodeSubDirectory._properties.Add(CodeSubDirectory._propDirectoryName);
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    internal CodeSubDirectory()
    {
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="T:System.Web.Configuration.CodeSubDirectory"/> class.
    /// </summary>
    /// <param name="directoryName">A string value specifying the <see cref="T:System.Web.Configuration.CodeSubDirectory"/> reference.</param>
    public CodeSubDirectory(string directoryName)
    {
      this.DirectoryName = directoryName;
    }

    internal void DoRuntimeValidation()
    {
      string directoryName = this.DirectoryName;
      if (BuildManager.IsPrecompiledApp)
        return;
      if (!Util.IsValidFileName(directoryName))
        throw new ConfigurationErrorsException(System.Web.SR.GetString("Invalid_CodeSubDirectory", new object[1]
        {
          (object) directoryName
        }), this.ElementInformation.Properties["directoryName"].Source, this.ElementInformation.Properties["directoryName"].LineNumber);
      VirtualPath virtualDir = HttpRuntime.CodeDirectoryVirtualPath.SimpleCombineWithDir(directoryName);
      if (!VirtualPathProvider.DirectoryExistsNoThrow(virtualDir))
        throw new ConfigurationErrorsException(System.Web.SR.GetString("Invalid_CodeSubDirectory_Not_Exist", new object[1]
        {
          (object) virtualDir
        }), this.ElementInformation.Properties["directoryName"].Source, this.ElementInformation.Properties["directoryName"].LineNumber);
      FindFileData data;
      FindFileData.FindFile(virtualDir.MapPathInternal(), out data);
      if (!System.Web.Util.StringUtil.EqualsIgnoreCase(directoryName, data.FileNameLong))
        throw new ConfigurationErrorsException(System.Web.SR.GetString("Invalid_CodeSubDirectory", new object[1]
        {
          (object) directoryName
        }), this.ElementInformation.Properties["directoryName"].Source, this.ElementInformation.Properties["directoryName"].LineNumber);
      if (BuildManager.IsReservedAssemblyName(directoryName))
        throw new ConfigurationErrorsException(System.Web.SR.GetString("Reserved_AssemblyName", new object[1]
        {
          (object) directoryName
        }), this.ElementInformation.Properties["directoryName"].Source, this.ElementInformation.Properties["directoryName"].LineNumber);
    }
  }
}
