public static void PrintT <T>(T t) { var builder = new StringBuilder(); var length = RefUtility <T> .GetPropertiesLength(); for (int i = 0; i < length; i++) { builder.AppendFormat("{0} {1}{2}", RefUtility <T> .GetPropertyName(i), RefUtility <T> .GetPropertyValue(i, t), i < length - 1 ? ", " : ";"); } Debug.Log(builder.ToString()); }
public static string CreateTableText <T>(string tablename) { var length = RefUtility <T> .GetPropertiesLength(); StringBuilder builder = new StringBuilder(string.Format(@"CREATE TABLE IF NOT EXISTS {0} (", tablename)); for (int i = 0; i < length; i++) { builder.AppendFormat("{0} {1}{2}", RefUtility <T> .GetPropertyName(i), GetSqliteType(RefUtility <T> .GetPropertyType(i)), i < length - 1 ? ", " : ")"); } return(builder.ToString()); }
public static string UpdateTableText <T>(string tablename, T t, int index) { var length = RefUtility <T> .GetPropertiesLength(); var builder = new StringBuilder(string.Format(@"UPDATE {0} SET ", tablename)); for (var i = 0; i < length; i++) { builder.AppendFormat("{0}=\'{1}\'{2}", RefUtility <T> .GetPropertyName(i), RefUtility <T> .GetPropertyValue(i, t), i < length - 1 ? ", " : " WHERE ROWID=" + (index + 1)); } return(builder.ToString()); }
public static string SelectTableText <T>(string tablename, int index) { var length = RefUtility <T> .GetPropertiesLength(); StringBuilder builder = new StringBuilder(@"SELECT "); for (int i = 0; i < length; i++) { builder.AppendFormat("{0}{1}", RefUtility <T> .GetPropertyName(i), i < length - 1 ? ", " : " "); } builder.AppendFormat("FROM {0} LIMIT 1 OFFSET {1}", tablename, index); return(builder.ToString()); }