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


C# Language.ToString方法代码示例

本文整理汇总了C#中System.Language.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Language.ToString方法的具体用法?C# Language.ToString怎么用?C# Language.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Language的用法示例。


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

示例1: TestCodeGeneration

        public async Task TestCodeGeneration(string resourceBaseName, Language language)
        {
            var inputResourceName = "BrightstarDB.CodeGeneration.Tests.GeneratorTestsResources." + resourceBaseName + "Input_" + language.ToString() + ".txt";
            var outputResourceName = "BrightstarDB.CodeGeneration.Tests.GeneratorTestsResources." + resourceBaseName + "Output_" + language.ToString() + ".txt";

            using (var inputStream = this.GetType().Assembly.GetManifestResourceStream(inputResourceName))
            using (var outputStream = this.GetType().Assembly.GetManifestResourceStream(outputResourceName))
            using (var outputStreamReader = new StreamReader(outputStream))
            {
                var workspace = new AdhocWorkspace();
                var projectId = ProjectId.CreateNewId();
                var versionStamp = VersionStamp.Create();
                var projectInfo = ProjectInfo.Create(
                    projectId,
                    versionStamp,
                    "AdhocProject",
                    "AdhocProject",
                    language.ToSyntaxGeneratorLanguageName(),
                    metadataReferences: new[]
                    {
                        MetadataReference.CreateFromFile(typeof(object).Assembly.Location),
                        MetadataReference.CreateFromFile(typeof(Uri).Assembly.Location),
                        MetadataReference.CreateFromFile(typeof(BrightstarException).Assembly.Location)
                    });
                var project = workspace.AddProject(projectInfo);
                workspace.AddDocument(projectId, "Source.cs", SourceText.From(inputStream));
                var solution = workspace.CurrentSolution;

                var results = await Generator
                    .GenerateAsync(
                        language,
                        solution,
                        "BrightstarDB.CodeGeneration.Tests",
                        interfacePredicate: x => true);
                var result = results
                    .Aggregate(
                        new StringBuilder(),
                        (current, next) => current.AppendLine(next.ToString()),
                        x => x.ToString());

                var expectedCode = outputStreamReader.ReadToEnd();

                // make sure version changes don't break the tests
                expectedCode = expectedCode.Replace("$VERSION$", typeof(BrightstarException).Assembly.GetName().Version.ToString());

                //// useful when converting generated code to something that can be pasted into an expectation file
                //var sanitisedResult = result.Replace("1.10.0.0", "$VERSION$");
                //System.Diagnostics.Debug.WriteLine(sanitisedResult);

                Assert.AreEqual(expectedCode, result);
            }
        }
开发者ID:jamescoffman23,项目名称:BrightstarDB,代码行数:52,代码来源:GeneratorTests.cs

示例2: can_generate_simple_mock

        // TODO: VB is totally borked - calls to syntaxGenerator.WithStatements don't seem to add the statements! Will need to look into this at a later date
        //[InlineData("SimpleInterface", Language.VisualBasic)]
        //[InlineData("InterfaceWithGenericMethods", Language.VisualBasic)]
        //[InlineData("GenericInterface", Language.VisualBasic)]
        //[InlineData("InterfaceWithNonMockableMembers", Language.VisualBasic)]
        //[InlineData("PartialInterface", Language.VisualBasic)]
        //[InlineData("InheritingInterface", Language.VisualBasic)]
        public async Task can_generate_simple_mock(string resourceBaseName, Language language)
        {
            var inputResourceName = "PCLMock.UnitTests.CodeGeneration.GeneratorFixtureResources." + resourceBaseName + "Input_" + language.ToString() + ".txt";
            var outputResourceName = "PCLMock.UnitTests.CodeGeneration.GeneratorFixtureResources." + resourceBaseName + "Output_" + language.ToString() + ".txt";

            using (var inputStream = this.GetType().Assembly.GetManifestResourceStream(inputResourceName))
            using (var outputStream = this.GetType().Assembly.GetManifestResourceStream(outputResourceName))
            using (var outputStreamReader = new StreamReader(outputStream))
            {
                var workspace = new AdhocWorkspace();
                var projectId = ProjectId.CreateNewId();
                var versionStamp = VersionStamp.Create();
                var projectInfo = ProjectInfo.Create(
                    projectId,
                    versionStamp,
                    "AdhocProject",
                    "AdhocProject",
                    language.ToSyntaxGeneratorLanguageName(),
                    metadataReferences: new[]
                    {
                        MetadataReference.CreateFromFile(typeof(object).Assembly.Location),
                        MetadataReference.CreateFromFile(typeof(Uri).Assembly.Location),
                        MetadataReference.CreateFromFile(typeof(MockBase<>).Assembly.Location)
                    });
                var project = workspace.AddProject(projectInfo);
                workspace.AddDocument(projectId, "Source.cs", SourceText.From(inputStream));
                var solution = workspace.CurrentSolution;

                var results =
                    (await Generator.GenerateMocksAsync(
                        language,
                        solution,
                        x => true,
                        x => "The.Namespace",
                        x => "Mock"));
                var result = results
                    .Single()
                    .ToString();

                var expectedCode = outputStreamReader.ReadToEnd();

                // make sure version changes don't break the tests
                expectedCode = expectedCode.Replace("$VERSION$", typeof(MockBase<>).Assembly.GetName().Version.ToString());

                // useful when converting generated code to something that can be pasted into an expectation file
                var sanitisedResult = result.Replace(typeof(MockBase<>).Assembly.GetName().Version.ToString(), "$VERSION$");

                Assert.Equal(expectedCode, result);
            }
        }
