public Research Find(str path) { if (!str.IsNullOrEmpty(path)) { return(Find(path.ToString())); } return(null); }
public static Item Find(str path) { if (!str.IsNullOrEmpty(path)) { return(Find(path.ToString())); } return(null); }
// Used to extract last portion of a string which can be split using given separator // (e.g. "/Script/FactoryGame.FGInventoryComponent" -> "FGInventoryComponent") public static string LastName(this str name, char separator = '.') { if (str.IsNullOrEmpty(name)) { return(null); } return(LastName(name.ToString(), separator)); }
public Schematic Find(str path) { if (!str.IsNullOrEmpty(path)) { return(Find(path.ToString())); } return(null); }
public static BitmapSource GetImage(str object_name, int desired_resolution, VersionTable.Version version) { if (object_name == null) { return(null); } return(GetImage(object_name.ToString(), desired_resolution, version)); }
// Tries to get .Name from property passed, or null if property has no such value public static string GetName(this P.Property prop) { if (prop is P.ValueProperty) { str s = (prop as P.ValueProperty).Name; if (s != null) { return(s.ToString()); } } return(null); }
// Find a value property by name public static P.Property Named(this P.Properties props, string name, int index = -1) { if (index < 0) { int pos = name.IndexOf('#'); if (pos > 0) { string idx = name.Substring(pos + 1); name = name.Substring(0, pos); if (!int.TryParse(idx, out index)) { return(null); } } } if (index >= 0) { return(props.FirstOrDefault(prop => { if (prop is P.ValueProperty) { P.ValueProperty val = prop as P.ValueProperty; str prop_name = val.Name; if (!str.IsNullOrEmpty(prop_name)) { return (val.Index == index) && (prop_name.ToString() == name); } } return false; })); } return(props.FirstOrDefault(prop => { if (prop is P.ValueProperty) { str prop_name = (prop as P.ValueProperty).Name; if (!str.IsNullOrEmpty(prop_name)) { return prop_name.ToString() == name; } } return false; })); }
public void BasicTest() { const string TestString = "test string"; str str1 = new str(TestString); // test constructor: Assert.AreEqual(str1.ToString(), TestString); // test directly assign string value str str2 = TestString; Assert.AreEqual(str2.ToString(), TestString); Assert.IsFalse(ReferenceEquals(str1, str2)); // test Equals Assert.IsTrue(str1.Equals(str2)); Assert.IsTrue(str1.Equals((object)str2)); // test == Assert.IsTrue(str1 == str2); // test != Assert.IsTrue(str1 != new str(TestString + " ")); // test + Assert.IsTrue(str1 + str1 == new str(TestString + TestString)); // test indexer Assert.AreEqual('e', str1[1]); str1[1] = 'E'; Assert.AreEqual(str1, "tEst string"); str1[1] = 'e'; // compare with built-in string Assert.IsTrue(str1.Equals(TestString)); }
// Find a property by it's path name public static P.Property FindByPathName(this P.Properties props, str pathname, bool case_insensitive = false) { return(props.FindByPathName(pathname.ToString(), case_insensitive)); }