示例#1
0
        public void AppendClass()
        {
            int i = 0;

            foreach (TableParser table in Tables.Items)
            {
                SexBuilder.AppendRowDef(sb, table);
            }

            foreach (TableParser table in Tables.Items)
            {
                sb.Append("(alias ");
                SexBuilder.AppendTableNameToLocalStructName(sb, table);
                sb.Append("Row ");

                AppendNamespace();
                sb.Append('.');
                SexBuilder.AppendTableNameToLocalStructName(sb, table);
                sb.Append("Row)\n");
            }

            sb.Append("\n(class CSXL0");
            AppendFilenameAsTypeName();
            sb.Append("Asset");

            sb.Append(" (defines ");
            AppendNamespace();
            sb.Append('.');
            AppendInterfaceShortName();
            sb.Append(")\n");

            i = 1;

            foreach (TableParser table in Tables.Items)
            {
                sb.Append("\t(array<");
                SexBuilder.AppendAsTypeName(sb, table.Name);
                sb.AppendFormat("Row> table{0}", i++);
                sb.Append(")\n");
            }

            sb.Append(")\n\n");

            i = 1;

            foreach (TableParser table in Tables.Items)
            {
                sb.Append("(method CSXL0");
                AppendFilenameAsTypeName();
                sb.Append("Asset.");
                SexBuilder.AppendAsTypeName(sb, table.Name);
                sb.Append(" -> (array<");
                SexBuilder.AppendAsTypeName(sb, table.Name);
                sb.AppendFormat("Row> table):\n\t(table = this.table{0})\n)\n", i++);
            }

            sb.Append("\n(method CSXL0.");
            AppendFilenameAsTypeName();
            sb.Append("Asset.Construct :\n");

            i = 1;
            foreach (TableParser table in Tables.Items)
            {
                sb.AppendFormat("\t(ConstructFromAppendix table{0} \"table{1}\")\n", i, i++);
            }

            sb.Append(")\n\n");

            i = 1;
            foreach (TableParser table in Tables.Items)
            {
                sb.AppendFormat("(factory ");
                AppendNamespace();
                sb.Append(".New");
                AppendFilenameAsTypeName();
                sb.Append(" ");
                AppendNamespace();
                sb.Append(".IAsset");
                AppendFilenameAsTypeName();
                sb.Append(": (construct CSXL0");
                AppendFilenameAsTypeName();
                sb.Append("))\n");
            }

            sb.Append("\n");

            i = 1;
            foreach (TableParser table in Tables.Items)
            {
                sb.AppendFormat("(' table{0} ", i++);
                SexBuilder.AppendTableNameToLocalStructName(sb, table);

                sb.Append("\n");

                Excel.Range item;

                for (int j = table.FirstRowIndex; j < table.FinalRowIndex; ++j)
                {
                    sb.Append("\t(");

                    for (int k = table.FirstColumnIndex; k < table.FinalColumnIndex; ++k)
                    {
                        if (k != table.FirstColumnIndex)
                        {
                            sb.Append("\t");
                        }

                        string entry = table.GetCellText(k, j, out item);

                        Excel.Range typeEntry;
                        string      type = table.GetFieldType(k, out typeEntry);
                        if (type == "string")
                        {
                            bool usesQuotes = SexBuilder.HasEscapedCharacters(entry);
                            if (usesQuotes)
                            {
                                sb.Append("\"");
                            }

                            SexBuilder.AddEscapedText(sb, entry);

                            if (usesQuotes)
                            {
                                sb.Append("\"");
                            }
                        }
                        else
                        {
                            SexBuilder.AppendMakeSexyCase(sb, entry);
                        }
                    }

                    sb.Append(")\n");
                }

                sb.AppendFormat(")\n");
            }
        }
示例#2
0
 public void AppendHeaders()
 {
     sb.AppendFormat("(' generator: Sexel 1.0.0.0 from: \"");
     SexBuilder.AddEscapedText(sb, Filename);
     sb.AppendFormat("\")\n\n");
 }