Пример #1
0
        public void FillFieldDefinition(NetLanguage leng, StringBuilder sb, bool properties)
        {
            AddMainAttributes(leng, sb);

            if (TrimMode != TrimMode.None)
            {
                switch (leng)
                {
                case NetLanguage.VbNet:
                    sb.Append(IndentString);
                    sb.AppendLine("<FieldTrim(TrimMode." + TrimMode.ToString() + ")> ");
                    break;

                case NetLanguage.CSharp:
                    sb.Append(IndentString);
                    sb.AppendLine("[FieldTrim(TrimMode." + TrimMode.ToString() + ")]");
                    break;

                default:
                    break;
                }
            }

            if (mIsOptional == true)
            {
                switch (leng)
                {
                case NetLanguage.VbNet:
                    sb.Append(IndentString);
                    sb.AppendLine("<FieldOptional()> _");
                    break;

                case NetLanguage.CSharp:
                    sb.Append(IndentString);
                    sb.AppendLine("[FieldOptional()]");
                    break;

                default:
                    break;
                }
            }

            if (sb.ToString(sb.Length - 2, 2) != Environment.NewLine)
            {
                sb.AppendLine();
            }
            sb.Append(IndentString);


            string visi = EnumHelper.GetVisibility(leng, mVisibility);

            string usedname;

            usedname = this.Name;

            if (properties)
            {
                usedname = "m" + this.Name;
                visi     = EnumHelper.GetVisibility(leng, NetVisibility.Private);
            }

            switch (leng)
            {
            case NetLanguage.VbNet:
                sb.AppendLine(visi + " " + usedname + " As " + this.Type);
                break;

            case NetLanguage.CSharp:
                sb.AppendLine(visi + " " + this.Type + " " + usedname + ";");
                break;

            default:
                break;
            }

            sb.AppendLine();
        }
Пример #2
0
        public string WizardOutput(NetLanguage leng)
        {
            StringBuilder sb = new StringBuilder(500);

            switch (leng)
            {
            case NetLanguage.VbNet:
                if (RecordKind == RecordKind.FixedLength)
                {
                    sb.AppendLine("<FixedLengthRecord()> _");
                }
                else
                {
                    sb.AppendLine("<DelimitedRecord(\"" + Delimiter + "\") >_");
                }

                if (IgnoreFirst > 0)
                {
                    sb.AppendLine("<IgnoreFirst(" + IgnoreFirst.ToString() + ")> _");
                }

                if (IgnoreLast > 0)
                {
                    sb.AppendLine("<IgnoreLast(" + IgnoreLast.ToString() + ")> _");
                }

                if (IgnoreEmptyLines)
                {
                    sb.AppendLine("<IgnoreEmptyLines()> _");
                }

                sb.Append(EnumHelper.GetVisibility(leng, mClassVisibility));

                if (mMarkAsSealed)
                {
                    sb.Append(" Not Inheritable");
                }

                sb.AppendLine(" Class " + this.mClassName);
                sb.AppendLine();
                break;

            case NetLanguage.CSharp:
                if (RecordKind == RecordKind.FixedLength)
                {
                    sb.AppendLine("[FixedLengthRecord()]");
                }
                else
                {
                    sb.AppendLine("[DelimitedRecord(\"" + Delimiter + "\")]");
                }

                if (IgnoreEmptyLines)
                {
                    sb.AppendLine("[IgnoreEmptyLines()]");
                }

                if (IgnoreFirst > 0)
                {
                    sb.AppendLine("[IgnoreFirst(" + IgnoreFirst.ToString() + ")]");
                }

                if (IgnoreLast > 0)
                {
                    sb.AppendLine("[IgnoreLast(" + IgnoreLast.ToString() + ")]");
                }

                sb.Append(EnumHelper.GetVisibility(leng, mClassVisibility));

                if (mMarkAsSealed)
                {
                    sb.Append(" sealed");
                }

                sb.AppendLine(" class " + this.mClassName);
                sb.AppendLine("{");
                break;

            default:
                break;
            }

            foreach (DesignFieldInfoBase info in mFields)
            {
                info.FillFieldDefinition(leng, sb, mUseProperties);

                if (mUseProperties)
                {
                    info.CreateProperty(leng, sb);
                }
            }

            // Append End

            switch (leng)
            {
            case NetLanguage.VbNet:
                sb.AppendLine("End Class");
                break;

            case NetLanguage.CSharp:
                sb.AppendLine("}");
                break;

            default:
                break;
            }


            return(sb.ToString());
        }