本文整理汇总了C#中System.Language类的典型用法代码示例。如果您正苦于以下问题:C# Language类的具体用法?C# Language怎么用?C# Language使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Language类属于System命名空间,在下文中一共展示了Language类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Lookup
public virtual string Lookup(object itemId, string path, Language language)
{
var id = ToGuid(itemId);
if (Database == null || id == null || path == null)
{
return null;
}
language = language ?? Language;
var key = string.Concat(language.Name, id, path);
return _cache.GetOrAdd(key, _ =>
{
var item = Database.GetItem(ID.Parse(id), language);
if (item != null)
{
if (path.Equals("@displayname", StringComparison.InvariantCultureIgnoreCase))
{
return item.DisplayName;
}
if (path.Equals("@templatename", StringComparison.InvariantCultureIgnoreCase))
{
return item.TemplateName;
}
return item[path];
}
return null;
});
}
示例2: Add
public string this[ulong guid, Language language]
{
get
{
if (_stringTableSet.ContainsKey(guid))
{
if (_stringTableSet[guid].ContainsKey(language))
{
return _stringTableSet[guid][language];
}
}
return null;
}
set
{
if (_stringTableSet.ContainsKey(guid) && _stringTableSet[guid].ContainsKey(language))
{
if (_stringTableSet[guid][language] != value)
{
_stringTableSet[guid][language] = value;
_stringTables[language][guid] = value;
}
}
else
{
Add(guid, language, value);
}
}
}
示例3: 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;
}
示例4: GetSimpleNameHandleArray
private static string GetSimpleNameHandleArray(Type t, Language language)
{
if (t.IsArray && language == Language.VisualBasic)
return t.Name.Replace('[', '(').Replace(']', ')');
return t.Name;
}
示例5: Insert
///<summary>Inserts one Language into the database. Provides option to use the existing priKey.</summary>
public static long Insert(Language language,bool useExistingPK){
if(!useExistingPK && PrefC.RandomKeys) {
language.LanguageNum=ReplicationServers.GetKey("language","LanguageNum");
}
string command="INSERT INTO language (";
if(useExistingPK || PrefC.RandomKeys) {
command+="LanguageNum,";
}
command+="EnglishComments,ClassType,English,IsObsolete) VALUES(";
if(useExistingPK || PrefC.RandomKeys) {
command+=POut.Long(language.LanguageNum)+",";
}
command+=
"'"+POut.String(language.EnglishComments)+"',"
+"'"+POut.String(language.ClassType)+"',"
+"'"+POut.String(language.English)+"',"
+ POut.Bool (language.IsObsolete)+")";
if(useExistingPK || PrefC.RandomKeys) {
Db.NonQ(command);
}
else {
language.LanguageNum=Db.NonQ(command,true);
}
return language.LanguageNum;
}
示例6: Book
//Constructor
public Book(string title, Author author, Language language, BookSection bookSection)
: base(title)
{
this.BookAuthor = author;
this.BookLanguage = language;
this.bookSection = bookSection;
}
示例7: GetWords
public IEnumerable<WordModel> GetWords(Language from, Language to, string filter)
{
using (var db = GetConnection())
{
var translatesFrom = db.Translations.Where(t => t.Language == from && t.Value.ToLower().Contains(filter.ToLower()));
if (translatesFrom != null && translatesFrom.Any())
foreach (var translateFrom in translatesFrom)
{
if (translateFrom?.Word == null)
continue;
var availableTranslations = translateFrom.Word.Translations.Where(t => t.Language == to);
if (availableTranslations != null && availableTranslations.Any())
foreach (var translation in availableTranslations)
{
var word = translation.Word;
yield return new WordModel
{
DateCreated = word.DateCreated,
LastSearch = word.LastSearch,
Example = translation.SentenceExample,
Pronunciation = translation.Pronunciation,
TranslateFrom = translateFrom.Value,
TranslateTo = translation.Value,
};
}
}
}
}
示例8: TtsEspHelper
/// <summary>
/// Initializes a new instance of the <see cref="TtsEspHelper"/> class.
/// </summary>
/// <param name="language">Language.</param>
/// <param name="voicePath">Voice font path.</param>
/// <param name="langDllPath">Language dll path.</param>
/// <param name="langDataPath">Language data path.</param>
/// <param name="mode">Process mode.</param>
public TtsEspHelper(Language language, string voicePath, string langDllPath,
string langDataPath, ProcessMode mode)
{
if (string.IsNullOrEmpty(voicePath))
{
voicePath = null;
}
if (string.IsNullOrEmpty(langDllPath))
{
langDllPath = null;
}
if (string.IsNullOrEmpty(langDataPath))
{
langDataPath = null;
}
_language = language;
if (string.IsNullOrEmpty(langDllPath) && string.IsNullOrEmpty(langDataPath))
{
_engine = new SP.TtsEngine((SP.Language)language, voicePath);
}
else if (string.IsNullOrEmpty(langDataPath))
{
_engine = new SP.TtsEngine((SP.Language)language, voicePath, langDllPath);
}
else
{
_engine = new SP.TtsEngine((SP.Language)language, voicePath, langDllPath, langDataPath);
}
_mode = mode;
}
示例9: getTextFromImageFile
public string getTextFromImageFile(string filePath, Language selectedLanguage, string selectedMode)
{
string language = AspriseOCR.LANGUAGE_ENG;
switch (selectedLanguage)
{
case Language.SPANISH:
language = AspriseOCR.LANGUAGE_SPA;
break;
case Language.ENGLISH:
language = AspriseOCR.LANGUAGE_ENG;
break;
case Language.GERMAN:
language = AspriseOCR.LANGUAGE_DEU;
break;
case Language.FRENCH:
language = AspriseOCR.LANGUAGE_FRA;
break;
default:
language = AspriseOCR.LANGUAGE_ENG;
break;
}
AspriseOCR.SetUp();
AspriseOCR ocr = new AspriseOCR();
ocr.StartEngine(language, AspriseOCR.SPEED_FASTEST);
string s = ocr.Recognize(filePath, -1, -1, -1, -1, -1, AspriseOCR.RECOGNIZE_TYPE_ALL, AspriseOCR.OUTPUT_FORMAT_PLAINTEXT);
ocr.StopEngine();
return s;
}
示例10: Compiler
public const int DefaultTimeout = 5000; //5s
protected Compiler(Language language, IEnumerable<KeyValuePair<string, string>> sources)
{
Language = language;
Parameters = new Dictionary<string, string>(StringComparer.Ordinal);
Sources = sources ?? new Dictionary<string, string>();
Timeout = DefaultTimeout;
}
示例11: GetSamplesCodeBehindFileName
/// <summary>
/// Gets the name of the C# code behind file.
/// </summary>
public static string GetSamplesCodeBehindFileName(this SampleModel model, Language language = Language.CSharp)
{
if (language == Language.CSharp)
return string.Format("{0}.xaml.cs", model.GetSampleName(language));
return string.Format("{0}.xaml.vb", model.GetSampleName(language));
}
示例12: CompileGetter
public static GetterInfo CompileGetter(this JobParser parser, Type type, string selector, Language language = null)
{
var slash = selector.IndexOf('/');
var path = (slash != -1 ? selector.Substring(0, slash) : selector).Split(new[] {"."}, StringSplitOptions.RemoveEmptyEntries);
var scField = slash != -1 ? selector.Substring(slash + 1) : null;
Type valueType;
var valueGetter = CompileGetter(type, path, out valueType);
Func<object, ProcessingScope, object> getter = (item, scope) => valueGetter(item);
if (!string.IsNullOrEmpty(scField))
{
valueType = typeof(string);
getter =
(item, scope) =>
valueGetter(item).TryGet(id => scope.FieldLookup.TryGet(lu => lu.Lookup(id, scField, language)));
}
return new GetterInfo
{
Path = path,
SitecoreField = scField,
Type = type,
ValueType = valueType,
Getter = getter
};
}
示例13: AppendLanguage
private void AppendLanguage(Language? language)
{
if (language.HasValue && language.Value != Language.Undefined)
{
this.builder.AppendFormat(" +language:{0}", this.location.GetLanguage(language.Value));
}
}
示例14: CodeBlock
public CodeBlock(string lineOfCode, int lineNumber, Language language, string propertyOrMethodName)
{
Value = ExtractCallOutsFromText(lineOfCode);
LineNumber = lineNumber;
Language = language;
PropertyName = propertyOrMethodName?.ToLowerInvariant();
}
示例15: GetColor
private Color GetColor(Language lang, Color? col, bool invert)
{
if (invert)
return (lang == Language.OtherLanguage) ? SystemColors.Control : (CurrentWord.Parent.ColorRecursive ?? SystemColors.Control);
else
return (lang == Language.German) ? SystemColors.Control : (CurrentWord.Parent.ColorRecursive ?? SystemColors.Control);
}