开发者ID:modulexcite,项目名称:PCLMock,代码行数:57,代码来源:GeneratorFixture.cs

示例3: SetLanguage

        public static void SetLanguage(Language language)
        {
            GlobalData.Current.Language = language;

            RegistryKey regKey = Registry.CurrentUser.OpenSubKey(GlobalData.RegPathBase, true);
            regKey.SetValue(GlobalData.RegValueLanguage, language.ToString());
        }
开发者ID:Qibbi,项目名称:OpenSAGE,代码行数:7,代码来源:Language.cs

示例4: Get

		internal static string Get(Language lang)
		{
			var type = typeof(Language);
			var member = type.GetField(lang.ToString());
			var attr = member.GetCustomAttributes(typeof(CountryCodeAttribute), false)[0] as CountryCodeAttribute;
			return attr.Code;
		}
开发者ID:returnString,项目名称:WordReference.NET,代码行数:7,代码来源:Language.cs

示例5: InitLanguage

        /// <summary>
        /// 字符资源
        /// </summary>
        /// <param name="currentLanguage">当前语言</param>
        public void InitLanguage(Language currentLanguage)
        {
            string tag = string.Empty;
            string text = string.Empty;
            string fileName = string.Format("Language\\{0}.xml", currentLanguage.ToString());
            XmlTextReader reader = new XmlTextReader(fileName);
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element: // The node is an element.
                        if (reader.Name == "Language")
                        {
                            continue;
                        }
                        tag = reader.Name.Trim();
                        text = reader.ReadInnerXml().Trim();
                        if (!string.IsNullOrEmpty(tag) && !string.IsNullOrEmpty(text))
                        {
                            _stringDic.Add(tag, text);
                            //System.Diagnostics.Debug.WriteLine(tag + ",");
                        }
                        break;
                }

            }
        }
开发者ID:kklik,项目名称:MagicMongoDBTool,代码行数:31,代码来源:StringResources.cs

示例6: BuildFunctionTree

        public static FunctionTree BuildFunctionTree(Guid userId,Language language)
        {
            FunctionTree tree = new FunctionTree();
            using (SqlConnection sqlConnection = DataAccess.GetSqlConnection())
            {
                SqlCommand command = sqlConnection.CreateCommand();
                command.CommandText = "[dbo].[FunctionTree_GetData]";
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Add(new SqlParameter("@userId", userId));
                command.Parameters.Add(new SqlParameter("@language", language.ToString()));
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Category category = new Category();
                    category.CategoryType = (ModuleCategoryType)reader.GetValue(0);
                    category.CategoryDescription = reader.GetValue(1).ToString();
                    tree.Categories.Add(category);

                }
                reader.NextResult();
                while (reader.Read())
                {
                    Module module = new Module();
                    module.Type = (ModuleType)reader.GetValue(0);
                    module.ModuleDescription = reader.GetValue(1).ToString();
                    module.Category = (ModuleCategoryType)reader.GetValue(2);
                    tree.Modules.Add(module);
                }
            }
            return tree;
        }
