/// <summary> /// Handles the Apply event of the cpCreateContract control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="ea">The <see cref="DevExpress.CodeRush.Core.ApplyContentEventArgs"/> instance containing the event data.</param> private void Apply(object sender, ApplyContentEventArgs ea) { // Must have cached instance of interface and interface declaration. if (this.activeInterface == null) { return; } if (ea.TextDocument == null) { return; } if (string.IsNullOrEmpty(this.interfaceFilePath)) { return; } if (this.interfaceSourceFile == null) { return; } if (this.codeRushProxy == null) { return; } if (this.cpCreateContract == null) { return; } if (string.IsNullOrEmpty(this.interfaceName)) { return; } var interfaceUpdater = new InterfaceUpdater( ea.TextDocument, this.activeInterface, this.interfaceSourceFile, this.interfaceFilePath, this.interfaceName); var contractClassBuilder = new ContractClassBuilder(interfaceUpdater, this.codeRushProxy); using (this.codeRushProxy.TextBuffers.NewMultiFileCompoundAction(this.cpCreateContract.ActionHintText)) { this.codeRushProxy.Markers.Drop(MarkerStyle.Standard); interfaceUpdater.UpdateInterface(); contractClassBuilder.CreateContractClassFile(); } }
/// <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; }