/// <summary>
        /// Handles the CheckAvailability event of the cpCreateContract control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="ea">The <see cref="DevExpress.CodeRush.Core.CheckContentAvailabilityEventArgs"/> instance containing the event data.</param>
        private void CheckAvailability(object sender, CheckContentAvailabilityEventArgs ea)
        {
            // Must be in an interface.
            this.activeInterface = ea.ClassInterfaceOrStruct as Interface;
            if (this.activeInterface == null || ea.Caret.Line != this.activeInterface.Range.Start.Line)
            {
                return;
            }

            // This object will provide assertions that statically provided services are not null.
            // If required services are null, an exception is thrown here by design.
            this.codeRushProxy = new CodeRushProxy();
            string filePath = this.codeRushProxy.Source.ActiveSourceFile.FilePath;

            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            this.interfaceFilePath = filePath;

            SourceFile fileNode = this.activeInterface.FileNode;

            if (fileNode == null)
            {
                return;
            }

            this.interfaceSourceFile = fileNode;

            string interfaceName = this.activeInterface.Name;

            if (string.IsNullOrEmpty(interfaceName))
            {
                return;
            }

            this.interfaceName = interfaceName;

            // Must not already have the ContractClassAttribute
            ea.Available = this.activeInterface.AttributeSections == null ||
                           !(from AttributeSection section in this.activeInterface.AttributeSections
                             from DevExpress.CodeRush.StructuralParser.Attribute attribute in section.AttributeCollection
                             where attribute.Name == ContractClassAttributeName
                             select attribute).Any();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ContractClassBuilder"/> class.
        /// </summary>
        /// <param name="interfaceUpdater">The interface updater.</param>
        /// <param name="codeRushProxy">The code rush proxy.</param>
        public ContractClassBuilder(InterfaceUpdater interfaceUpdater, CodeRushProxy codeRushProxy)
        {
            if (interfaceUpdater == null)
            {
                throw new ArgumentNullException(message: "interfaceUpdater is null.", paramName: "interfaceUpdater");
            }

            if (codeRushProxy == null)
            {
                throw new ArgumentNullException("codeRushProxy", "codeRushProxy is null.");
            }

            Contract.EndContractBlock();

            this.ContractClassName = interfaceUpdater.CreateContractClassName();
            this.interfaceUpdater  = interfaceUpdater;
            this.CodeRushProxy     = codeRushProxy;
        }
    /// <summary>
    /// Initializes a new instance of the <see cref="ContractClassBuilder"/> class.
    /// </summary>
    /// <param name="interfaceUpdater">The interface updater.</param>
    /// <param name="codeRushProxy">The code rush proxy.</param>
    public ContractClassBuilder(InterfaceUpdater interfaceUpdater, CodeRushProxy codeRushProxy)
    {
      if (interfaceUpdater == null)
      {
        throw new ArgumentNullException(message: "interfaceUpdater is null.", paramName: "interfaceUpdater");
      }

      if (codeRushProxy == null)
      {
        throw new ArgumentNullException("codeRushProxy", "codeRushProxy is null.");
      }

      Contract.EndContractBlock();

      this.ContractClassName = interfaceUpdater.CreateContractClassName();
      this.interfaceUpdater = interfaceUpdater;
      this.CodeRushProxy = codeRushProxy;
    }
    /// <summary>
    /// Handles the CheckAvailability event of the cpCreateContract control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="ea">The <see cref="DevExpress.CodeRush.Core.CheckContentAvailabilityEventArgs"/> instance containing the event data.</param>
    private void CheckAvailability(object sender, CheckContentAvailabilityEventArgs ea)
    {
      // Must be in an interface.
      this.activeInterface = ea.ClassInterfaceOrStruct as Interface;
      if (this.activeInterface == null || ea.Caret.Line != this.activeInterface.Range.Start.Line)
      {
        return;
      }

      // This object will provide assertions that statically provided services are not null.  
      // If required services are null, an exception is thrown here by design.
      this.codeRushProxy = new CodeRushProxy();
      string filePath = this.codeRushProxy.Source.ActiveSourceFile.FilePath;
      if (string.IsNullOrEmpty(filePath))
      {
        return;
      }

      this.interfaceFilePath = filePath;

      SourceFile fileNode = this.activeInterface.FileNode;
      if (fileNode == null)
      {
        return;
      }

      this.interfaceSourceFile = fileNode;

      string interfaceName = this.activeInterface.Name;
      if (string.IsNullOrEmpty(interfaceName))
      {
        return;
      }
      
      this.interfaceName = interfaceName;

      // Must not already have the ContractClassAttribute
      ea.Available = this.activeInterface.AttributeSections == null ||
        !(from AttributeSection section in this.activeInterface.AttributeSections
          from DevExpress.CodeRush.StructuralParser.Attribute attribute in section.AttributeCollection
          where attribute.Name == ContractClassAttributeName
          select attribute).Any();
    }