开发者ID:BlueSky007,项目名称:ExchangeManager,代码行数:31,代码来源:UserDataAccess.cs

示例7: GetLanguageFileExtension

 public static string GetLanguageFileExtension(Language language)
 {
     var type = typeof(Language);
     var memInfo = type.GetMember(language.ToString());
     var attributes = memInfo[0].GetCustomAttributes(typeof(FileExtensionAttribute), false);
     return ((FileExtensionAttribute)attributes[0]).Extension;
 }
开发者ID:modulexcite,项目名称:docs-8,代码行数:7,代码来源:FileExtensionHelper.cs

示例8: RunLocalBacktest

        public static void RunLocalBacktest(string algorithm, Dictionary<string, string> expectedStatistics, Language language)
        {
            var statistics = new Dictionary<string, string>();

            Composer.Instance.Reset();

            try
            {
                // set the configuration up
                Config.Set("algorithm-type-name", algorithm);
                Config.Set("live-mode", "false");
                Config.Set("environment", "");
                Config.Set("messaging-handler", "QuantConnect.Messaging.Messaging");
                Config.Set("job-queue-handler", "QuantConnect.Queues.JobQueue");
                Config.Set("api-handler", "QuantConnect.Api.Api");
                Config.Set("result-handler", "QuantConnect.Lean.Engine.Results.BacktestingResultHandler");
                Config.Set("algorithm-language", language.ToString());
                Config.Set("algorithm-location", "QuantConnect.Algorithm." + language + ".dll");

                var debugEnabled = Log.DebuggingEnabled;

                var logHandlers = new ILogHandler[] {new ConsoleLogHandler(), new FileLogHandler("regression.log", false)};
                using (Log.LogHandler = new CompositeLogHandler(logHandlers))
                using (var algorithmHandlers = LeanEngineAlgorithmHandlers.FromConfiguration(Composer.Instance))
                using (var systemHandlers = LeanEngineSystemHandlers.FromConfiguration(Composer.Instance))
                {
                    Log.DebuggingEnabled = true;

                    Log.LogHandler.Trace("");
                    Log.LogHandler.Trace("{0}: Running " + algorithm + "...", DateTime.UtcNow);
                    Log.LogHandler.Trace("");

                    // run the algorithm in its own thread

                    var engine = new Lean.Engine.Engine(systemHandlers, algorithmHandlers, false);
                    Task.Factory.StartNew(() =>
                    {
                        string algorithmPath;
                        var job = systemHandlers.JobQueue.NextJob(out algorithmPath);
                        engine.Run(job, algorithmPath);
                    }).Wait();

                    var backtestingResultHandler = (BacktestingResultHandler)algorithmHandlers.Results;
                    statistics = backtestingResultHandler.FinalStatistics;
                    
                    Log.DebuggingEnabled = debugEnabled;
                }
            }
            catch (Exception ex)
            {
                Log.LogHandler.Error("{0} {1}", ex.Message, ex.StackTrace);
            }

            foreach (var stat in expectedStatistics)
            {
                Assert.AreEqual(true, statistics.ContainsKey(stat.Key), "Missing key: " + stat.Key);
                Assert.AreEqual(stat.Value, statistics[stat.Key], "Failed on " + stat.Key);
            }
        }
开发者ID:AlexCatarino,项目名称:Lean,代码行数:59,代码来源:AlgorithmRunner.cs

示例9: Info

 /// <summary>
 /// 获取用户信息
 /// </summary>
 /// <param name="accessToken">调用接口凭证</param>
 /// <param name="openId">普通用户的标识,对当前公众号唯一</param>
 /// <param name="lang">返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语</param>
 /// <returns></returns>
 public static UserInfoJson Info(string accessToken, string openId, Language lang = Language.zh_CN)
 {
     //微信公众平台获取用户信息接口地址
     string urlFormat = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang={2}";
     return ApiHelper.Get<UserInfoJson>(accessToken, urlFormat, openId, lang.ToString());
     //错误时微信会返回错误码等信息,JSON数据包示例如下(该示例为AppID无效错误):
     //{"errcode":40013,"errmsg":"invalid appid"}
 }
开发者ID:15172002285,项目名称:tianxiangyu,代码行数:15,代码来源:User.cs

示例10: Get

 public override string Get(Language from, Language to, string text)
 {
     string res;
     if (_cache.TryGetValue(from.ToString() + "|" + to.ToString() + "|" + text, out res))
     {
         return res;
     }
     return null;
 }
开发者ID:hagaygo,项目名称:XmlTvGenerator,代码行数:9,代码来源:FileCacheManager.cs

示例11: Info

        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="accessToken">调用接口凭证</param>
        /// <param name="openId">普通用户的标识,对当前公众号唯一</param>
        /// <param name="lang">返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语</param>
        /// <returns></returns>
        public static UserInfoJson Info(string accessToken, string openId, Language lang = Language.zh_CN)
        {
            string url = string.Format("https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang={2}",
                accessToken, openId, lang.ToString());
            return HttpUtility.Get.GetJson<UserInfoJson>(url);

            //错误时微信会返回错误码等信息,JSON数据包示例如下(该示例为AppID无效错误):
            //{"errcode":40013,"errmsg":"invalid appid"}
        }
开发者ID:Rwing,项目名称:WeiXinMPSDK,代码行数:16,代码来源:User.cs

示例12: FormatLanguageEnum

 public static string FormatLanguageEnum(Language? lang)
 {
     if (lang == Language.xpiglatin)
     {
         return "x-pig-latin";
     }
     if (lang == Language.zhtw)
     {
         return "zh-tw";
     }
     return lang.ToString();
 }
开发者ID:Cr4ck3rs,项目名称:forecast.io-csharp,代码行数:12,代码来源:RequestHelpers.cs

示例13: GetPathToDocumentationSamplesDirectory

 public string GetPathToDocumentationSamplesDirectory(Language language, string documentationVersion)
 {
     switch (language)
     {
         case Language.Csharp:
             return Path.Combine(PathToDocumentationDirectory, documentationVersion, "Samples", "csharp", "Raven.Documentation.Samples");
         case Language.Java:
             return Path.Combine(PathToDocumentationDirectory, documentationVersion, "Samples", "java", "src", "test", "java", "net", "ravendb");
         default:
             throw new NotSupportedException(language.ToString());
     }
 }
开发者ID:modulexcite,项目名称:docs-8,代码行数:12,代码来源:ParserOptions.cs

示例14: fetchAndSave

 // methods
 public void fetchAndSave(Language lng)
 {
     words = (lng == Language.Lazca) ? getLazcaWords ("A","B","C","C1","C2","D","E","F","G","Gy","G1","H","I","J","K","K1","Ky","Ky1","L","M","N","O","P","P1","R","S","S1","T","T1","U","V","X","X1","Y","Z","Z1","3","31") : getTurckeWords("A-C","D-J","K-R","S-Z");
     // null check
     if(words==null) {
         Console.WriteLine ("HATA: {0} hic bir kelime bulunamadi",lng.ToString());
         return;
     }
     StringBuilder wordlistHTML = new StringBuilder ("{\"wordlist\":[");
     int counter=0;
     foreach (var item in words) {
         if(item.Key==null || item.Value==null){
             Console.WriteLine ("HATA: Bir kelimede terslik var");
             break;
         }
         wordlistHTML.Append ("\""+  Regex.Replace(item.Key.Trim(), @"\t|\n|\r", " ").Trim() +"\",");
         writeToDisk(lng.ToString() + "_" + counter + ".html" , item.Value);
         counter++;
     }
     wordlistHTML.Append ("\"END\"]}");
     writeToDisk("datalist"+lng.ToString()+".json" , wordlistHTML.ToString());
 }
开发者ID:aytacyildiz,项目名称:lazcasozlukfetcher,代码行数:23,代码来源:Program.cs

示例15: ConvertLanguageToCssClass

 private static string ConvertLanguageToCssClass(Language language)
 {
     switch (language)
     {
         case Language.Csharp:
             return "language-csharp";
         case Language.Java:
             return "language-java";
         case Language.Http:
             return "language-javascript";
         default:
             throw new NotSupportedException(language.ToString());
     }
 }
开发者ID:modulexcite,项目名称:docs-8,代码行数:14,代码来源:CodeBlockHelper.cs


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