本文整理汇总了C#中ILanguage类的典型用法代码示例。如果您正苦于以下问题:C# ILanguage类的具体用法?C# ILanguage怎么用?C# ILanguage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ILanguage类属于命名空间,在下文中一共展示了ILanguage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RaceGen
public RaceGen(List<IMythology> mythologies, ILanguage commonTongue)
{
CommonTongue = commonTongue;
Mythologies = mythologies;
Random = new Random(Guid.NewGuid().GetHashCode());
Names = new NameGen();
}
示例2: BaseLanguageWriter
public BaseLanguageWriter(ILanguage language, IFormatter formatter, IExceptionFormatter exceptionFormatter, bool writeExceptionsAsComments)
{
this.Language = language;
this.formatter = formatter;
this.exceptionFormatter = exceptionFormatter;
this.WriteExceptionsAsComments = writeExceptionsAsComments;
}
示例3: RunInternal
protected BlockStatement RunInternal(MethodBody body, BlockStatement block, ILanguage language)
{
try
{
if (body.Instructions.Count != 0 || body.Method.IsJustDecompileGenerated)
{
foreach (IDecompilationStep step in steps)
{
if (language != null && language.IsStopped)
{
break;
}
block = step.Process(Context, block);
}
}
}
finally
{
if (Context.MethodContext.IsMethodBodyChanged)
{
body.Method.RefreshBody();
}
}
return block;
}
示例4: AddDictionaryItem
public void AddDictionaryItem(string resourceName, string defaultValue, ILanguage language)
{
var arr = resourceName.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
if (arr.Length == 0)
return;
if (arr.Length == 1)
{
SetDictionaryValue(resourceName, defaultValue, language);
return;
}
var parentName = string.Join(".", arr.Take(arr.Length - 1));
if (!_localizationService.DictionaryItemExists(parentName))
{
AddDictionaryItem(parentName, "", language);
}
var parentDic = _localizationService.GetDictionaryItemByKey(parentName);
var dicItem = new DictionaryItem(resourceName);
dicItem.ParentId = parentDic.Key;
dicItem.Translations = new List<IDictionaryTranslation>
{
new DictionaryTranslation(language, defaultValue)
};
_localizationService.Save(dicItem);
}
示例5: TestWinRTProjectBuilder
public TestWinRTProjectBuilder(string assemblyPath, AssemblyDefinition assembly,
Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<TypeDefinition>> userDefinedTypes,
Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<Resource>> resources,
string targetPath, ILanguage language, IDecompilationPreferences preferences, VisualStudioVersion visualStudioVersion, ProjectGenerationSettings projectGenerationSettings = null)
: base(assemblyPath, assembly, userDefinedTypes, resources, targetPath, language, preferences, NoCacheAssemblyInfoService.Instance, visualStudioVersion, projectGenerationSettings)
{
}
示例6: Process
/// <summary>
/// 处理过程方法
/// </summary>
/// <param name="code">输入的代码</param>
/// <param name="lang">指定的语言</param>
/// <returns>返回高亮的代码片段</returns>
public static List<CodePiece> Process(string code, ILanguage lang)
{
var regexes = lang.Regexes.Keys.ToArray();
var matches = new Match[regexes.Length];
int index = 0;
var codePieces = new List<CodePiece>();
while (index < code.Length)
{
int i = 0;
for (; i < matches.Length; i++)
{
// 是否需要匹配
if (matches[i] != null && matches[i].Index >= index)
continue;
matches[i] = regexes[i].Match(code, index);
}
// 取最前的匹配
i = GetFirstMatch(matches);
if (i == -1)
break;
// 添加到代码片段
codePieces.Add(
new CodePiece(lang.Regexes[regexes[i]], matches[i])
);
// 更新Index,继续迭代
index = matches[i].Index + matches[i].Length;
}
return codePieces;
}
示例7: ImportItem
public virtual Projects.Items.Item ImportItem(IProject project, Data.Items.Item item, ILanguage language, [ItemNotNull] IEnumerable<string> excludedFields)
{
var itemBuilder = new ItemBuilder(Factory)
{
DatabaseName = item.Database.Name,
Guid = item.ID.ToString(),
ItemName = item.Name,
TemplateIdOrPath = item.Template.InnerItem.Paths.Path,
ItemIdOrPath = item.Paths.Path
};
var versions = item.Versions.GetVersions(true);
var sharedFields = item.Fields.Where(f => f.Shared && !excludedFields.Contains(f.Name, StringComparer.OrdinalIgnoreCase) && !f.ContainsStandardValue && !string.IsNullOrEmpty(f.Value)).ToList();
var unversionedFields = versions.SelectMany(i => i.Fields.Where(f => !f.Shared && f.Unversioned && !excludedFields.Contains(f.Name, StringComparer.OrdinalIgnoreCase) && !f.ContainsStandardValue && !string.IsNullOrEmpty(f.Value))).ToList();
var versionedFields = versions.SelectMany(i => i.Fields.Where(f => !f.Shared && !f.Unversioned && !excludedFields.Contains(f.Name, StringComparer.OrdinalIgnoreCase) && !f.ContainsStandardValue && !string.IsNullOrEmpty(f.Value))).ToList();
// shared fields
foreach (var field in sharedFields.OrderBy(f => f.Name))
{
var value = ImportFieldValue(field, item, language);
var fieldBuilder = new FieldBuilder(Factory)
{
FieldName = field.Name,
Value = value
};
itemBuilder.Fields.Add(fieldBuilder);
}
// unversioned fields
foreach (var field in unversionedFields.OrderBy(f => f.Name))
{
var value = ImportFieldValue(field, item, language);
var fieldBuilder = new FieldBuilder(Factory)
{
FieldName = field.Name,
Value = value,
Language = field.Language.Name
};
itemBuilder.Fields.Add(fieldBuilder);
}
// versioned fields
foreach (var field in versionedFields.OrderBy(f => f.Name))
{
var value = ImportFieldValue(field, item, language);
var fieldBuilder = new FieldBuilder(Factory)
{
FieldName = field.Name,
Value = value,
Language = field.Language.Name,
Version = field.Item.Version.Number
};
itemBuilder.Fields.Add(fieldBuilder);
}
return itemBuilder.Build(project, TextNode.Empty);
}
示例8: FormatAndColorize
protected virtual string FormatAndColorize(string value, ILanguage language = null)
{
var output = new StringBuilder();
string[] sz = value.Split(new[] { "\n" }, StringSplitOptions.None);
List<string> ls = new List<string>();
foreach (string s in sz)
{
if (!s.StartsWith(CodeBlockMarker))
ls.Add(s);
}
//foreach (var line in value.Split(new[] { "\n" }, StringSplitOptions.None).Where(s => !s.StartsWith(CodeBlockMarker)))
foreach (var line in ls)
{
if(language == null)
output.Append(new string(' ', 4));
if(line == "\n")
output.AppendLine();
else
output.AppendLine(line);
}
ls.Clear();
ls = null;
return language != null
? _syntaxHighlighter.Colorize(output.ToString().Trim(), language)
: output.ToString();
}
示例9: AddCustomTranslations
public void AddCustomTranslations(ILanguage sourceLanguage, ILanguage destLanguage, IDictionary<string,string>customTranslations)
{
if (sourceLanguage == null) { throw new ArgumentNullException("soureLanguage"); }
if (destLanguage == null) { throw new ArgumentNullException("destLanguage"); }
if (customTranslations == null) { throw new ArgumentNullException("customTranslations"); }
// TODO: This could be done Async
IList<BingTranslatorService.Translation> translationList = new List<BingTranslatorService.Translation>();
foreach (string key in customTranslations.Keys) {
if (!string.IsNullOrWhiteSpace(key)) {
BingTranslatorService.Translation translation = new BingTranslatorService.Translation();
translation.OriginalText = key;
translation.TranslatedText = customTranslations[key];
// make it less than 5 because that is the max value for machine translations
translation.Rating = this.CustomTranslationRating;
translation.RatingSpecified = true;
translation.Sequence = 0;
translation.SequenceSpecified = true;
translationList.Add(translation);
}
}
// TODO: We should batch these into 100 because according to http://msdn.microsoft.com/en-us/library/ff512409.aspx that is the limit
using (BingTranslatorService.SoapService client = new BingTranslatorService.SoapService()) {
client.AddTranslationArray(this.ApiKey, translationList.ToArray(), sourceLanguage.Language, destLanguage.Language, this.TranslateOptions);
}
}
示例10: DecompileMethod
private string DecompileMethod(MethodDefinition definition, ILanguage language)
{
var str = new StringWriter();
var writer = language.GetWriter(new PlainTextFormatter(str));
writer.Write (definition);
return str.ToString ();
}
示例11: Load
public void Load(ILanguage language)
{
Guard.ArgNotNull(language, "language");
if (string.IsNullOrEmpty(language.Id))
throw new ArgumentException("The language identifier must not be null or empty.", "language");
lock (loadLock)
{
loadedLanguages[language.Id] = language;
}
/*
loadLock.EnterWriteLock();
try
{
loadedLanguages[language.Id] = language;
}
finally
{
loadLock.ExitWriteLock();
}
*/
}
示例12: DefaultFilePathsAnalyzer
public DefaultFilePathsAnalyzer(Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<TypeDefinition>> userDefinedTypes,
Dictionary<ModuleDefinition, Mono.Collections.Generic.Collection<Resource>> resources, ILanguage language)
{
this.userDefinedTypes = userDefinedTypes;
this.resources = resources;
this.sourceExtension = language.VSCodeFileExtension;
}
示例13: WinRTSolutionWriter
internal WinRTSolutionWriter(AssemblyDefinition assembly, TargetPlatform targetPlatform, string targetDir, string solutionFileName,
Dictionary<ModuleDefinition, string> modulesProjectsRelativePaths, Dictionary<ModuleDefinition, Guid> modulesProjectsGuids,
VisualStudioVersion visualStudioVersion, ILanguage language, IEnumerable<string> platforms)
: base(assembly, targetPlatform, targetDir, solutionFileName, modulesProjectsRelativePaths, modulesProjectsGuids, visualStudioVersion, language)
{
this.platforms = platforms;
}
示例14: SolutionWriter
internal SolutionWriter(AssemblyDefinition assembly, TargetPlatform targetPlatform, string targetDir, string solutionFileName,
Dictionary<ModuleDefinition, string> modulesProjectsRelativePaths, Dictionary<ModuleDefinition, Guid> modulesProjectsGuids,
VisualStudioVersion visualStudioVersion, ILanguage language)
{
this.assembly = assembly;
this.targetPlatform = targetPlatform;
this.targetDir = targetDir;
this.solutionFileName = solutionFileName;
this.modulesProjectsRelativePaths = modulesProjectsRelativePaths;
this.modulesProjectsGuids = modulesProjectsGuids;
if (language is ICSharp)
{
this.languageGuid = new Guid(WinRTProjectBuilder.CSharpGUID);
}
else if (language is IVisualBasic)
{
this.languageGuid = new Guid(WinRTProjectBuilder.VisualBasicGUID);
}
else
{
throw new NotSupportedException();
}
this.visualStudioVersion = visualStudioVersion;
}
示例15: ChangeLanguage
/// <summary>
/// Changes the language.
/// </summary>
/// <param name="Language">The language.</param>
public void ChangeLanguage(ILanguage Language)
{
foreach (var item in Language.GetTranslationDictionary())
{
var itemKey = item.Key;
var itemValue = item.Value;
var menuItem = Variables.Menu.Item(itemKey);
try
{
if (menuItem != null)
{
menuItem.DisplayName = itemValue;
}
else
{
LogHelper.AddToLog(new LogItem("Language_Module", "Could Not Translate: "+ itemKey + " with " + itemValue, LogSeverity.Warning));
}
}
catch (Exception e)
{
LogHelper.AddToLog(new LogItem("Language_Module", e, LogSeverity.Warning));
}
}
}