当前位置: 首页>>代码示例>>C#>>正文


C# NetLanguage类代码示例

本文整理汇总了C#中NetLanguage的典型用法代码示例。如果您正苦于以下问题:C# NetLanguage类的具体用法?C# NetLanguage怎么用?C# NetLanguage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NetLanguage类属于命名空间,在下文中一共展示了NetLanguage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WizardOutput

        //private NetVisibility mClassVisibility = NetVisibility.Public;

        //public NetVisibility ClassVisibility
        //{
        //    get { return mClassVisibility; }
        //    set { mClassVisibility = value; }
        //}


        public string WizardOutput(NetLanguage lang)
        {
            if (mClassBuilder == null)
                return string.Empty;

            return mClassBuilder.GetClassSourceCode(lang);
        }
开发者ID:BD-GitHub,项目名称:filehelpers,代码行数:16,代码来源:WizardInfo.cs

示例2: GetVisibility

        public static string GetVisibility(NetLanguage leng, NetVisibility visi)
        {
            switch (leng) {
                case NetLanguage.VbNet:
                    switch (visi) {
                        case NetVisibility.Private:
                            return "Private";
                        case NetVisibility.Protected:
                            return "Protected";
                        case NetVisibility.Public:
                            return "Public";
                        case NetVisibility.Internal:
                            return "Friend";
                    }
                    break;
                case NetLanguage.CSharp:
                    switch (visi) {
                        case NetVisibility.Private:
                            return "private";
                        case NetVisibility.Protected:
                            return "protected";
                        case NetVisibility.Public:
                            return "public";
                        case NetVisibility.Internal:
                            return "internal";
                    }
                    break;
                default:
                    break;
            }

            return "";
        }
开发者ID:calebillman,项目名称:FileHelpers,代码行数:33,代码来源:Enums.cs

示例3: GetConverterCode

        /// <summary>
        /// Create the converter in source code
        /// </summary>
        /// <param name="lang">C# or Visual Basic</param>
        /// <returns>Converter attribute in appropriate language</returns>
        internal string GetConverterCode(NetLanguage lang)
        {
            var sb = new StringBuilder();

            if (mKind != ConverterKind.None)
                sb.Append("FieldConverter(ConverterKind." + mKind.ToString());
            else if (mTypeName != string.Empty)
            {
                if (lang == NetLanguage.CSharp)
                    sb.Append("FieldConverter(typeof(" + mTypeName + ")");
                else if (lang == NetLanguage.VbNet)
                    sb.Append("FieldConverter(GetType(" + mTypeName + ")");
            }
            else
                return string.Empty;

            if (!string.IsNullOrEmpty(mArg1))
            {
                sb.Append(", \"" + mArg1 + "\"");

                if (!string.IsNullOrEmpty(mArg2))
                {
                    sb.Append(", \"" + mArg2 + "\"");

                    if (!string.IsNullOrEmpty(mArg3))
                    {
                        sb.Append(", \"" + mArg3 + "\"");
                    }
                }
            }

            sb.Append(")");

            return sb.ToString();
        }
开发者ID:rohancragg,项目名称:FileHelpers,代码行数:40,代码来源:ConverterBuilder.cs

