Consult the following browser type parameter: the BrowserRunType is a judgment on current browser, using a binary expression, now want to add a browser type judgment, inside with the if an error, how to solve the problem?
Public override ApplicationMetaDataType ToAppMetaData (IUiObject control, RecordEventInfo recordInfo) { ApplicationMetaDataType appMd=new ApplicationMetaDataType () { ProcessName=control. CurrentProcess? ProcessName, BrowserRunType=this. CurrentBrowserType==BrowserType. Web360? AutomationImplData. WEB360: AutomationImplData. WEBFireFox }; } Public class ApplicationMetaDataType { Public ApplicationMetaDataType (); Public AutomationImplData BrowserRunType {get; set; } Public string ProcessName {get; set; } } CodePudding user response:
Don't understand what do you want to describe the problem, with the if and then an error? You also did not show up in the code
CodePudding user response:
reference 1/f, hands on the keyboard to knock very light response: don't understand what do you want to describe the problem, with the if and then an error? You also did not show up in the code Sorry, novice didn't fully clear, just want to ask BrowserRunType=this. CurrentBrowserType==BrowserType. Web360? AutomationImplData. WEB360: AutomationImplData. WEBFireFox This line is to use binary judgment, whether the current browser is 360, not just choose Firefox, now I have to add a Chrome, such as three possible will divide judging, here I do not know with what method to write, use the if, BrowserRunType shows cannot be placed in local CodePudding user response:
That you can write a method to judge alone Public static BrowserRunType GetType () { Var type=this. CurrentBrowserType; The if () { {} else if () } } CodePudding user response:
Can add a piece at the back up of BrowserRunType=this. CurrentBrowserType==BrowserType. Web360? AutomationImplData. WEB360: Enclosing currentBrowserType==BrowserType. WEBFireFox? AutomationImplData. WEBFireFox: AutomationImplData. Chrome CodePudding user response:
The reference 4 floor nan peony reply: go up in the back to add a piece of BrowserRunType=this. CurrentBrowserType==BrowserType. Web360? AutomationImplData. WEB360: Enclosing currentBrowserType==BrowserType. WEBFireFox? AutomationImplData. WEBFireFox: AutomationImplData. Chrome with this kind of writing, logic is no problem, it seems the new framework support judged by the switch, it may be a bit more intuitive CodePudding user response:
reference 5 floor weixin_43274436 reply: Quote: refer to 4th floor nan peony reply: can add a piece at the back up of BrowserRunType=this. CurrentBrowserType==BrowserType. Web360? AutomationImplData. WEB360: Enclosing currentBrowserType==BrowserType. WEBFireFox? AutomationImplData. WEBFireFox: AutomationImplData. Chrome with this kind of writing, logic is no problem, it seems the new framework support judged by the switch, it may be a bit more intuitive Can don't use any branch of a solution, really want to extend that it is better to use the strategy pattern