-
-
Save Dzoukr/dd9f54974dd4e3fddac5ec2fb976db01 to your computer and use it in GitHub Desktop.
Imperative vs Declarative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static Maybe<string> TryGetErrorMessage(XElement html) | |
{ | |
return html.GetElementsByClassName("ErrorMessage").MaybeFirst(). | |
Where(x => !x.Attributes("style").Any() | |
|| !x.Attribute("style").Value.Contains("visibility:hidden")). | |
Or(html.GetElementsByClassName("ErrorText").MaybeFirst()). | |
Select(x => x.Value.Trim()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static string TryGetErrorMessage(XElement html) | |
{ | |
var errMessage = html.GetElementsByClassName("ErrorMessage").FirstOrDefault(); | |
var errText = html.GetElementsByClassName("ErrorText").FirstOrDefault(); | |
var errorMessage = String.Empty; | |
if (errMessage != null && (!errMessage.Attributes("style").Any() || (errMessage.Attributes("style").Any() && errMessage.Attributes("style").First().Value != "visibility:hidden;"))) | |
errorMessage = errMessage.Value.Trim(); | |
if (errText != null) | |
errorMessage = errText.Value.Trim(); | |
return errorMessage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment