c# - How can I clean up this ugly if statement? -


I have the following ugly statement that is part of a square that is drawn from the IOC container:

< Pre-> Protected Virtual Zero ExecuteSourceControlGet (IBILMMadata Build Metadata, IPCertTTTT) {If ((BuildmateDataDepository Elementalist! = Faucet) & amp; (BuildMetadata RepositoryArrayList.Count & gt; 0)} {componentTree.DeleteWorkingDirectory (); Forex (version repository element build metadata. Repository elementalist) {repositoryElement.PrepareRepository (get components, threads). Export (); }} If ((buildMetaData.ExportList! = Null) & amp; (Buildmetda.export list.account> 0)) {var initialise = true; Foreach (buildMetaData.ExportList in the above sourceControl) {log.InfoFormat ("\ nThere is a problem getting the horn {0} \ n \ n." .TowUpper (), sourceControl.Url); Get.from (sourceControl) .ExportTo (componentTree, sourceControl.ExportPath, initialize); Initialise = false; }} Log.InfoFormat ("\ \ horn is being brought {0}. \ N \ n" .upper (), buildMetaData.SourceControl.Url); Get.From (buildMetaData.SourceControl) .ExportTo (componentTree); }

If there is a subclass for every condition, then my general view of destroying it.

What's different about this example:

  1. The class in which this method has been drawn from the IOC container.
  2. If the statement is on or not, then I would like to argue between 2.

Any advice is very welcome.

about using two removal methods , and if revert To be a guard:

  Protected Virtual Zero ExecuteSourceControlGet (IBuildMetaData buildMetaData, IPackageTree componentTree) {ExecuteRepositoryElementList (buildMetaData.RepositoryElementList, componentTree); ExecuteExportList (BuildmateData.exportalist, componentTree); Log.InfoFormat ("\ \ horn is fetching {0}. \ N \ n" .upper (), buildMetaData.SourceControl.Url); Get.From (buildMetaData.SourceControl) .ExportTo (componentTree); } Private Zero ExecuteRepositoryElementList (RepositoryElementList repositoryElements, IPackageTree componentTree) {// Guard: No Elements if (repositoryElements == null} repositoryElements.Count == 0 Return; ComponentTree.DeleteWorkingDirectory (); Forrest (different repository elements in repository elements) {repositoryElement.PrepareRepository (get component, tree). Export (); }} Private Zero ExecuteExportList (ExportList exportList, IPackageTree componentTree) {// Guard: No Elements if (exportList == null} exportList.Count == 0 Return; Var initialise = true; Foreach (various source controls in the export source) {log. Informat ("\ nhunting the string {0}. \ N \ n" .User (source), source control. Url); Get.from (sourceControl) .ExportTo (componentTree, sourceControl.ExportPath, initialize); Initialise = false; }}  

BTW: Two methods must be fixed with the correct type IBuildMetaData.RepositoryElementList and IBuildMetaData.ExportList .


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -