internal override void AddAttributesCode(AttributesBuilder attbs, NetLanguage lang)
        {
            if (mFieldLength <= 0)
                throw new BadUsageException("The Length of each field must be grater than 0");
            else
                attbs.AddAttribute("FieldFixedLength("+ mFieldLength.ToString() +")");

            if (mAlignMode != AlignMode.Left)
            {
                if (lang == NetLanguage.CSharp)
                    attbs.AddAttribute("FieldAlign(AlignMode."+ mAlignMode.ToString()+", '"+ mAlignChar.ToString() +"')");

                else if (lang == NetLanguage.VbNet)
                    attbs.AddAttribute("FieldAlign(AlignMode."+ mAlignMode.ToString()+", \""+ mAlignChar.ToString() +"\"c)");
            }
        }
        internal override void AddAttributesCode(AttributesBuilder attbs, NetLanguage leng)
        {
            if (mFieldQuoted == true)
            {
                if (leng == NetLanguage.CSharp)
                {
                    string quoteStr = mQuoteChar.ToString();
                    if (mQuoteChar == '\'') quoteStr = @"\'";

                    attbs.AddAttribute("FieldQuoted('" + quoteStr + "', QuoteMode." + mQuoteMode.ToString()+", MultilineMode." + mQuoteMultiline.ToString() +")");
                }
                else if (leng == NetLanguage.VbNet)
                {
                    string quoteStr = mQuoteChar.ToString();
                    if (mQuoteChar == '"') quoteStr = "\"\"";

                    attbs.AddAttribute("FieldQuoted(\"" + quoteStr + "\"c, QuoteMode." + mQuoteMode.ToString()+", MultilineMode." + mQuoteMultiline.ToString() +")");
                }
            }
        }
        private void AddAttributesInternal(AttributesBuilder attbs, NetLanguage leng)
        {
            if (mFieldOptional == true)
                attbs.AddAttribute("FieldOptional()");

            if (mFieldIgnored == true)
                attbs.AddAttribute("FieldIgnored()");

            if (mFieldInNewLine == true)
                attbs.AddAttribute("FieldInNewLine()");

            if (mFieldNullValue != null)
            {
                if (mFieldNullValue is string)
                    attbs.AddAttribute("FieldNullValue(\"" + mFieldNullValue.ToString() + "\")");
                else
                {
                    string t = ClassBuilder.TypeToString(mFieldNullValue.GetType());
                    string gt = string.Empty;
                    if (leng == NetLanguage.CSharp)
                        gt = "typeof(" + t + ")";
                    else if (leng == NetLanguage.VbNet)
                        gt = "GetType(" + t + ")";

                    attbs.AddAttribute("FieldNullValue("+ gt +", \""+ mFieldNullValue.ToString() +"\")");
                }
            }

            attbs.AddAttribute(mConverter.GetConverterCode(leng));

            if (mTrimMode != TrimMode.None)
            {
                if (" \t" == mTrimChars)
                    attbs.AddAttribute("FieldTrim(TrimMode."+ mTrimMode.ToString()+")");
                else
                    attbs.AddAttribute("FieldTrim(TrimMode." + mTrimMode.ToString() + ", \"" + mTrimChars.ToString() + "\")");
            }
        }
        internal string GetFieldCode(NetLanguage lang)
        {
            StringBuilder sb = new StringBuilder(100);

            AttributesBuilder attbs = new AttributesBuilder(lang);

            AddAttributesInternal(attbs, lang);
            AddAttributesCode(attbs, lang);

            sb.Append(attbs.GetAttributesCode());

            NetVisibility visi = mVisibility;
            string currentName = mFieldName;

            if (mClassBuilder.GenerateProperties)
            {
                visi = NetVisibility.Private;
                currentName = "m" + mFieldName;
            }

            switch (lang)
            {
                case NetLanguage.VbNet:
                    sb.Append(ClassBuilder.GetVisibility(lang, visi) + currentName + " As " + mFieldType);
                    break;
                case NetLanguage.CSharp:
                    sb.Append(ClassBuilder.GetVisibility(lang, visi) + mFieldType + " " + currentName+ ";");
                    break;
                default:
                    break;
            }

            sb.Append(StringHelper.NewLine);

            if (mClassBuilder.GenerateProperties)
            {
                sb.Append(StringHelper.NewLine);

                switch (lang)
                {
                    case NetLanguage.VbNet:
                        sb.Append("Public Property " + mFieldName + " As " + mFieldType);
                        sb.Append(StringHelper.NewLine);
                        sb.Append("   Get");
                        sb.Append(StringHelper.NewLine);
                        sb.Append("      Return m" + mFieldName);
                        sb.Append(StringHelper.NewLine);
                        sb.Append("   End Get");
                        sb.Append(StringHelper.NewLine);
                        sb.Append("   Set (value As " + mFieldType + ")");
                        sb.Append(StringHelper.NewLine);
                        sb.Append("      m" + mFieldName + " = value");
                        sb.Append(StringHelper.NewLine);
                        sb.Append("   End Set");
                        sb.Append(StringHelper.NewLine);
                        sb.Append("End Property");
                        break;
                    case NetLanguage.CSharp:
                        sb.Append("public " + mFieldType + " " + mFieldName);
                        sb.Append(StringHelper.NewLine);
                        sb.Append("{");
                        sb.Append(StringHelper.NewLine);
                        sb.Append("   get { return m" + mFieldName + "; }");
                        sb.Append(StringHelper.NewLine);
                        sb.Append("   set { m" + mFieldName + " = value; }");
                        sb.Append(StringHelper.NewLine);
                        sb.Append("}");
                        break;
                    default:
                        break;
                }

                sb.Append(StringHelper.NewLine);
                sb.Append(StringHelper.NewLine);
            }

            return sb.ToString();
        }
 internal abstract void AddAttributesCode(AttributesBuilder attbs, NetLanguage leng);
 internal override void AddAttributesCode(AttributesBuilder attbs)
 {
     attbs.AddAttribute("FixedLengthRecord(FixedMode."+ mFixedMode.ToString()+ ")");
 }
 internal override void AddAttributesCode(AttributesBuilder attbs)
 {
     if (mDelimiter == string.Empty)
         throw new BadUsageException("The Delimiter of the DelimiterClassBuilder can't be null or empty.");
     else
         attbs.AddAttribute("DelimitedRecord(\""+ mDelimiter +"\")");
 }
