本文整理汇总了C#中Language类的典型用法代码示例。如果您正苦于以下问题:C# Language类的具体用法?C# Language怎么用?C# Language使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Language类属于命名空间,在下文中一共展示了Language类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InitializeRecognizer
/// <summary>
/// Initialize Speech Recognizer and compile constraints.
/// </summary>
/// <param name="recognizerLanguage">Language to use for the speech recognizer</param>
/// <returns>Awaitable task.</returns>
private async Task InitializeRecognizer(Language recognizerLanguage)
{
MicrophoneAccessStatus status = await AudioCapturePermissions.RequestMicrophoneAccessAsync();
if (status != MicrophoneAccessStatus.Allowed)
{
string prompt = status == MicrophoneAccessStatus.NoCaptureDevices ?
"没有检测到音频捕获设备,请检查设备后重试" :
"您没有允许本应用访问麦克风,请在 设置 -> 隐私 -> 麦克风 中设置";
var messageDialog = new MessageDialog(prompt);
await messageDialog.ShowAsync();
throw new Exception($"Request microphone access failed. Status: {status}");
}
Dispose();
// Create an instance of SpeechRecognizer.
_speechRecognizer = new SpeechRecognizer(recognizerLanguage);
// Add a web search topic constraint to the recognizer.
var webSearchGrammar = new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.WebSearch, "webSearch");
_speechRecognizer.Constraints.Add(webSearchGrammar);
// RecognizeWithUIAsync allows developers to customize the prompts.
_speechRecognizer.UIOptions.AudiblePrompt = "请说出您想搜索的东西";
_speechRecognizer.UIOptions.ExampleText = "例如:“你好,美女”";
// Compile the constraint.
SpeechRecognitionCompilationResult compilationResult = await _speechRecognizer.CompileConstraintsAsync();
// Check to make sure that the constraints were in a proper format and the recognizer was able to compile it.
if (compilationResult.Status != SpeechRecognitionResultStatus.Success)
throw new Exception($"Unable to compile grammar. Status: {compilationResult.Status}");
}
开发者ID:GJian,项目名称:UWP-master,代码行数:38,代码来源:SpeechService.cs
示例2: SetUp
public void SetUp()
{
var home = _context.CurrentDatabase.GetItem("/sitecore/content/home");
var contentRootItem = TestUtil.CreateContentFromFile("TestResources\\items in workflow.xml", _testRoot);
_publishableItem = contentRootItem.Axes.GetChild("publishable");
_itemInWorkflow = contentRootItem.Axes.GetChild("in draft");
_noWorkflow = contentRootItem.Axes.GetChild("no workflow");
_noWorkflow.Editing.BeginEdit();
_noWorkflow[FieldIDs.Workflow] = string.Empty;
_noWorkflow[FieldIDs.WorkflowState] = string.Empty;
_noWorkflow.Editing.EndEdit();
// publish the root item only so publishing on any item works
var dbs = new Database[]{ Sitecore.Configuration.Factory.GetDatabase("web")};
var langs = new Language[]{ Sitecore.Context.Language};
var handle = PublishManager.PublishItem(_testRoot, dbs, langs, false, true);
PublishManager.PublishItem(contentRootItem, dbs, langs, false, true);
var jobs = from j in Sitecore.Jobs.JobManager.GetJobs()
where j.Name.Contains("Publish") && j.Name.Contains("web")
select j;
foreach (var job in jobs)
job.Wait();
}
开发者ID:KerwinMa,项目名称:revolver,代码行数:28,代码来源:PublishItem.cs
示例3: Settings_Page4
public Settings_Page4(Color c, Language lang)
{
InitializeComponent();
themeColor = c;
LANG = lang;
SlideOutButtonVisible = false;
settings4_1_filelocation_button.Click += settings4_1_filelocation_button_Click;
settings4_4_language.Items.AddRange(new object[] {"简体中文", "English"});
settings4_4_language.DrawItem += settings4_4_language_DrawItem;
settings4_4_language.SelectionChangeCommitted += settings4_4_language_SelectionChangeCommitted;
settings4_1_filelocation_label.Text = LANG.getString("settings4_1_filelocation_label");
settings4_1_filelocation_button.Text = LANG.getString("settings4_1_filelocation_button");
settings4_2_deletetempfiles_label.Text = LANG.getString("settings4_2_deletetempfiles_label");
settings4_4_chkupd_label.Text = LANG.getString("settings4_4_chkupd_label");
settings4_4_chkupd_button.Text = LANG.getString("settings4_4_chkupd_button");
settings4_3_reset_button.Text = LANG.getString("settings4_3_reset_button");
settings4_1_filelocation_dialog.Description = LANG.getString("settings4_1_filelocation_dialog");
settings4_4_language_label.Text = LANG.getString("settings4_4_language_label");
// DPI settings
AutoScaleDimensions = new SizeF(96F, 96F);
AutoScaleMode = AutoScaleMode.Dpi;
// Set UI Font according to language
LANG.setFont(this.Controls);
Font = new Font(LANG.getFont(), Font.Size, Font.Style);
}
开发者ID:henryxrl,项目名称:SimpleEpub2,代码行数:31,代码来源:Settings_Page4.cs
示例4: Init
void Init (string fname)
{
if (File.Exists (fname)) {
File.Delete (fname);
}
lang = LanguageForExtension (Path.GetExtension (fname));
switch (lang) {
case Language.C:
Indenter = " ";
break;
case Language.CSharp:
default:
Indenter = "\t";
break;
}
FileStream fs = new FileStream (fname, FileMode.OpenOrCreate, FileAccess.Write);
w = new StreamWriter (fs);
if (lang == Language.CSharp) {
w.WriteLine ("//------------------------------------------------------------------------------");
w.WriteLine ("// <auto-generated>");
w.WriteLine ("// This code was generated by a tool.");
w.WriteLine ("// </auto-generated>");
w.WriteLine ("//------------------------------------------------------------------------------");
w.WriteLine ();
} else {
WriteComment ("This code was generated by a tool.");
}
}
开发者ID:emtees,项目名称:old-code,代码行数:34,代码来源:CodeWriter.cs
示例5: LanguageKey
public LanguageKey(string key, string value, Language lang)
{
Key = key;
Value = value;
Language = lang;
FkLanguage = lang.Id;
}
开发者ID:GabrielCapano,项目名称:transito-de-,代码行数:7,代码来源:LanguageKey.cs
示例6: AddNewLanguage
/// <summary>
/// Adds a new language.
/// </summary>
public void AddNewLanguage(Language language)
{
Check.Require(language.Name);
dataContext.Languages.Add(language);
dataContext.SaveChanges();
}
开发者ID:Woodje,项目名称:DaCoder,代码行数:10,代码来源:BusinessContext.cs
示例7: DeleteLanguage
/// <summary>
/// Deletes a language
/// </summary>
/// <param name="language">Language</param>
public virtual void DeleteLanguage(Language language)
{
if (language == null)
throw new ArgumentNullException("language");
//update default admin area language (if required)
if (_localizationSettings.DefaultAdminLanguageId == language.Id)
{
foreach (var activeLanguage in GetAllLanguages())
{
if (activeLanguage.Id != language.Id)
{
_localizationSettings.DefaultAdminLanguageId = activeLanguage.Id;
_settingService.SaveSetting(_localizationSettings);
break;
}
}
}
_languageRepository.Delete(language);
//cache
_cacheManager.RemoveByPattern(LANGUAGES_PATTERN_KEY);
//event notification
_eventPublisher.EntityDeleted(language);
}
开发者ID:priceLiu,项目名称:MulitNop,代码行数:31,代码来源:LanguageService.cs
示例8: SaveLanguage
public void SaveLanguage(Language language)
{
if (Equals(language, null))
throw new ArgumentNullException("language");
CurrentSession.Save(language);
}
开发者ID:rellydinio,项目名称:Freetime-Generic-Platform,代码行数:7,代码来源:LocalizationSession.cs
示例9: PageLinksValidationResult
public PageLinksValidationResult(string key, Language language, string version)
{
PageKey = key;
PageLanguage = language;
PageVersion = version;
Links = new Dictionary<string, bool>();
}
开发者ID:modulexcite,项目名称:docs-8,代码行数:7,代码来源:PageLinksValidationResult.cs
示例10: UpdateKeywordIsPersisted
public void UpdateKeywordIsPersisted()
{
using (var businessContext = new BusinessContext())
{
var language = new Language
{
Name = "LanguageName"
};
businessContext.AddNewLanguage(language);
var keyword = new Keyword
{
Name = "KeywordName",
LanguageId = 1,
};
businessContext.AddNewKeyword(keyword);
keyword.Name = "New KeywordName";
businessContext.UpdateKeyword(keyword);
bool updated = businessContext.DataContext.Keywords.Any(k => k.Id == keyword.Id && k.Name == keyword.Name);
Assert.IsTrue(updated);
}
}
开发者ID:Woodje,项目名称:DaCoder,代码行数:28,代码来源:KeywordScenarioTests.cs
示例11: DeleteLanguage
public void DeleteLanguage(Language language)
{
if (Equals(language, null))
throw new ArgumentNullException("language");
CurrentSession.Delete<Language>(language);
}
开发者ID:rellydinio,项目名称:Freetime-Generic-Platform,代码行数:7,代码来源:LocalizationSession.cs
示例12: DeleteKeywordIsPersisted
public void DeleteKeywordIsPersisted()
{
using (var businessContext = new BusinessContext())
{
var language = new Language
{
Name = "LanguageName"
};
businessContext.AddNewLanguage(language);
var keyword = new Keyword
{
Name = "KeywordName",
LanguageId = 1,
};
businessContext.AddNewKeyword(keyword);
//businessContext.DeleteKeyword(keyword);
bool notDeleted = businessContext.DataContext.Keywords.Any(k => k.Id == keyword.Id);
//Assert.IsFalse(notDeleted);
}
}
开发者ID:Woodje,项目名称:DaCoder,代码行数:26,代码来源:KeywordScenarioTests.cs
示例13: CompileAndRun
public static string CompileAndRun(string code, Language language)
{
var compilerParams = new CompilerParameters
{
GenerateInMemory = false,
TreatWarningsAsErrors = false,
GenerateExecutable = false,
CompilerOptions = "/optimize"
};
string[] references = { "System.dll", "System.Linq.dll", "System.Core.dll" };
compilerParams.ReferencedAssemblies.AddRange(references);
CodeDomProvider provider = language == Language.CSharp ? (CodeDomProvider)new CSharpCodeProvider() : (CodeDomProvider)new VBCodeProvider();
var compile = provider.CompileAssemblyFromSource(compilerParams, code);
if (compile.Errors.HasErrors)
{
return compile.Errors.Cast<CompilerError>().Aggregate("Compile error: ",
(current, ce) => current
+ string.Format("Line: {0}\r\nColumn: {1}\r\nError Code: {2}\r\nError Text: {3}\r\n",
ce.Line, ce.Column, ce.ErrorNumber, ce.ErrorText));
}
var sandbox = Sandbox.Create();
return sandbox.Execute(compile.PathToAssembly);
}
开发者ID:alxwest,项目名称:OpenFiddle,代码行数:27,代码来源:CompileHelper.cs
示例14: WriteJavascriptDictionary
public static void WriteJavascriptDictionary(StreamWriter stream, Language language)
{
var processDictionaryItems = new ProcessDictionaryItems();
stream.WriteLine("(function () {");
// IE7 can't handle trailing "," in javascript array
var lastLine = " var tmp = {";
processDictionaryItems.Start(item =>
{
stream.WriteLine(lastLine);
var key = EscapeSingleQuote(item.key);
var value = EscapeSingleQuote(item.Value(language.id));
lastLine = string.Format(" '{0}': '{1}',", key, value);
}, Dictionary.getTopMostItems);
stream.WriteLine(lastLine.TrimEnd(','));
stream.WriteLine(" };");
stream.WriteLine("");
stream.WriteLine(" if (window['$uDictionary'] === undefined) {");
stream.WriteLine(" window['$uDictionary'] = tmp;");
stream.WriteLine(" } else {");
stream.WriteLine(" var $uDic = window['$uDictionary'];");
stream.WriteLine(" for (var attrname in tmp) { ");
stream.WriteLine(" var value = tmp[attrname];");
stream.WriteLine(" if(value != '')");
stream.WriteLine(" $uDic[attrname] = value;");
stream.WriteLine(" }");
stream.WriteLine(" }");
stream.WriteLine("})();");
}
开发者ID:drphrozen,项目名称:DicToJs,代码行数:32,代码来源:MyStartupHandler.cs
示例15: LanguageAdapter
public LanguageAdapter(Language language)
{
if (language == null) throw new ArgumentNullException(nameof(language));
Id = language.Id;
Name = language.Name;
}
开发者ID:dyatlov-a,项目名称:cEditor,代码行数:7,代码来源:LanguageAdapter.cs
示例16: Add_Click
protected void Add_Click(object sender, EventArgs e)
{
Language language = new Language();
language.Name = tbNewLang.Text.Trim();
BLL.LanguageManager.Add(language);
this.GridView1.DataBind();
}
开发者ID:BGCX262,项目名称:zszsource-svn-to-git,代码行数:7,代码来源:LanguageManage.aspx.cs
示例17: CreateProvider
public static CodeDomProvider CreateProvider(Language language, CompilerVersion version)
{
var providerOptions = GetProviderOptions(version);
var provider = CodeDomProvider.CreateProvider(language.ToString(), providerOptions);
return provider;
}
开发者ID:MartinF,项目名称:Dynamo.Jiss,代码行数:7,代码来源:CompilerHelper.cs
示例18: Write
protected override void Write(ITextOutput output, Language language)
{
if (name != null)
output.Write(name, TextTokenType.Keyword);
else
base.Write(output, language);
}
开发者ID:BahNahNah,项目名称:dnSpy,代码行数:7,代码来源:AnalyzedPropertyAccessorTreeNode.cs
示例19: Deserialize
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
WritLanguage = (Language)reader.ReadInt();
}
开发者ID:ITLongwell,项目名称:Ulmeta,代码行数:7,代码来源:Language.cs
示例20: Completion
public Completion(SimpleIni config, Settings settings)
{
this.settings = settings;
lang = ScintillaControl.Configuration.GetLanguage("css");
InitProperties(GetSection(config, "Properties"));
InitLists(GetSection(config, "Lists"));
}
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:7,代码来源:Completion.cs
注:本文中的Language类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论