當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。