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
class genericObjectCompareClass : IEqualityComparer<objectType> | |
{ | |
#region IEqualityComparer<objectType> Members | |
public bool Equals(Object1 x, Object2 y) | |
{ | |
return x.Attribute1.Equals(y.Attribute1); | |
} | |
public int GetHashCode(vipFlip obj) |
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
private DateTime RoundUp(DateTime dt, TimeSpan d) | |
{ | |
return new DateTime(((dt.Ticks + d.Ticks - 1) / d.Ticks) * d.Ticks); | |
} |
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
//parse the XML, might as well use Xpath to avoid dupe root nodes.... ughhhhh | |
System.Xml.XPath.XPathDocument xmlResults = new System.Xml.XPath.XPathDocument(customObjectThatHasXmlData.Data.InnerXml.ToString()); | |
System.Xml.XPath.XPathNavigator xmlResultsNav = xmlResults.CreateNavigator(); | |
System.Xml.XPath.XPathExpression xmlResultsExpression; | |
xmlResultsExpression = xmlResultsNav.Compile(@"/Data/result xmlns=""/time_stamp"); //in this case was trying to get the Tstamp | |
System.Xml.XPath.XPathNodeIterator xmlResultsNavIterator = xmlResultsNav.Select(xmlResultsExpression); | |
while(xmlResultsNavIterator.MoveNext()) | |
{ |
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
private static void datatableEnforceNulls(DataTable resultTable) | |
{ | |
List<string> removeList = new List<string>(); | |
foreach (DataColumn column in resultTable.Columns) | |
{ | |
if (resultTable.Rows.OfType<DataRow>().All(r => r.IsNull(column))) | |
{ |
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
private string ConvertDatabaseToXML(DataTable dt) | |
{ | |
System.IO.MemoryStream memory = new System.IO.MemoryStream(); | |
dt.WriteXml(memory, true); | |
memory.Seek(0, System.IO.SeekOrigin.Begin); | |
System.IO.StreamReader memReader = new System.IO.StreamReader(memory); | |
string xmlResults; | |
xmlResults = memReader.ReadToEnd(); | |
return xmlResults; |
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
public static ValidationResult ContainsUrl(string sampleStr) | |
{ | |
if(Uri.IsWellFormedUriString(sampleStr, UriKind.Absolute)) | |
{ | |
return new ValidationResult("Message Contains a URL."); | |
} | |
Regex urlRx = new Regex(@"(?<url>(http:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)", RegexOptions.IgnoreCase); | |
MatchCollection matches = urlRx.Matches(sampleStr); |
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
public static ValidationResult ContainsSpecChar(string sampleStr) | |
{ | |
Regex specChar = new Regex(@"[^A-Za-z0-9!?.&,\ -]", RegexOptions.IgnorePatternWhitespace); | |
MatchCollection matches = specChar.Matches(sampleStr); | |
if (matches.Count > 0) | |
{ | |
return new ValidationResult("Message cannot contain special characters."); | |
} | |
return ValidationResult.Success; |
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
public static ValidationResult EscapedAmpersand(string sampleStr) | |
{ | |
Regex specChar = new Regex(@"&(?!(?:apos|quot|[A-Za-z0-1!?.,\ -]|amp);|#)", RegexOptions.IgnoreCase); | |
MatchCollection matches = specChar.Matches(sampleStr); | |
if (matches.Count > 0) | |
{ | |
return new ValidationResult("Message cannot contain special characters."); | |
} | |
return ValidationResult.Success; |