private static bool TrySystemEntitiesListDeserializer(string input, Directory parent, int count) { List <ISystemEntity> entities = new List <ISystemEntity>(); if (!DeserializationTools.CheckStringFormat(input, true)) { return(false); } input = input.TrimStart('[').TrimEnd(']').TrimStart('\r').TrimEnd('\n').TrimStart('\n').TrimEnd('\r'); List <string> stringList = new List <string>(); bool isEntitiesValid = TrySplitSystemEntitiesList(input, parent, out stringList); if (!isEntitiesValid) { return(false); } if (stringList.Count != count) { return(false); } bool result = true; for (int i = 0; i < count; ++i) { string type = new string(stringList[i].Skip(1).TakeWhile(s => s != ':').ToArray()); int index = int.Parse(new string(stringList[i].Skip(type.Length + 2).TakeWhile(s => s != ')').ToArray())); if (index != i) { return(false); } switch (type) { case "file": if (!File.IsSerializedStringValid(new string(stringList[i].SkipWhile(s => s != '[').ToArray()), parent)) { result = false; } break; case "directory": if (!Directory.IsSerializedStringValid(new string(stringList[i].SkipWhile(s => s != '[').ToArray()), parent)) { result = false; } break; default: return(false); } } return(result); }
/// <summary> /// Deserializes passed string to file. /// </summary> /// <param name="input"> /// String to be deserialized. /// </param> /// <param name="parent"> /// Parent <see cref="IEntity">entity</see> for file. /// </param> /// <param name="encoding"> /// Encoding used for deserialization of file name. /// Usually passed from parent <see cref="Hypermedia">hypermedia</see> where file resides during deserialization of parent hypermedia. /// </param> public static File DeserializeFromString(string input, IEntity parent, Encoding encoding) { string path = null; string name = null; string extension = null; FileAttributes?attributes = null; long lastModDateTime = 0; DateTime? lastModifiedDateTime = null; List <Block> blocks = new List <Block>(); bool isSingleBlock = false; ulong size = 0; string parent_path = null; string hash = null; DeserializationTools.CheckStringFormat(input, false); string blockList; int count; List <string> stringList; DeserializationTools.SplitStringForSystemEntity(input, _startOfBlockListDeclaration, _endOfBlockListDeclaration, 13, out count, out blockList, out stringList, true); DeserializationTools.ParseStartBaseSystemEntitySerializationString(stringList, encoding, out path, out name); extension = new string(stringList[2].Skip(19).TakeWhile(x => x != ',').ToArray()); attributes = FileAttributesDeserializer(new string(stringList[3].Skip(34).TakeWhile(x => x != ',').ToArray())); lastModDateTime = long.Parse(new string(stringList[4].Skip(41).TakeWhile(x => x != ',').ToArray())); lastModifiedDateTime = DateTimeOffset.FromUnixTimeSeconds(lastModDateTime).UtcDateTime; isSingleBlock = (new string(stringList[5].Skip(26).TakeWhile(x => x != ',').ToArray()) == "true") ? true : false; DeserializationTools.ParseEndBaseSerializationString(stringList, 6, out size, out parent_path, out hash); DeserializationTools.CheckParent(parent, parent_path, false); File file = new File { Path = path, Name = name, Extension = extension, Attributes = attributes, LastModifiedDateTime = lastModifiedDateTime, IsSingleBlock = isSingleBlock, Size = size, Parent = parent, Hash = hash }; if (count != 0) { blocks = BlocksListDeserializer(blockList, file, count); } file.Blocks = blocks; return(file); }
private List <IEntity> EntitiesListDeserializer(string input, Hypermedia parent, int count) { List <IEntity> entities = new List <IEntity>(); DeserializationTools.CheckStringFormat(input, false); input = input.TrimStart('[').TrimEnd(']').TrimStart('\r').TrimEnd('\n').TrimStart('\n').TrimEnd('\r'); var stringList = SplitEntitiesList(input, parent); if (stringList.Count != count) { throw new ArgumentException("Parsed string list does not match expected length", "count"); } for (int i = 0; i < count; ++i) { string type = new string(stringList[i].Skip(1).TakeWhile(s => s != ':').ToArray()); int index = int.Parse(new string(stringList[i].Skip(type.Length + 2).TakeWhile(s => s != ')').ToArray())); if (index != i) { throw new ArgumentException("Possible serialization error encountered. Unexpected sequence", "input"); } switch (type) { case "file": entities.Add(File.DeserializeFromString(new string(stringList[i].SkipWhile(s => s != '[').ToArray()), parent, parent.Encoding)); break; case "directory": entities.Add(Directory.DeserializeFromString(new string(stringList[i].SkipWhile(s => s != '[').ToArray()), parent, parent.Encoding)); break; case "hypermedia": var deserializer = SerializationVersionTools.GetSerializationVersion(SerializationVersionTools.GetVersion(new string(stringList[i].SkipWhile(s => s != '[').ToArray()))); entities.Add(deserializer.DeserializeFromString(new string(stringList[i].SkipWhile(s => s != '[').ToArray()), parent)); break; default: throw new ArgumentException("Possible serialization error encountered. Unexpected type", "input"); } } if (count != entities.Count) { throw new ArgumentException("Serialized and deserialized collection length does not match", "count"); } return(entities); }
/// <summary> /// Deserializes passed string to directory. /// </summary> /// <param name="input"> /// String to be deserialized. /// </param> /// <param name="parent"> /// Parent <see cref="IEntity">entity</see> for directory. /// </param> /// <param name="encoding"> /// Encoding used for deserialization of directory name. /// Usually passed from parent <see cref="Hypermedia">hypermedia</see> where directory resides during deserialization of parent hypermedia. /// </param> public static Directory DeserializeFromString(string input, IEntity parent, Encoding encoding) { string path = null; string name = null; FileAttributes? attributes = null; long lastModDateTime = 0; DateTime? lastModifiedDateTime = null; List <ISystemEntity> entities = new List <ISystemEntity>(); ulong size = 0; string parent_path = null; string hash = null; DeserializationTools.CheckStringFormat(input, false); string entitiesList; int count; List <string> stringList; DeserializationTools.SplitStringForSystemEntity(input, _startOfSystemEntityListDeclaration, _endOfSystemEntityListDeclaration, 31, out count, out entitiesList, out stringList, false); DeserializationTools.ParseStartBaseSystemEntitySerializationString(stringList, encoding, out path, out name); attributes = FileAttributesDeserializer(new string(stringList[2].Skip(34).TakeWhile(x => x != ',').ToArray())); lastModDateTime = long.Parse(new string(stringList[3].Skip(41).TakeWhile(x => x != ',').ToArray())); lastModifiedDateTime = DateTimeOffset.FromUnixTimeSeconds(lastModDateTime).UtcDateTime; DeserializationTools.ParseEndBaseSerializationString(stringList, 4, out size, out parent_path, out hash); DeserializationTools.CheckParent(parent, parent_path, false); Directory directory = new Directory { Path = path, Name = name, Attributes = attributes, LastModifiedDateTime = lastModifiedDateTime, Size = size, Parent = parent, Hash = hash }; if (count != 0) { entities = SystemEntitiesListDeserializer(entitiesList, directory, count, encoding); } directory.Entities = entities; return(directory); }
/// <summary> /// Deserializes passed string to block. /// </summary> /// <param name="input"> /// String to be deserialized. /// </param> /// <param name="parent"> /// Parent <see cref="File">file</see> for block. /// </param> public static Block DeserializeFromString(string input, File parent) { string path = null; ulong size = 0; string parent_path = null; string hash = null; DeserializationTools.CheckStringFormat(input, false); var stringList = DeserializationTools.SplitStringForBlock(input); path = new string(stringList[0].Skip(14).TakeWhile(x => x != ',').ToArray()); DeserializationTools.ParseEndBaseSerializationString(stringList, 1, out size, out parent_path, out hash); DeserializationTools.CheckParent(parent, parent_path, false); return(new Block { Path = path, Size = size, Parent = parent, Hash = hash }); }
private static bool TryBlocksListDeserializer(string input, File parent, int count) { if (!DeserializationTools.CheckStringFormat(input, true)) { return(false); } input = input.TrimStart('[').TrimEnd(']').TrimStart('\r').TrimEnd('\n').TrimStart('\n').TrimEnd('\r'); var stringList = input.Split(new string[] { "],", "];" }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (stringList.Count != count) { return(false); } for (int i = 0; i < stringList.Count; ++i) { stringList[i] = stringList[i].TrimStart('\r').TrimStart('\n'); StringBuilder builder = new StringBuilder(stringList[i]); builder.Append(']'); stringList[i] = builder.ToString(); } bool result = true; for (int i = 0; i < count; ++i) { int index = int.Parse(new string(stringList[i].Skip(7).TakeWhile(s => s != ')').ToArray())); if (index != i) { return(false); } if (!Block.IsSerializedStringValid(new string(stringList[i].SkipWhile(s => s != '[').ToArray()), parent)) { result = false; } } return(result); }
private static List <Block> BlocksListDeserializer(string input, File parent, int count) { List <Block> blocks = new List <Block>(); DeserializationTools.CheckStringFormat(input, false); input = input.TrimStart('[').TrimEnd(']').TrimStart('\r').TrimEnd('\n').TrimStart('\n').TrimEnd('\r'); var stringList = input.Split(new string[] { "],", "];" }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (stringList.Count != count) { throw new ArgumentException("Parsed string list does not match expected collection length", "count"); } for (int i = 0; i < stringList.Count; ++i) { stringList[i] = stringList[i].TrimStart('\r').TrimStart('\n'); StringBuilder builder = new StringBuilder(stringList[i]); builder.Append(']'); stringList[i] = builder.ToString(); } for (int i = 0; i < count; ++i) { int index = int.Parse(new string(stringList[i].Skip(7).TakeWhile(s => s != ')').ToArray())); if (index != i) { throw new ArgumentException("Possible serialization error encountered. Unexpected sequence", "input"); } blocks.Add(Block.DeserializeFromString(new string(stringList[i].SkipWhile(s => s != '[').ToArray()), parent)); } if (count != blocks.Count) { throw new ArgumentException("Serialized and deserialized collection length does not match", "count"); } return(blocks); }
public bool IsSerializedStringValid(string input, Hypermedia parent = null) { Encoding encoding = null; long cDateTime = 0; ulong size = 0; if (!DeserializationTools.CheckStringFormat(input, true)) { return(false); } int count; string entitiesList; List <string> stringList; if (!DeserializationTools.SplitStringForHypermedia(input, _startOfEntityListDeclaration, _endOfEntityListDeclaration, 24, out count, out entitiesList, out stringList, true)) { return(false); } if (stringList.Count != 16) { return(false); } if (!DeserializationTools.ValidateStartOfStrings(stringList)) { return(false); } if (!DeserializationTools.ValidateEndOfStrings(stringList, 15)) { return(false); } //0 if ((new string(stringList[0].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[0].Skip(8).TakeWhile(x => x != ')').ToArray())) != "path") { return(false); } //3 if ((new string(stringList[3].Skip(1).TakeWhile(x => x != ':').ToArray())) != "encoding") { return(false); } if ((new string(stringList[3].Skip(10).TakeWhile(x => x != ')').ToArray())) != "encoding") { return(false); } //1 if ((new string(stringList[1].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[1].Skip(8).TakeWhile(x => x != ')').ToArray())) != "name") { return(false); } //2 if ((new string(stringList[2].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[2].Skip(8).TakeWhile(x => x != ')').ToArray())) != "comment") { return(false); } //4 if ((new string(stringList[4].Skip(1).TakeWhile(x => x != ':').ToArray())) != "date_time") { return(false); } if ((new string(stringList[4].Skip(11).TakeWhile(x => x != ')').ToArray())) != "created_date_time") { return(false); } //5 if ((new string(stringList[5].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[5].Skip(8).TakeWhile(x => x != ')').ToArray())) != "created_by") { return(false); } //6 if ((new string(stringList[6].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[6].Skip(8).TakeWhile(x => x != ')').ToArray())) != "creator_peer") { return(false); } //7 if ((new string(stringList[7].Skip(1).TakeWhile(x => x != ':').ToArray())) != "boolean") { return(false); } if ((new string(stringList[7].Skip(9).TakeWhile(x => x != ')').ToArray())) != "is_directory_wrapped") { return(false); } //8 if ((new string(stringList[8].Skip(1).TakeWhile(x => x != ':').ToArray())) != "boolean") { return(false); } if ((new string(stringList[8].Skip(9).TakeWhile(x => x != ')').ToArray())) != "is_raw_ipfs") { return(false); } //9 if ((new string(stringList[9].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[9].Skip(8).TakeWhile(x => x != ')').ToArray())) != "topic") { return(false); } //10 if ((new string(stringList[10].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[10].Skip(8).TakeWhile(x => x != ')').ToArray())) != "default_subscription_message") { return(false); } //11 if ((new string(stringList[11].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[11].Skip(8).TakeWhile(x => x != ')').ToArray())) != "default_seeding_message") { return(false); } //12 if ((new string(stringList[12].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[12].Skip(8).TakeWhile(x => x != ')').ToArray())) != "version") { return(false); } //13 if ((new string(stringList[13].Skip(1).TakeWhile(x => x != ':').ToArray())) != "uint64") { return(false); } if ((new string(stringList[13].Skip(8).TakeWhile(x => x != ')').ToArray())) != "size") { return(false); } //14 if ((new string(stringList[14].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[14].Skip(8).TakeWhile(x => x != ')').ToArray())) != "parent_path") { return(false); } //15 if ((new string(stringList[15].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[15].Skip(8).TakeWhile(x => x != ')').ToArray())) != "hash") { return(false); } //TryParse try { encoding = Encoding.GetEncoding(new string(stringList[3].Skip(20).TakeWhile(x => x != ',').ToArray())); } catch { return(false); } if (!long.TryParse(new string(stringList[4].Skip(30).TakeWhile(x => x != ',').ToArray()), out cDateTime)) { return(false); } if (!(new string(stringList[7].Skip(31).TakeWhile(x => x != ',').ToArray()) == "true" || new string(stringList[7].Skip(31).TakeWhile(x => x != ',').ToArray()) == "false")) { return(false); } if (!(new string(stringList[8].Skip(22).TakeWhile(x => x != ',').ToArray()) == "true" || new string(stringList[8].Skip(22).TakeWhile(x => x != ',').ToArray()) == "false")) { return(false); } if (!ulong.TryParse(new string(stringList[13].Skip(14).TakeWhile(x => x != ',').ToArray()), out size)) { return(false); } string ver = new string(stringList[12].Skip(17).TakeWhile(x => x != ',').ToArray()); if (!ver.Contains("/")) { return(false); } if (ver.Split('/').Length != 2) { return(false); } string path = new string(stringList[0].Skip(14).TakeWhile(x => x != ',').ToArray()); string parent_path = new string(stringList[14].Skip(21).TakeWhile(x => x != ',').ToArray()); if (parent != null) { if (!DeserializationTools.CheckParent(parent, parent_path, true)) { return(false); } } Hypermedia010 hypermedia = new Hypermedia010 { Path = path, Encoding = encoding, Parent = parent }; bool isEntitiesValid = true; if (count > 0) { isEntitiesValid = TryEntitiesListDeserializer(entitiesList, hypermedia, count); } if (!isEntitiesValid) { return(false); } return(true); }
/// <summary> /// Deserializes passed string to hypermedia. /// </summary> /// <param name="input"> /// String to be deserialized. /// </param> /// <param name="parent"> /// Parent <see cref="Hypermedia">hypermedia</see> for serialized hypermedia. /// Default - null. /// </param> public Hypermedia DeserializeFromString(string input, Hypermedia parent) { string path = null; string name = null; string comment = null; Encoding encoding = null; long cDateTime = 0; DateTime createdDateTime; string createdBy = null; string creatorPeer = null; List <IEntity> entities; bool isDirectoryWrapped = false; bool isRawIPFS = false; string topic = null; string defaultSubscriptionMessage = null; string defaultSeedingMessage = null; string version = null; ulong size = 0; string parent_path = null; string hash = null; input = input.Replace("\t", ""); DeserializationTools.CheckStringFormat(input, false); int count; string entitiesList; List <string> stringList; DeserializationTools.SplitStringForHypermedia(input, _startOfEntityListDeclaration, _endOfEntityListDeclaration, 24, out count, out entitiesList, out stringList, false); DeserializationTools.ParseStartBaseHypermediaSerializationString(stringList, out path, out encoding, out name); comment = EncodingTools.DecodeString(new string(stringList[2].Skip(17).TakeWhile(x => x != ',').ToArray()), encoding); cDateTime = long.Parse(new string(stringList[4].Skip(30).TakeWhile(x => x != ',').ToArray())); createdDateTime = DateTimeOffset.FromUnixTimeSeconds(cDateTime).UtcDateTime; createdBy = new string(stringList[5].Skip(20).TakeWhile(x => x != ',').ToArray()); creatorPeer = new string(stringList[6].Skip(22).TakeWhile(x => x != ',').ToArray()); isDirectoryWrapped = (new string(stringList[7].Skip(31).TakeWhile(x => x != ',').ToArray()) == "true") ? true : false; isRawIPFS = (new string(stringList[8].Skip(22).TakeWhile(x => x != ',').ToArray()) == "true") ? true : false; topic = new string(stringList[9].Skip(15).TakeWhile(x => x != ',').ToArray()); defaultSubscriptionMessage = new string(stringList[10].Skip(38).TakeWhile(x => x != ',').ToArray()); defaultSeedingMessage = new string(stringList[11].Skip(33).TakeWhile(x => x != ',').ToArray()); version = new string(stringList[12].Skip(17).TakeWhile(x => x != ',').ToArray()); DeserializationTools.ParseEndBaseSerializationString(stringList, 13, out size, out parent_path, out hash); if (parent != null) { DeserializationTools.CheckParent(parent, parent_path, false); } Hypermedia010 hypermedia = new Hypermedia010 { Path = path, Name = name, Comment = comment, Encoding = encoding, CreatedDateTime = createdDateTime, CreatedBy = createdBy, CreatorPeer = creatorPeer, IsDirectoryWrapped = isDirectoryWrapped, IsRawIPFS = isRawIPFS, Topic = topic, DefaultSubscriptionMessage = defaultSubscriptionMessage, DefaultSeedingMessage = defaultSeedingMessage, Version = version, Size = size, Parent = parent, Hash = hash }; entities = EntitiesListDeserializer(entitiesList, hypermedia, count); hypermedia.Entities = entities; return(hypermedia); }
public static bool IsSerializedStringValid(string input, File parent) { if (!DeserializationTools.CheckStringFormat(input, true)) { return(false); } var stringList = DeserializationTools.SplitStringForBlock(input); if (stringList.Count != 4) { return(false); } if (!DeserializationTools.ValidateStartOfStrings(stringList)) { return(false); } if (!DeserializationTools.ValidateEndOfStrings(stringList, 3)) { return(false); } if ((new string(stringList[0].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[0].Skip(8).TakeWhile(x => x != ')').ToArray())) != "path") { return(false); } if ((new string(stringList[1].Skip(1).TakeWhile(x => x != ':').ToArray())) != "uint64") { return(false); } if ((new string(stringList[1].Skip(8).TakeWhile(x => x != ')').ToArray())) != "size") { return(false); } if ((new string(stringList[2].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[2].Skip(8).TakeWhile(x => x != ')').ToArray())) != "parent_path") { return(false); } if ((new string(stringList[3].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[3].Skip(8).TakeWhile(x => x != ')').ToArray())) != "hash") { return(false); } string parent_path = new string(stringList[2].Skip(21).TakeWhile(x => x != ',').ToArray()); if (!DeserializationTools.CheckParent(parent, parent_path, true)) { return(false); } return(true); }
public static bool IsSerializedStringValid(string input, IEntity parent) { long lastModDateTime = 0; ulong size = 0; if (!DeserializationTools.CheckStringFormat(input, true)) { return(false); } int count; string entitiesList; List <string> stringList; if (!DeserializationTools.SplitStringForSystemEntity(input, _startOfSystemEntityListDeclaration, _endOfSystemEntityListDeclaration, 31, out count, out entitiesList, out stringList, false)) { return(false); } if (stringList.Count != 7) { return(false); } if (!DeserializationTools.ValidateStartOfStrings(stringList)) { return(false); } if (!DeserializationTools.ValidateEndOfStrings(stringList, 6)) { return(false); } //0 if ((new string(stringList[0].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[0].Skip(8).TakeWhile(x => x != ')').ToArray())) != "path") { return(false); } //1 if ((new string(stringList[1].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[1].Skip(8).TakeWhile(x => x != ')').ToArray())) != "name") { return(false); } //2 if ((new string(stringList[2].Skip(1).TakeWhile(x => x != ':').ToArray())) != "file_attributes_null") { return(false); } if ((new string(stringList[2].Skip(22).TakeWhile(x => x != ')').ToArray())) != "attributes") { return(false); } //3 if ((new string(stringList[3].Skip(1).TakeWhile(x => x != ':').ToArray())) != "date_time_null") { return(false); } if ((new string(stringList[3].Skip(16).TakeWhile(x => x != ')').ToArray())) != "last_modified_date_time") { return(false); } //4 if ((new string(stringList[4].Skip(1).TakeWhile(x => x != ':').ToArray())) != "uint64") { return(false); } if ((new string(stringList[4].Skip(8).TakeWhile(x => x != ')').ToArray())) != "size") { return(false); } //5 if ((new string(stringList[5].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[5].Skip(8).TakeWhile(x => x != ')').ToArray())) != "parent_path") { return(false); } //6 if ((new string(stringList[6].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[6].Skip(8).TakeWhile(x => x != ')').ToArray())) != "hash") { return(false); } //TryParse if (!long.TryParse(new string(stringList[3].Skip(41).TakeWhile(x => x != ',').ToArray()), out lastModDateTime)) { return(false); } if (!ulong.TryParse(new string(stringList[4].Skip(14).TakeWhile(x => x != ',').ToArray()), out size)) { return(false); } string path = new string(stringList[0].Skip(14).TakeWhile(x => x != ',').ToArray()); string parent_path = new string(stringList[5].Skip(21).TakeWhile(x => x != ',').ToArray()); if (!DeserializationTools.CheckParent(parent, parent_path, true)) { return(false); } Directory directory = new Directory { Path = path }; bool isEntitiesValid = true; if (count > 0) { isEntitiesValid = TrySystemEntitiesListDeserializer(entitiesList, directory, count); } if (!isEntitiesValid) { return(false); } return(true); }
public static bool IsSerializedStringValid(string input, IEntity parent) { long lastModDateTime = 0; ulong size = 0; if (!DeserializationTools.CheckStringFormat(input, true)) { return(false); } int count; string blockList; List <string> stringList; if (!DeserializationTools.SplitStringForSystemEntity(input, _startOfBlockListDeclaration, _endOfBlockListDeclaration, 13, out count, out blockList, out stringList, true)) { return(false); } if (stringList.Count != 9) { return(false); } if (!DeserializationTools.ValidateStartOfStrings(stringList)) { return(false); } if (!DeserializationTools.ValidateEndOfStrings(stringList, 8)) { return(false); } //0 if ((new string(stringList[0].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[0].Skip(8).TakeWhile(x => x != ')').ToArray())) != "path") { return(false); } //1 if ((new string(stringList[1].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[1].Skip(8).TakeWhile(x => x != ')').ToArray())) != "name") { return(false); } //2 if ((new string(stringList[2].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[2].Skip(8).TakeWhile(x => x != ')').ToArray())) != "extension") { return(false); } //3 if ((new string(stringList[3].Skip(1).TakeWhile(x => x != ':').ToArray())) != "file_attributes_null") { return(false); } if ((new string(stringList[3].Skip(22).TakeWhile(x => x != ')').ToArray())) != "attributes") { return(false); } //4 if ((new string(stringList[4].Skip(1).TakeWhile(x => x != ':').ToArray())) != "date_time_null") { return(false); } if ((new string(stringList[4].Skip(16).TakeWhile(x => x != ')').ToArray())) != "last_modified_date_time") { return(false); } //5 if ((new string(stringList[5].Skip(1).TakeWhile(x => x != ':').ToArray())) != "boolean") { return(false); } if ((new string(stringList[5].Skip(9).TakeWhile(x => x != ')').ToArray())) != "is_single_block") { return(false); } //6 if ((new string(stringList[6].Skip(1).TakeWhile(x => x != ':').ToArray())) != "uint64") { return(false); } if ((new string(stringList[6].Skip(8).TakeWhile(x => x != ')').ToArray())) != "size") { return(false); } //7 if ((new string(stringList[7].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[7].Skip(8).TakeWhile(x => x != ')').ToArray())) != "parent_path") { return(false); } //8 if ((new string(stringList[8].Skip(1).TakeWhile(x => x != ':').ToArray())) != "string") { return(false); } if ((new string(stringList[8].Skip(8).TakeWhile(x => x != ')').ToArray())) != "hash") { return(false); } //TryParse if (!long.TryParse(new string(stringList[4].Skip(41).TakeWhile(x => x != ',').ToArray()), out lastModDateTime)) { return(false); } if (!(new string(stringList[5].Skip(26).TakeWhile(x => x != ',').ToArray()) == "true" || new string(stringList[5].Skip(26).TakeWhile(x => x != ',').ToArray()) == "false")) { return(false); } if (!ulong.TryParse(new string(stringList[6].Skip(14).TakeWhile(x => x != ',').ToArray()), out size)) { return(false); } string path = new string(stringList[0].Skip(14).TakeWhile(x => x != ',').ToArray()); string parent_path = new string(stringList[7].Skip(21).TakeWhile(x => x != ',').ToArray()); if (!DeserializationTools.CheckParent(parent, parent_path, true)) { return(false); } File file = new File { Path = path }; bool isBlocksValid = true; if (count > 0) { isBlocksValid = TryBlocksListDeserializer(blockList, file, count); } if (!isBlocksValid) { return(false); } return(true); }