import CSSettingsV3Example from "./CSSettingsV3Example";
import { StringExampleTable } from "./Tables/StringTableExample";

export default class TableUseExample {

	start() {

		// #region StringExample表
		console.log("----------------#stringExample");
		console.log(CSSettingsV3Example.StringExample instanceof StringExampleTable); // true
		console.log(Array.isArray(CSSettingsV3Example.StringExample)); // true, 所以Array相關的方法都可以拿來操作

		console.log(CSSettingsV3Example.StringExample.length);
		console.log(CSSettingsV3Example.StringExample.Count); // 跟length一樣

		console.log(CSSettingsV3Example.StringExample.ContainsRow(11)); // 是否包含id=11的Row
		console.log(11 in CSSettingsV3Example.StringExample); // 同上

		console.log(CSSettingsV3Example.StringExample[1].MsgZnCh);
		console.log(CSSettingsV3Example.StringExample[1]["MsgZnCh"]); // 同上
		console.log(CSSettingsV3Example["StringExample"][1]["MsgZnCh"]); // 同上

		console.log("----------------");
		for (let row of CSSettingsV3Example.StringExample) {
			if (row) { // 如果Row沒有連號, 那有可能取到undefined值, 要先判斷, 不想判斷就用 CSSettings.StringExample.Rows
				console.log(row.Id, row.MsgZnCh);
			}
		}

		console.log("----------------");
		for (let id of CSSettingsV3Example.StringExample.Keys) {
			console.log(id); // 只會列出有值的id, undefined會跳過
		}

		console.log("----------------");
		for (let row of CSSettingsV3Example.StringExample.Rows) {
			console.log(row.Id, row.MsgZnCh); // 只會列出有值的Row, undefined會跳過
		}
		// #endregion

		// #region StringExample表 #StringFilter表
		console.log("----------------#stringExample#string_filter");
		// console.log(CSSettings.StringExample.StringFilter instanceof StringFilterTable); // true
		console.log(Array.isArray(CSSettingsV3Example.StringExample.StringFilter)); // true, 所以Array相關的方法都可以拿來操作

		console.log(CSSettingsV3Example.StringExample.StringFilter.length);
		console.log(CSSettingsV3Example.StringExample.StringFilter.Count); // 跟length一樣

		console.log(CSSettingsV3Example.StringExample.StringFilter.ContainsRow(11)); // 是否包含id=11的Row
		console.log(11 in CSSettingsV3Example.StringExample.StringFilter); // 同上

		console.log(CSSettingsV3Example.StringExample.StringFilter[1].FilterWord);
		console.log(CSSettingsV3Example.StringExample.StringFilter[1]["FilterWord"]); // 同上
		console.log(CSSettingsV3Example["StringExample"]["StringFilter"][1]["FilterWord"]); // 同上

		console.log("----------------");
		for (let row of CSSettingsV3Example.StringExample.StringFilter) {
			if (row) { // 如果Row沒有連號, 那有可能取到undefined值, 要先判斷, 不想判斷就用 CSSettings.StringExample.StringFilter.Rows
				console.log(row.Id, row.FilterWord);
			}
		}

		console.log("----------------");
		for (let id of CSSettingsV3Example.StringExample.StringFilter.Keys) {
			console.log(id); // 只會列出有值的id, undefined會跳過
		}

		console.log("----------------");
		for (let row of CSSettingsV3Example.StringExample.StringFilter.Rows) {
			console.log(row.Id, row.FilterWord); // 只會列出有值的Row, undefined會跳過
		}
		// #endregion

		console.log("----------------");
		// CSSettingsV3.ResetTables(); // 重置表

	}
}