Esempio n. 8
0
		private void AddAttributesInternal(AttributesBuilder attbs, NetLanguage lang)
		{

			if (mIgnoreFirstLines != 0)
				attbs.AddAttribute("IgnoreFirst("+ mIgnoreFirstLines.ToString() +")");

			if (mIgnoreLastLines != 0)
				attbs.AddAttribute("IgnoreLast("+ mIgnoreLastLines.ToString() +")");

			if (mIgnoreEmptyLines == true)
				attbs.AddAttribute("IgnoreEmptyLines()");

            if (mRecordConditionInfo.Condition != FileHelpers.RecordCondition.None)
                attbs.AddAttribute("ConditionalRecord(RecordCondition." + mRecordConditionInfo.Condition.ToString() + ", \"" + mRecordConditionInfo.Selector + "\")");

            if (mIgnoreCommentInfo.CommentMarker != null && mIgnoreCommentInfo.CommentMarker.Length > 0)
                attbs.AddAttribute("IgnoreCommentedLines(\""+mIgnoreCommentInfo.CommentMarker+ "\", " + mIgnoreCommentInfo.InAnyPlace.ToString().ToLower() + ")");
		
		}
Esempio n. 9
0
		/// <summary>
		/// Returns the source code for the current class in the specified language.
		/// </summary>
		/// <param name="lang">The language for the return code.</param>
		/// <returns>The Source Code for the class that are currently building.</returns>
		public string GetClassSourceCode(NetLanguage lang)
		{
			StringBuilder sb = new StringBuilder(100);
			
			BeginNamespace(lang, sb);
			
			AttributesBuilder attbs = new AttributesBuilder(lang);
			
			AddAttributesInternal(attbs, lang);
			AddAttributesCode(attbs, lang);
			
			sb.Append(attbs.GetAttributesCode());
			
			switch (lang)
			{
				case NetLanguage.VbNet:
					sb.Append(GetVisibility(lang, mVisibility) + GetSealed(lang) + "Class " + mClassName);
					sb.Append(StringHelper.NewLine);
					break;
				case NetLanguage.CSharp:
					sb.Append(GetVisibility(lang, mVisibility) + GetSealed(lang) + "class " + mClassName);
					sb.Append(StringHelper.NewLine);
					sb.Append("{");
					break;
			}

			sb.Append(StringHelper.NewLine);
			sb.Append(StringHelper.NewLine);

			foreach (FieldBuilder field in mFields)
			{
				sb.Append(field.GetFieldCode(lang));
				sb.Append(StringHelper.NewLine);
			}
			
			
			sb.Append(StringHelper.NewLine);
			
			switch (lang)
			{
				case NetLanguage.VbNet:
					sb.Append("End Class");
					break;
				case NetLanguage.CSharp:
					sb.Append("}");
					break;
			}

			EndNamespace(lang, sb);
			
			return sb.ToString();
			
		
		}
