public void Serialize <T>() { var classtype = typeof(T); var xlss = classtype.GetAttribute <XLSSAttribute>(); if (xlss == null) { UnityEngine.Debug.LogWarning(string.Format("Can't Serialize {0}", classtype.FullName)); return; } var excelfile = Path.Combine(_config.ExcelPath, xlss.file); if (!File.Exists(excelfile)) { return; } var table = _reader.Read(excelfile); if (xlss.type == XLSSType.Script) { var codestr = ScriptSerialize <T>(table); var filename = Path.Combine(_config.ScriptPath, classtype.Name) + ".cs"; File.WriteAllText(filename, codestr); } else { var obj = BinarySerialize <T>(table); var filename = Path.Combine(_config.BineryPath, typeof(T).Name) + ".bytes"; using (var fs = File.Open(filename, FileMode.OpenOrCreate, FileAccess.Write)) { Serialize(fs, obj); } } }
private IEnumerable <TEntity> select(ICommand command) { _connection.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { yield return(_tableReader.Read(reader, 0)); } } }
internal void Generating(ITableReader tableReader, IClassWriter classWriter) { tableReader.Close(); classWriter.ClearProperty(); string className = FileMedia.QUERY_CLASS_PRE + Misc.GetPublicName(tableReader.TableName); classWriter.ClassName = className; if (string.IsNullOrEmpty(classWriter.NameSpace)) { classWriter.NameSpace = _nameSpace; } try { tableReader.Open(); while (tableReader.Read()) { TableColumn tableColumn = tableReader.CurrentColumn().Value; string propertyName = Misc.GetPublicName(tableColumn.Name); classWriter.AppendProperty(propertyName, tableColumn, tableColumn.DotNetType); } classWriter.WriteOut(); } finally { tableReader.Close(); } }
public void Generating(ITableReader tableReader, IClassWriter classWriter, IClassLogicWriter classLogicWriter, IMapWriter mapWriter) { tableReader.Close(); classWriter.ClearProperty(); mapWriter.ClearItem(); if (classLogicWriter != null) { classLogicWriter.ClearProperty(); } string className = FileMedia.ENTITY_CLASS_PRE + Misc.GetPublicName(tableReader.TableName); classWriter.NameSpace = _nameSpace; classWriter.ClassName = className; if (classLogicWriter != null) { classLogicWriter.ClassNameSpace = _nameSpace; classLogicWriter.ClassName = className; classLogicWriter.ClassLogicNameSpace = _logicNameSpace; classLogicWriter.ClassLogicName = className + "Helper"; } mapWriter.ClassName = string.Format("{0}.{1}", _nameSpace, className); mapWriter.AssemblyName = _assemblyName; mapWriter.TableName = tableReader.TableName; try { tableReader.Open(); while (tableReader.Read()) { TableColumn tableColumn = tableReader.CurrentColumn().Value; string propertyName = Misc.GetPublicName(tableColumn.Name); classWriter.AppendProperty(propertyName, tableColumn, tableColumn.DotNetType); if (classLogicWriter != null) { classLogicWriter.AppendProperty(propertyName, tableColumn.DotNetType, tableColumn.IsKey); } mapWriter.AppendItem(new MapItem(propertyName, tableColumn.Name, tableColumn.DatabaseType, tableColumn.IsKey, tableColumn.CanBeNull, tableColumn.MaxLength, true, true)); } classWriter.WriteOut(); if (classLogicWriter != null) { classLogicWriter.WriteOut(); } mapWriter.WriteOut(); } finally { tableReader.Close(); } }
public static void Copy(ITableReader tableReader, ITableWriter tableWriter) { while (tableReader.Read()) { tableWriter.Next(); Copy <string>(tableReader, tableWriter); } }
public void OnReadAll(IDataWriter <int> dataWriter) { int index = 0; if (tableReader.Count != 1) { while (tableReader.Read()) { dataWriter[index].WriteObject(tableReader); ++index; } return; } while (tableReader.Read()) { var valueWriter = dataWriter[index]; try { valueWriter.WriteObject(tableReader); } catch (Exception e) { try { tableReader.OnReadValue(0, valueWriter); } catch (Exception) { throw e; } } ++index; } }