Home > Net >  How to turn A method in A code, split into two methods B and C??????
How to turn A method in A code, split into two methods B and C??????

Time:11-10

Turn to the great god
I have a Case, it is necessary to read. A method of cs file and will MethodA according to certain logical split into MethodB and MethodC respectively;
Currently using StreamReader. ReadLine () on. Cs file line by line to read; And reads the stored in each row of MethodA List ;
Please give some advice, how to make difference? Probably is completed (true... ) related code extracted into the MethodC, the rest of the completed (false... ) related in MethodB inside!



 private void MethodA (Dictionary Param, Action Completed) 
{
String ababab=string. The Empty;

Bool checkResult param of===null? False: param. Count & gt; 0? True, false;

Dictionary CommonParam=new Dictionary (a);

if (null !=param & amp; & Param. Values. The Count!=0 & amp; & Param. Either ContainsKey (" isAutoFreshFlag "))
{
CommonParam. Add (" isAutoFreshFlag ", true);
}

If (checkResult)
{
CommonParam. Add (" Test ", "Content");
Completed (true, commonParam);
}
The else
{
Completed, false, null);
}
}

Private bool MethodB (Dictionary Param)
{
String ababab=string. The Empty;

Bool checkResult param of===null? False: param. Count & gt; 0? True, false;

If (checkResult)
{
}
The else
{
return false;
}

//if (! CheckResult)
//{
//return false.
//}

return true;
}

Private Dictionary MethodC (Dictionary Param)
{
Dictionary CommonParam=new Dictionary (a);

if (null !=param & amp; & Param. Values. The Count!=0 & amp; & Param. Either ContainsKey (" isAutoFreshFlag "))
{
CommonParam. Add (" isAutoFreshFlag ", true);
}
CommonParam. Add (" Test ", "Content");

Return commonParam;
}

CodePudding user response:

to a great god did advise bai ~ I not understand - -,

CodePudding user response:

Bring two copies of A code (red circle part) encapsulated into two methods, call the corresponding method B and C, respectively,

CodePudding user response:

Using the CodeDOM | Microsoft Docs
https://docs.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/using-the-codedom

CodePudding user response:

refer to the second floor qybao response:
put A two copies of the code (red circle) encapsulated into two methods, call the corresponding method B and C, respectively,


Yeah ~
But the problem is how to put the red box in front of the code out ah, MethodA is from my cs line after line of read file; Line 1-23 I read stored in List The inside;
Actually the function of I actually want to do is, copy a. Cs file, the file inside a MethodA method, I have in the process of copying to MethodA into MethodB and MethodC;

CodePudding user response:

Is this code generation? Unknown folded,
Well, it seems that could not be addressed using simple matching, upstairs said CodeDOM seems quite reasonable, you can refer to reference,
  •  Tags:  
  • C#
  • Related