Esempio n. 10
0
 internal abstract void AddAttributesCode(AttributesBuilder attbs);
Esempio n. 11
0
 internal abstract void AddAttributesCode(AttributesBuilder attbs, NetLanguage leng);
Esempio n. 12
0
        internal string GetFieldCode(NetLanguage lang)
        {
            StringBuilder sb = new StringBuilder(100);

            AttributesBuilder attbs = new AttributesBuilder(lang);

            AddAttributesInternal(attbs, lang);
            AddAttributesCode(attbs, lang);

            sb.Append(attbs.GetAttributesCode());

            NetVisibility visi        = mVisibility;
            string        currentName = mFieldName;

            if (mClassBuilder.GenerateProperties)
            {
                visi        = NetVisibility.Private;
                currentName = "m" + mFieldName;
            }

            switch (lang)
            {
            case NetLanguage.VbNet:
                sb.Append(ClassBuilder.GetVisibility(lang, visi) + currentName + " As " + mFieldType);
                break;

            case NetLanguage.CSharp:
                sb.Append(ClassBuilder.GetVisibility(lang, visi) + mFieldType + " " + currentName + ";");
                break;

            default:
                break;
            }

            sb.Append(StringHelper.NewLine);

            if (mClassBuilder.GenerateProperties)
            {
                sb.Append(StringHelper.NewLine);

                switch (lang)
                {
                case NetLanguage.VbNet:
                    sb.Append("Public Property " + mFieldName + " As " + mFieldType);
                    sb.Append(StringHelper.NewLine);
                    sb.Append("   Get");
                    sb.Append(StringHelper.NewLine);
                    sb.Append("      Return m" + mFieldName);
                    sb.Append(StringHelper.NewLine);
                    sb.Append("   End Get");
                    sb.Append(StringHelper.NewLine);
                    sb.Append("   Set (value As " + mFieldType + ")");
                    sb.Append(StringHelper.NewLine);
                    sb.Append("      m" + mFieldName + " = value");
                    sb.Append(StringHelper.NewLine);
                    sb.Append("   End Set");
                    sb.Append(StringHelper.NewLine);
                    sb.Append("End Property");
                    break;

                case NetLanguage.CSharp:
                    sb.Append("public " + mFieldType + " " + mFieldName);
                    sb.Append(StringHelper.NewLine);
                    sb.Append("{");
                    sb.Append(StringHelper.NewLine);
                    sb.Append("   get { return m" + mFieldName + "; }");
                    sb.Append(StringHelper.NewLine);
                    sb.Append("   set { m" + mFieldName + " = value; }");
                    sb.Append(StringHelper.NewLine);
                    sb.Append("}");
                    break;

                default:
                    break;
                }

                sb.Append(StringHelper.NewLine);
                sb.Append(StringHelper.NewLine);
            }

            return(sb.ToString());
        }