示例4: ClassFromString

        /// <summary>Compiles the source code passed and returns the Type with the name className.</summary>
        /// <param name="classStr">The Source Code of the class in the specified language</param>
        /// <param name="className">The Name of the Type that must be returned</param>
        /// <returns>The Type generated by runtime compilation of the class source.</returns>
        /// <param name="lang">One of the .NET Languages</param>
        public static Type ClassFromString(string classStr, string className, NetLanguage lang)
        {
            var cp = new CompilerParameters();
            cp.ReferencedAssemblies.Add("system.dll");
            cp.ReferencedAssemblies.Add("system.data.dll");
            cp.ReferencedAssemblies.Add(typeof (ClassBuilder).Assembly.GetModules()[0].FullyQualifiedName);
            cp.GenerateExecutable = false;
            cp.GenerateInMemory = true;
            cp.IncludeDebugInformation = false;

            var code = new StringBuilder();

            switch (lang)
            {
                case NetLanguage.CSharp:
                    code.Append("using System; using Transformalize.Libs.FileHelpers.Attributes; using Transformalize.Libs.FileHelpers.Enums; using System.Data; ");
                    break;

                case NetLanguage.VbNet:
                    code.Append("Imports System \n");
                    code.Append("Imports FileHelpers \n");
                    code.Append("Imports System.Data \n");
                    break;
            }

            code.Append(classStr);

            var comp = new CSharpCodeProvider();
            var cr = comp.CompileAssemblyFromSource(cp, code.ToString());

            if (cr.Errors.HasErrors)
            {
                var error = new StringBuilder();
                error.Append("Error Compiling Expression: " + StringHelper.NewLine);
                foreach (CompilerError err in cr.Errors)
                {
                    error.AppendFormat("Line {0}: {1}\n", err.Line, err.ErrorText);
                }
                throw new RunTimeCompilationException(error.ToString(), classStr, cr.Errors);
            }

            //            Assembly.Load(cr.CompiledAssembly.);
            if (className != string.Empty)
                return cr.CompiledAssembly.GetType(className, true, true);
            else
            {
                var ts = cr.CompiledAssembly.GetTypes();
                if (ts.Length > 0)
                    foreach (var t in ts)
                    {
                        if (t.FullName.StartsWith("My.My") == false)
                            return t;
                    }

                throw new BadUsageException("The Compiled assembly don´t have any Type inside.");
            }
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:62,代码来源:ClassBuilder.cs

示例5: frmDataPreview

 public frmDataPreview(string data, NetLanguage language)
 {
     InitializeComponent();
     ShowCode(data, language);
     //sdClassOut.Text = data;
     cboClassLanguage.Items.Clear();
     cboClassLanguage.Items.AddRange(NetLanguageList.Languages.ToArray());
     NetLanguageList.LanguageType selected = NetLanguageList.Languages.Find(x => x.Language == language);
     cboClassLanguage.SelectedItem = selected;
 }
开发者ID:smwhit,项目名称:FileHelpers-fork,代码行数:10,代码来源:frmDataPreview.cs

示例6: frmDataPreview

        public frmDataPreview(string data, NetLanguage language)
        {
            InitializeComponent();
            ShowCode(data, language);
            //sdClassOut.Text = data;
            cboClassLanguage.Items.Clear();
            cboClassLanguage.Items.Add(NetLanguage.CSharp);
            cboClassLanguage.Items.Add(NetLanguage.VbNet);

            cboClassLanguage.SelectedItem = language;
        }
开发者ID:mgmccarthy,项目名称:FileHelpers,代码行数:11,代码来源:frmDataPreview.cs

示例7: AddAttributesCode

        /// <summary>
        /// Add attributes to the field at the appropriate spot in the code
        /// </summary>
        /// <param name="attbs">Add attributes to this</param>
        /// <param name="lang">Language to use,  C# of Visual Basic</param>
        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)");
            }
        }
开发者ID:jonswaino,项目名称:FileHelpers-fork,代码行数:20,代码来源:FixedFieldBuilder.cs

示例8: WizardOutput

        //private NetVisibility mClassVisibility = NetVisibility.Public;
        //public NetVisibility ClassVisibility
        //{
        //    get { return mClassVisibility; }
        //    set { mClassVisibility = value; }
        //}
        public string WizardOutput(NetLanguage lang)
        {
            if (mClassBuilder == null)
                return string.Empty;

            try
            {
                return mClassBuilder.GetClassSourceCode(lang);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "Error generating class code", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return ex.Message;
            }
        }
开发者ID:hoffmanc,项目名称:FileHelpers,代码行数:21,代码来源:WizardInfo.cs

