public static string Write(object One, ref LswSql.SqlPositions SqlPosition) { string Return = "ELSEIF "; LsElseIf Two = (LsElseIf)One; Return += new SqlControler().Out(new LsBaseList() { Bases = new List <lsBase>() { Two.Bracket } }).TrimEnd("\r\n".ToCharArray()) + " THEN\r\n"; Return = Return.Replace("((", "("); foreach (var item in Two.InerLines) { Return += "\t" + new SqlControler().Out(new LsBaseList() { Bases = new List <lsBase>() { item } }); } if (Two.EndIf) { Return += "END IF;\r\n"; } return(Return); }
public static LsElseIf Read(string One, ref LswSql.SqlPositions SqlPosition) { LsElseIf Two = new LsElseIf(); string Three = One.Trim().Substring(7, One.Length - 11).Trim(); //string Three = One.Trim().Substring(2,One.Length - 3).Split("THEN".ToCharArray())[0].Trim() + ")"; Two.Bracket = (LsBracket) new SqlControler().PartInRef(Three, ref SqlPosition); bool Continu = true; do { SqlPosition.Position++; try { string Four = SqlPosition.InLine[SqlPosition.Position]; if (Four.Trim().ToLower() == "end if;") { Continu = false; SqlPosition.Position++; SqlPosition.Position++; Two.EndIf = true; } else if (CheckRepeate(Four, Two)) { LsBaseList list = (LsBaseList)(new SqlControler().In(new string[] { Four.Trim() })); Two.InerLines.Add(list.Bases[0]); } else if (Four.Trim().ToLower().Substring(0, 4) == "else") { Continu = false; SqlPosition.Position++; SqlPosition.Position++; Two.EndIf = true; } else { Continu = false; } } catch { Continu = false; } } while (Continu); SqlPosition.Position = SqlPosition.Position - 1; return(Two); }
public static string Write(object One, ref LswSql.SqlPositions SqlPosition) { string Return = ""; LsBracket Two = (LsBracket)One; Return += Two.BracketTypesPears[Two.BracketType][0]; int Point = 0; while (Two.BaseProperties.Count + Two.StringProperties.Count > Point) { object ToAdd; LsName ToAdd2; if (Two.BaseProperties.TryGetValue(Point, out ToAdd)) { if (ToAdd.GetType() == typeof(string)) { Return += (ToAdd.ToString().Contains("\"")) ? "@" + '"' + DoubleSpeatch(ToAdd.ToString()) + '"' : '"' + ToAdd.ToString() + @""""; } else if (ToAdd.GetType() == typeof(char)) { Return += (ToAdd.ToString().Contains("'")) ? "'\\''" : "'" + ToAdd.ToString() + @"''"; } else if (ToAdd.GetType() == typeof(int)) { Return += ToAdd.ToString() + "{int}"; } else if (ToAdd.GetType() == typeof(bool)) { Return += ToAdd.ToString().ToLower(); } else if (ToAdd.GetType() == typeof(LsBracket)) { Return += Write(ToAdd, ref SqlPosition); } Return += Seperater(Two.BracketType) + " "; } else if (Two.StringProperties.TryGetValue(Point, out ToAdd2)) { Return += ToAdd2.Name + Seperater(Two.BracketType) + " "; } Point++; } Return = Return.TrimEnd(); Return = Return.Substring(0, Return.Length - 1); Return += ")"; return(Return); }
public static string Write(object One, ref LswSql.SqlPositions SqlPosition) { string Return = "ELSE\r\n"; LsElse Two = (LsElse)One; foreach (var item in Two.InerLines) { Return += "\t" + new SqlControler().Out(new LsBaseList() { Bases = new List <lsBase>() { item } }); } Return += "END IF;\r\n"; return(Return); }
public static LsElse Read(string One, ref LswSql.SqlPositions SqlPosition) { LsElse Two = new LsElse(); Two.Tabindex = CountTabs(One); bool Continu = true; do { SqlPosition.Position++; try { string Four = SqlPosition.InLine[SqlPosition.Position]; if (Four.Trim().ToLower() == "end if;") { Continu = false; SqlPosition.Position++; SqlPosition.Position++; Two.EndIf = true; } else if (CheckRepeate(Four, Two)) { LsBaseList list = (LsBaseList)(new SqlControler().In(new string[] { Four.Trim() })); Two.InerLines.Add(list.Bases[0]); } else { Continu = false; } } catch { Continu = false; } } while (Continu); SqlPosition.Position = SqlPosition.Position - 1; return(Two); }
public static LsBracket Read(string One, ref LswSql.SqlPositions SqlPosition) { LsBracket Two = new LsBracket(); string Three = One[0].ToString(); switch (Three) { case "<": Three = Three + "|>"; break; case "(": Three = Three + "|)"; break; case "[": Three = Three + "|]"; break; case "{": Three = Three + "|}"; break; default: Three = "(|)"; break; } if (Two.BracketTypesPears.ContainsValue(Three)) { Two.BracketType = Dic.KeyByValue(Three); // // } else { Two.BracketType = LsBracket.BracketTypes.Round; } //do //{ string[] Parts; Parts = One.Trim().Substring(1, One.Length - 2).Split(Seperater(Two.BracketType).ToCharArray()); foreach (var item in Parts) { string itemT = item.Trim(); var Four = new SqlControler().PartInRef(itemT, ref SqlPosition); if (Four is string && (itemT[0] != '"' && itemT[0] != "'"[0])) { Two.AddString(new LsName() { Name = Four.ToString() }); } else { Two.AddBase(Four); } } SqlPosition.Position++; try { One = SqlPosition.InLine[SqlPosition.Position]; } catch { } //} while(CheckRepeate(One, Two)); SqlPosition.Position = SqlPosition.Position - 1; return(Two); }