• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NetLanguage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetFieldCode

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


示例17: ExampleFile

 public ExampleFile(string filename, NetLanguage language)
 {
     Filename = filename;
     Language = language;
 }
开发者ID:MarcosMeli,项目名称:ExamplesFx,代码行数:5,代码来源:ExampleFile.cs


示例18: 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)
        {
            if (classStr.Length < 4)
                throw new BadUsageException("There is not enough text to be a proper class, load your class and try again");

            var cp = new CompilerParameters();

            //cp.ReferencedAssemblies.Add("System.dll");
            //cp.ReferencedAssemblies.Add("System.Data.dll");
            //cp.ReferencedAssemblies.Add(typeof(ClassBuilder).Assembly.GetModules()[0].FullyQualifiedName);

            bool mustAddSystemData = false;
            lock (mReferencesLock)
            {
                if (mReferences == null)
                {
                     ArrayList arr = new ArrayList();

                    foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                    {
                        Module module = assembly.GetModules()[0];
                        if (module.Name == "mscorlib.dll" || module.Name == "<Unknown>")
                            continue;

                        if (module.Name == "System.Data.dll")
                            mustAddSystemData = true;

                        if (File.Exists(module.FullyQualifiedName))
                            arr.Add(module.FullyQualifiedName);
                    }

                    mReferences = (string[]) arr.ToArray(typeof (string));
                }
            }

            cp.ReferencedAssemblies.AddRange(mReferences);

            cp.GenerateExecutable = false;
            cp.GenerateInMemory = true;
            cp.IncludeDebugInformation = false;

            var code = new StringBuilder();

            switch (lang)
            {
                case NetLanguage.CSharp:
                    code.Append("using System; using FileHelpers;");
                    if (mustAddSystemData) code.Append(" using System.Data;");
                    break;

                case NetLanguage.VbNet:

                    if (CultureInfo.CurrentCulture.CompareInfo.IndexOf(classStr, "Imports System", CompareOptions.IgnoreCase) == -1)
                        code.Append("Imports System\n");

                    if (CultureInfo.CurrentCulture.CompareInfo.IndexOf(classStr, "Imports FileHelpers", CompareOptions.IgnoreCase) == -1)
                        code.Append("Imports FileHelpers\n");

                    if (mustAddSystemData && CultureInfo.CurrentCulture.CompareInfo.IndexOf(classStr, "Imports System.Data", CompareOptions.IgnoreCase) == -1)
                        code.Append("Imports System.Data\n");

                    break;
            }

            code.Append(classStr);

            CompilerResults cr;

            CodeDomProvider prov = null;

            switch (lang)
            {
                case NetLanguage.CSharp:
                    prov = CodeDomProvider.CreateProvider("cs");
                    break;

                case NetLanguage.VbNet:
                    prov = CodeDomProvider.CreateProvider("vb");
                    break;
            }

            cr = prov.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.);
//.........这里部分代码省略.........
开发者ID:TheJeremyGray,项目名称:FileWatcherService,代码行数:101,代码来源:ClassBuilder.cs


示例19: EndNamespace

        /// <summary>
        /// Add the end of namespace to text
        /// </summary>
        /// <param name="lang">language we are generating</param>
        /// <param name="sb">class text to add to</param>
        private void EndNamespace(NetLanguage lang, StringBuilder sb)
        {
            if (mNamespace == string.Empty)
                return;

            sb.Append(StringHelper.NewLine);

            switch (lang)
            {
                case NetLanguage.CSharp:
                    sb.Append("}");
                    break;

                case NetLanguage.VbNet:
                    sb.Append("End Namespace");
                    break;
            }
        }
开发者ID:TheJeremyGray,项目名称:FileWatcherService,代码行数:23,代码来源:ClassBuilder.cs


示例20: SaveToSourceFile

 /// <summary>Write the source code of the current class to a file. (In the specified language)</summary>
 /// <param name="filename">The file to write to.</param>
 /// <param name="lang">The .NET Language used to write the source code.</param>
 public void SaveToSourceFile(string filename, NetLanguage lang)
 {
     var writer = new StreamWriter(filename);
     writer.Write(GetClassSourceCode(lang));
     writer.Close();
 }
开发者ID:TheJeremyGray,项目名称:FileWatcherService,代码行数:9,代码来源:ClassBuilder.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NetMQMessage类代码示例发布时间:2022-05-24
下一篇:
C# NetInfo类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap