public void TestTryGetInt() { int result; Assert.IsTrue(ValueUtility.TryGetInt("12", out result)); Assert.AreEqual(12, result); Assert.IsFalse(ValueUtility.TryGetInt("", out result)); Assert.IsFalse(ValueUtility.TryGetInt("1.2", out result)); Assert.IsFalse(ValueUtility.TryGetInt("A", out result)); }
protected override int GetFileSize(XmlElement source) { var value = source.GetAttribute("ows_FileSizeDisplay"); int result; if (!string.IsNullOrEmpty(value) && ValueUtility.TryGetInt(value, out result)) { return(result); } value = source.GetAttribute("ows_File_x0020_Size"); return(string.IsNullOrEmpty(value) ? 0 : ValueUtility.GetInt(ValueUtility.GetLookupValue(value))); }