public Parts Split() { if (cache == null) { cache = new Dictionary <string, Parts>(); } if (!cache.ContainsKey(id)) { Parts ret = new Parts(); ret.local = id.StartsWith("_"); var name = id.Substring(ret.local ? 1 : 0); var ddpos = name.IndexOf(':'); if (ddpos >= 0) { ret.term = name.Substring(ddpos + 1); name = name.Substring(0, ddpos); } ret.quoted = name.StartsWith("\""); ret.name = ret.quoted ? name.Substring(1, name.Length - 2).Replace("\"\"", "\"") : name; cache[id] = ret; return(ret.Clone()); } return(cache[id].Clone()); }
/// <summary> /// Gets the child path. /// </summary> /// <param name="folderName">Name of the folder.</param> /// <returns>AbsoluteFolderPath.</returns> /// <exception cref="System.Exception">Invalid folder name: + folderName</exception> public AbsoluteFolderPath GetChildFolderPath(string folderName) { NameHelper.EnsureValidFilenameCharacters(folderName); var parts = Parts.Clone(); parts.Add(folderName); return(new AbsoluteFolderPath(parts)); }
public RelativeFilePath GetChildFilePath(string fileName) { NameHelper.EnsureValidFilenameCharacters(fileName); var parts = Parts.Clone(); parts.Add(fileName); return(new RelativeFilePath(parts)); }
public RelativeFolderPath GetSiblingFolderPath(string folderName) { NameHelper.EnsureValidFilenameCharacters(folderName); StringList parts = Parts.Clone(); parts.Add(".."); parts.Add(folderName); return(new RelativeFolderPath(parts)); }
public RelativeFilePath GetSiblingFilePath(string fileNameWithExtension) { NameHelper.EnsureValidFilenameCharacters(fileNameWithExtension); StringList parts = Parts.Clone(); parts.Add(".."); parts.Add(fileNameWithExtension); return(new RelativeFilePath(parts)); }
public object Clone() { Ship copy = new Ship(); copy.ID = this.ID; copy.Name = (string)this.Name.Clone(); copy.IsDestroyed = this.IsDestroyed; copy.Owner = (Player)this.Owner.Clone(); copy.Parts = (List <BasePart>)Parts.Clone(); copy.Position = this.Position; copy.Hull = (ShipHull)this.Hull.Clone(); copy.MP = (StatWithMax)this.MP.Clone(); return(copy); }
public Parts Split() { if (cache == null) { cache = new Dictionary <string, Parts>(); } if (id == null) { } if (!cache.ContainsKey(id)) { var factory = new CNLFactory(); var lexer = factory.getLexer(); lexer.Start(id); var token = lexer.Next(); Parts ret = new Parts(); if (token == null) { return(ret); } var tokStr = token.yytext; var termsStr = ""; if (token.yytext.EndsWith("]")) { var trmp = token.yytext.LastIndexOf('['); termsStr = token.yytext.Substring(trmp); tokStr = token.yytext.Substring(0, token.yytext.Length - termsStr.Length).Trim(); ret.term = termsStr.Substring(1, termsStr.Length - 2); } if (token is VERYBIGNAME) { ret.kind = Parts.Kind.VeryBigName; } else if (token is BIGNAME) { ret.kind = Parts.Kind.BigName; } else if (token is NAME) { ret.kind = Parts.Kind.Name; } ret.quoted = (tokStr.StartsWith(PFX + "\"") || tokStr.StartsWith(PFX.ToUpper() + "\"")) && tokStr.EndsWith("\""); if (ret.quoted) { ret.name = tokStr.Substring(PFX.Length + 1, tokStr.Length - PFX.Length - 2).Replace("\"\"", "\""); } else { ret.quoted = tokStr.StartsWith("\"") && tokStr.EndsWith("\""); if (ret.quoted) { ret.name = tokStr.Substring(1, tokStr.Length - 2).Replace("\"\"", "\""); } else { ret.name = tokStr; } } cache[id] = ret; return(ret.Clone()); } return(cache[id].Clone()); }