// Creates Sound wrapper private Sound CreateItem( // Fields of Sound table Guid SoundId, PinSide PinSide, string Notation, string Note // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = SoundId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); SoundData dataSound = new SoundData() { SoundId = SoundId, PinSide = PinSide, Notation = Notation, Note = Note, }; return(this.Create(this.Table.Insert(ref dataSound), rowIdCircuit)); }
// Creates LogicalCircuit wrapper private LogicalCircuit CreateItem( // Fields of LogicalCircuit table Guid LogicalCircuitId, string Name, string Notation, string Note, string Category, bool IsDisplay // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = LogicalCircuitId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); LogicalCircuitData dataLogicalCircuit = new LogicalCircuitData() { LogicalCircuitId = LogicalCircuitId, Name = Name, Notation = Notation, Note = Note, Category = Category, IsDisplay = IsDisplay, }; return(this.Create(this.Table.Insert(ref dataLogicalCircuit), rowIdCircuit)); }
// Creates all foreign keys of the table public static void CreateForeignKeys(StoreSnapshot store) { TableSnapshot <CircuitSymbolData> table = (TableSnapshot <CircuitSymbolData>)store.Table("CircuitSymbol"); table.CreateForeignKey("FK_Circuit_CircuitSymbol", store.Table("Circuit"), CircuitSymbolData.CircuitIdField.Field, ForeignKeyAction.Cascade, false); table.CreateForeignKey("FK_LogicalCircuit_CircuitSymbol", store.Table("LogicalCircuit"), CircuitSymbolData.LogicalCircuitIdField.Field, ForeignKeyAction.Restrict, false); }
// Creates CircuitProbe wrapper private CircuitProbe CreateItem( // Fields of CircuitProbe table Guid CircuitProbeId, string Name, string Note // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = CircuitProbeId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); CircuitProbeData dataCircuitProbe = new CircuitProbeData() { CircuitProbeId = CircuitProbeId, Name = Name, Note = Note, }; return(this.Create(this.Table.Insert(ref dataCircuitProbe), rowIdCircuit)); }
// Creates LedMatrix wrapper private LedMatrix CreateItem( // Fields of LedMatrix table Guid LedMatrixId, LedMatrixType MatrixType, LedMatrixCellShape CellShape, int Rows, int Columns, int Colors, string Note // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = LedMatrixId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); LedMatrixData dataLedMatrix = new LedMatrixData() { LedMatrixId = LedMatrixId, MatrixType = MatrixType, CellShape = CellShape, Rows = Rows, Columns = Columns, Colors = Colors, Note = Note, }; return(this.Create(this.Table.Insert(ref dataLedMatrix), rowIdCircuit)); }
// Creates Sensor wrapper private Sensor CreateItem( // Fields of Sensor table Guid SensorId, SensorType SensorType, int BitWidth, PinSide PinSide, string Notation, string Data, string Note // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = SensorId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); SensorData dataSensor = new SensorData() { SensorId = SensorId, SensorType = SensorType, BitWidth = BitWidth, PinSide = PinSide, Notation = Notation, Data = Data, Note = Note, }; return(this.Create(this.Table.Insert(ref dataSensor), rowIdCircuit)); }
// Creates Constant wrapper private Constant CreateItem( // Fields of Constant table Guid ConstantId, int BitWidth, int Value, PinSide PinSide, string Note // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = ConstantId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); ConstantData dataConstant = new ConstantData() { ConstantId = ConstantId, BitWidth = BitWidth, Value = Value, PinSide = PinSide, Note = Note, }; return(this.Create(this.Table.Insert(ref dataConstant), rowIdCircuit)); }
// Creates Splitter wrapper private Splitter CreateItem( // Fields of Splitter table Guid SplitterId, int BitWidth, int PinCount, bool Clockwise // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = SplitterId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); SplitterData dataSplitter = new SplitterData() { SplitterId = SplitterId, BitWidth = BitWidth, PinCount = PinCount, Clockwise = Clockwise, }; return(this.Create(this.Table.Insert(ref dataSplitter), rowIdCircuit)); }
// Creates CircuitButton wrapper private CircuitButton CreateItem( // Fields of CircuitButton table Guid CircuitButtonId, string Notation, bool IsToggle, PinSide PinSide, bool Inverted, int Width, int Height, string Note // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = CircuitButtonId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); CircuitButtonData dataCircuitButton = new CircuitButtonData() { CircuitButtonId = CircuitButtonId, Notation = Notation, IsToggle = IsToggle, PinSide = PinSide, Inverted = Inverted, Width = Width, Height = Height, Note = Note, }; return(this.Create(this.Table.Insert(ref dataCircuitButton), rowIdCircuit)); }
// Creates GraphicsArray wrapper private GraphicsArray CreateItem( // Fields of GraphicsArray table Guid GraphicsArrayId, bool WriteOn1, MemoryOnStart OnStart, int DataBitWidth, int BitsPerPixel, int Width, int Height, string Note // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = GraphicsArrayId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); GraphicsArrayData dataGraphicsArray = new GraphicsArrayData() { GraphicsArrayId = GraphicsArrayId, WriteOn1 = WriteOn1, OnStart = OnStart, DataBitWidth = DataBitWidth, BitsPerPixel = BitsPerPixel, Width = Width, Height = Height, Note = Note, }; return(this.Create(this.Table.Insert(ref dataGraphicsArray), rowIdCircuit)); }
// Creates all foreign keys of the table public static void CreateForeignKeys(StoreSnapshot store) { TableSnapshot <DevicePinData> table = (TableSnapshot <DevicePinData>)store.Table("DevicePin"); table.CreateForeignKey("PK_DevicePin", store.Table("Circuit"), DevicePinData.PinIdField.Field, ForeignKeyAction.Cascade, false); table.CreateForeignKey("FK_Circuit_DevicePin", store.Table("Circuit"), DevicePinData.CircuitIdField.Field, ForeignKeyAction.Restrict, false); }
// Creates Memory wrapper private Memory CreateItem( // Fields of Memory table Guid MemoryId, bool Writable, bool WriteOn1, MemoryOnStart OnStart, int AddressBitWidth, int DataBitWidth, string Data, string Note // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = MemoryId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); MemoryData dataMemory = new MemoryData() { MemoryId = MemoryId, Writable = Writable, WriteOn1 = WriteOn1, OnStart = OnStart, AddressBitWidth = AddressBitWidth, DataBitWidth = DataBitWidth, Data = Data, Note = Note, }; return(this.Create(this.Table.Insert(ref dataMemory), rowIdCircuit)); }
// Creates table. public static TableSnapshot <MemoryData> CreateTable(StoreSnapshot store) { TableSnapshot <MemoryData> table = new TableSnapshot <MemoryData>(store, "Memory", MemoryData.fields); // Create all but foreign keys of the table table.MakeUnique("PK_Memory", MemoryData.MemoryIdField.Field, true); // Return created table return(table); }
// Creates table. public static TableSnapshot <LedMatrixData> CreateTable(StoreSnapshot store) { TableSnapshot <LedMatrixData> table = new TableSnapshot <LedMatrixData>(store, "LedMatrix", LedMatrixData.fields); // Create all but foreign keys of the table table.MakeUnique("PK_LedMatrix", LedMatrixData.LedMatrixIdField.Field, true); // Return created table return(table); }
// Creates table. public static TableSnapshot <ProjectData> CreateTable(StoreSnapshot store) { TableSnapshot <ProjectData> table = new TableSnapshot <ProjectData>(store, "Project", ProjectData.fields); // Create all but foreign keys of the table table.MakeUnique("PK_Project", ProjectData.ProjectIdField.Field, true); // Return created table return(table); }
// Creates table. public static TableSnapshot <CircuitButtonData> CreateTable(StoreSnapshot store) { TableSnapshot <CircuitButtonData> table = new TableSnapshot <CircuitButtonData>(store, "CircuitButton", CircuitButtonData.fields); // Create all but foreign keys of the table table.MakeUnique("PK_CircuitButton", CircuitButtonData.CircuitButtonIdField.Field, true); // Return created table return(table); }
// Creates table. public static TableSnapshot <GraphicsArrayData> CreateTable(StoreSnapshot store) { TableSnapshot <GraphicsArrayData> table = new TableSnapshot <GraphicsArrayData>(store, "GraphicsArray", GraphicsArrayData.fields); // Create all but foreign keys of the table table.MakeUnique("PK_GraphicsArray", GraphicsArrayData.GraphicsArrayIdField.Field, true); // Return created table return(table); }
// Creates table. public static TableSnapshot <SensorData> CreateTable(StoreSnapshot store) { TableSnapshot <SensorData> table = new TableSnapshot <SensorData>(store, "Sensor", SensorData.fields); // Create all but foreign keys of the table table.MakeUnique("PK_Sensor", SensorData.SensorIdField.Field, true); // Return created table return(table); }
// Creates table. public static TableSnapshot <CollapsedCategoryData> CreateTable(StoreSnapshot store) { TableSnapshot <CollapsedCategoryData> table = new TableSnapshot <CollapsedCategoryData>(store, "CollapsedCategory", CollapsedCategoryData.fields); // Create all but foreign keys of the table table.MakeUnique("PK_CollapsedCategory", CollapsedCategoryData.NameField.Field, true); // Return created table return(table); }
// Creates table. public static TableSnapshot <LogicalCircuitData> CreateTable(StoreSnapshot store) { TableSnapshot <LogicalCircuitData> table = new TableSnapshot <LogicalCircuitData>(store, "LogicalCircuit", LogicalCircuitData.fields); // Create all but foreign keys of the table table.MakeUnique("PK_LogicalCircuit", LogicalCircuitData.LogicalCircuitIdField.Field, true); table.MakeUnique("AK_LogicalCircuit_Name", LogicalCircuitData.NameField.Field, false); // Return created table return(table); }
// Creates table. public static TableSnapshot <WireData> CreateTable(StoreSnapshot store) { TableSnapshot <WireData> table = new TableSnapshot <WireData>(store, "Wire", WireData.fields); // Create all but foreign keys of the table table.MakeUnique("PK_Wire", WireData.WireIdField.Field, true); table.CreateIndex("IX_LogicalCircuit_Wire", WireData.LogicalCircuitIdField.Field); // Return created table return(table); }
// Creates table. public static TableSnapshot <CircuitProbeData> CreateTable(StoreSnapshot store) { TableSnapshot <CircuitProbeData> table = new TableSnapshot <CircuitProbeData>(store, "CircuitProbe", CircuitProbeData.fields); // Create all but foreign keys of the table table.MakeUnique("PK_CircuitProbe", CircuitProbeData.CircuitProbeIdField.Field, true); table.MakeUnique("AK_CircuitProbe_Name", CircuitProbeData.NameField.Field, false); // Return created table return(table); }
// Creates table. public static TableSnapshot <DevicePinData> CreateTable(StoreSnapshot store) { TableSnapshot <DevicePinData> table = new TableSnapshot <DevicePinData>(store, "DevicePin", DevicePinData.fields); // Create all but foreign keys of the table table.MakeUnique("PK_DevicePin", DevicePinData.PinIdField.Field, true); table.MakeUnique("AK_DevicePinName", DevicePinData.CircuitIdField.Field, DevicePinData.NameField.Field); table.CreateIndex("IX_Circuit_DevicePin", DevicePinData.CircuitIdField.Field); // Return created table return(table); }
private static bool Equal <T>(TableSnapshot <T> x, TableSnapshot <T> y) where T : struct { return(ProjectTester.EqualCount(x, y) && x.Zip(y, (RowId xr, RowId yr) => { T xd, yd; x.GetData(xr, out xd); y.GetData(yr, out yd); foreach (IField <T> field in x.Fields) { if (field.Compare(ref xd, ref yd) != 0) { return false; } } return true; }).All(r => r)); }
public RecordLoader(XmlNameTable nameTable, TableSnapshot <TRecord> table, Action <RowId> register) { Debug.Assert(nameTable != null); Debug.Assert(register != null); this.table = table; this.register = register; this.serializers = new Dictionary <string, IFieldSerializer <TRecord> >(XmlHelper.AtomComparer); foreach (IField <TRecord> field in this.table.Fields) { if (field is IFieldSerializer <TRecord> serializer) { string fieldName = nameTable.Add(field.Name); this.serializers.Add(fieldName, serializer); } } }
internal CircuitProbe FindOrCreate(RowId rowId) { Debug.Assert(!rowId.IsEmpty && !this.Table.IsDeleted(rowId), "Bad RowId"); CircuitProbe item; if ((item = this.Find(rowId)) != null) { Debug.Assert(!item.IsDeleted(), "Deleted item should not be present in the dictionary"); return(item); } Guid primaryKeyValue = this.Table.GetField(rowId, CircuitProbeData.CircuitProbeIdField.Field); TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); return(this.Create(rowId, tableCircuit.Find(CircuitData.CircuitIdField.Field, primaryKeyValue))); }
// Saves the table private static void SaveRecords <TRecord>(XmlWriter writer, TableSnapshot <TRecord> table) where TRecord : struct { foreach (RowId rowId in table.Rows) { TRecord data; table.GetData(rowId, out data); writer.WriteStartElement(table.Name, CircuitProject.PersistenceNamespace); foreach (IField <TRecord> field in table.Fields) { if (field is IFieldSerializer <TRecord> serializer && serializer.NeedToSave(ref data)) { writer.WriteStartElement(field.Name, CircuitProject.PersistenceNamespace); writer.WriteString(serializer.GetTextValue(ref data)); writer.WriteEndElement(); } } writer.WriteEndElement(); } }
// Creates Gate wrapper private Gate CreateItem( // Fields of Gate table Guid GateId // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = GateId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); GateData dataGate = new GateData() { GateId = GateId, }; return(this.Create(this.Table.Insert(ref dataGate), rowIdCircuit)); }
/// <summary> /// Initialize hasMapped dictionary with tableName /// To determinate which record has been mapped /// </summary> /// <param name="tableName"></param> /// <param name="sourceDatabase"></param> /// <param name="destinationDatabase"></param> protected void Initialize(string tableName, DatabaseSnapshot sourceSnapshot, DatabaseSnapshot destSnapshot, DatabaseSnapshot outputSnapshot) { //TableSnapshot sourceTable = sourceSnapshot.GetTableSnapshot(tableName); TableSnapshot destTable = destSnapshot.GetTableSnapshot(tableName); //// //// Get common record from source table and destTable //// Then try to save to database //TableSnapshot commonTable = TableSnapshot.GetCommonRecord(sourceTable, destTable); //if (commonTable.IsEmpty == false) //{ // this._listTableToCheck.Add(tableName); //} if (destTable.IsEmpty == false) { this._listTableToCheck.Add(tableName); } // // Add outputSnapshot.Add(destTable); LogService.Log.Info("Saved snapshot of table : " + tableName); }
// Creates DevicePin wrapper private DevicePin CreateItem( // Fields of DevicePin table Guid PinId, Circuit Circuit, int BitWidth, PinType PinType, PinSide PinSide, bool Inverted, string Name, string Note, string JamNotation // Fields of Circuit table ) { TableSnapshot <CircuitData> tableCircuit = (TableSnapshot <CircuitData>) this.CircuitProject.Table("Circuit"); CircuitData dataCircuit = new CircuitData() { CircuitId = PinId }; RowId rowIdCircuit = tableCircuit.Insert(ref dataCircuit); DevicePinData dataDevicePin = new DevicePinData() { PinId = PinId, CircuitId = (Circuit != null) ? Circuit.CircuitId : DevicePinData.CircuitIdField.Field.DefaultValue, BitWidth = BitWidth, PinType = PinType, PinSide = PinSide, Inverted = Inverted, Name = Name, Note = Note, JamNotation = JamNotation, }; return(this.Create(this.Table.Insert(ref dataDevicePin), rowIdCircuit)); }