/// <summary> /// Creates new value object initialized with provided string /// </summary> /// <returns> /// true if parse was succesful, false otherwise /// </returns> /// <param name='str'> /// value /// </param> /// <param name='retVal'> /// output value - initialized object, null if provided string was invalid /// </param> public static bool TryParse(string str, out PStorageRecordDescription retVal) { char [] delimiters = new char [] {'#'}; string [] words = str.Split(delimiters, 9); if (words.Length == 9) { try { Type ntype = (Type)int.Parse(words[1]); object nobject = null; switch (ntype) { case Type.INTEGER : nobject = int.Parse(words[8]); break; case Type.VECTOR3 : string [] nums = words[8].Split(','); nobject = new Vector3(int.Parse(nums[0]), int.Parse(nums[1]), int.Parse(nums[2])); break; case Type.STRING32 : nobject = words[8]; break; }; retVal = new PStorageRecordDescription(int.Parse(words[0]), ntype, int.Parse(words[2]), words[3], words[4], words[5], int.Parse(words[6]), int.Parse(words[7]), nobject); return true; } catch { retVal = null; return false; } } else { retVal = null; return false; } }
/// <summary> /// Creates new value object initialized with provided string /// </summary> /// <returns> /// true if parse was succesful, false otherwise /// </returns> /// <param name='str'> /// value /// </param> /// <param name='retVal'> /// output value - initialized object, null if provided string was invalid /// </param> public static bool TryParse(string str, out PStorageRecordDescription retVal) { char [] delimiters = new char [] { '#' }; string [] words = str.Split(delimiters, 9); if (words.Length == 9) { try { Type ntype = (Type)int.Parse(words[1]); object nobject = null; switch (ntype) { case Type.INTEGER: nobject = int.Parse(words[8]); break; case Type.VECTOR3: string [] nums = words[8].Split(','); nobject = new Vector3(int.Parse(nums[0]), int.Parse(nums[1]), int.Parse(nums[2])); break; case Type.STRING32: nobject = words[8]; break; } ; retVal = new PStorageRecordDescription(int.Parse(words[0]), ntype, int.Parse(words[2]), words[3], words[4], words[5], int.Parse(words[6]), int.Parse(words[7]), nobject); return(true); } catch { retVal = null; return(false); } } else { retVal = null; return(false); } }