示例9: ShowCode

 private void ShowCode(string code, NetLanguage language)
 {
     mLastCode = code;
     browserCode.DocumentText = "";
     var colorizer = new CodeColorizer();
     switch (language) {
         case NetLanguage.CSharp:
             browserCode.DocumentText = GetDefaultCss() + colorizer.Colorize(code, Languages.CSharp);
             break;
         case NetLanguage.VbNet:
             browserCode.DocumentText = GetDefaultCss() + colorizer.Colorize(code, Languages.VbDotNet);
             break;
         default:
             throw new ArgumentOutOfRangeException("language");
     }
 }
开发者ID:mgmccarthy,项目名称:FileHelpers,代码行数:16,代码来源:frmDataPreview.cs

示例10: AddAttributesCode

        internal override void AddAttributesCode(AttributesBuilder attbs, NetLanguage leng)
        {
            if (mFieldQuoted)
            {
                if (leng == NetLanguage.CSharp)
                {
                    var quoteStr = mQuoteChar.ToString();
                    if (mQuoteChar == '\'') quoteStr = @"\'";

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

                    attbs.AddAttribute("FieldQuoted(\"" + quoteStr + "\"c, QuoteMode." + mQuoteMode.ToString() + ", MultilineMode." + mQuoteMultiline.ToString() + ")");
                }
            }
        }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:20,代码来源:DelimitedFieldBuilder.cs

示例11: GetDelimiter

        private static string GetDelimiter(string delimiter, NetLanguage lang)
        {
            switch (lang)
            {
                case NetLanguage.CSharp:
                    if (delimiter == "\t")
                        return "\"\\t\"";
                    else
                        return "\"" + delimiter + "\"";

                case NetLanguage.VbNet:
                    if (delimiter == "\t")
                        return "VbTab";
                    else
                        return "\"" + delimiter + "\"";
                default:
                    throw new ArgumentOutOfRangeException("lang");
            }
        }
开发者ID:rohancragg,项目名称:FileHelpers,代码行数:19,代码来源:DelimitedClassBuilder.cs

示例12: AddAttributesCode

 /// <summary>
 /// Add any attributes to source (currently only the delimiter attribute)
 /// </summary>
 /// <param name="attbs">Attributes storage area to add to class</param>
 /// <param name="lang"></param>
 internal override void AddAttributesCode(AttributesBuilder attbs, NetLanguage lang)
 {
     if (mDelimiter == string.Empty)
         throw new BadUsageException("The Delimiter of the DelimiterClassBuilder can't be null or empty.");
     else
         attbs.AddAttribute("DelimitedRecord("+ GetDelimiter(mDelimiter, lang) +")");
 }
开发者ID:rohancragg,项目名称:FileHelpers,代码行数:12,代码来源:DelimitedClassBuilder.cs

示例13: ClassFromSourceFile

 /// <summary>
 /// Create a class from a source file.
 /// </summary>
 /// <param name="filename">The filename with the source of the class.</param>
 /// <param name="lang">The language used to compile the class.</param>
 /// <returns>The compiled class.</returns>
 public static Type ClassFromSourceFile(string filename, NetLanguage lang)
 {
     return ClassFromSourceFile(filename, string.Empty, lang);
 }
开发者ID:TheJeremyGray,项目名称:FileWatcherService,代码行数:10,代码来源:ClassBuilder.cs

示例14: AddAttributesCode

 internal override void AddAttributesCode(AttributesBuilder attbs, NetLanguage leng)
 {
     attbs.AddAttribute("FixedLengthRecord(FixedMode." + mFixedMode.ToString() + ")");
 }
开发者ID:modulexcite,项目名称:Transformalize,代码行数:4,代码来源:FixedLengthClassBuilder.cs

示例15: GetClassSourceCode

        /// <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)
        {
            ValidateClass();

            StringBuilder sb = new StringBuilder(100);

            BeginNamespace(lang, sb);

            AttributesBuilder attbs = new AttributesBuilder(lang);

            AddAttributesInternal(attbs);
            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();
        }
开发者ID:TheJeremyGray,项目名称:FileWatcherService,代码行数:58,代码来源:ClassBuilder.cs


注:本文中的NetLanguage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。