private void setDictionary(string language, BaseLanguage baseLanguage, List <string> dictionary, int languageWeight, int dictionaryWeight) { throw new NotImplementedException(); Debug.Assert(false); //TODO CASE CREATED 5062 // string path = Path.Combine(SettingsContainer.Instance.Directories[Infrastructure.Source.UserDocsDir].FullName, "CustomDictionary.amd"); //TODO CASE CREATED //create dictionary file //makeDictionary( // path, // baseLanguage, // dictionary); // Get collection of dictionary descriptions and remove all items //DictionaryDescriptions dictionaryDescriptions = baseLanguage.DictionaryDescriptions; //if (language == null) //{ // dictionaryDescriptions.DeleteAll(); //} //// lower weight of defoult dictionary (defoult weight = 100) //foreach (DictionaryDescription d in dictionaryDescriptions) //{ // d.Weight = languageWeight; //} //// Create user dictionary description and add it to the collection //IDictionaryDescription dictionaryDescription = dictionaryDescriptions.AddNew(DictionaryTypeEnum.DT_UserDictionary); //UserDictionaryDescription userDictionaryDescription = dictionaryDescription.GetAsUserDictionaryDescription(); //userDictionaryDescription.Weight = dictionaryWeight; //userDictionaryDescription.FileName = path; }
public virtual void Write(ICodeFragment fragment, IOutputCache output) { BaseLanguage language = this.options.Language.CastTo <BaseLanguage>(); EnumTemplate template = (EnumTemplate)fragment; output.Add(template.Attributes) .Add(language.ClassScope) .Add(" enum ") .Add(template.Name); if (template.BasedOn != null) { output.Add(" : ").Add(template.BasedOn); } output.StartBlock(); EnumValueTemplate last = template.Values.LastOrDefault(); foreach (EnumValueTemplate enumTemplateValue in template.Values) { output.Add($"{enumTemplateValue.FormattedName} = ") .Add(enumTemplateValue.Value) .Add(last == enumTemplateValue ? string.Empty : ",") .BreakLine(); } output.EndBlock(); }
private static DecompilationPipeline GetStateMachineRemovalPipeline(BaseStateMachineRemoverStep removeStateMachineStep, Func <DecompilationContext, IStateMachineData> stateMachineDataSelector) { stackVariable0 = BaseLanguage.get_IntermediateRepresenationPipeline(); V_0 = new List <IDecompilationStep>(); V_0.Add(removeStateMachineStep); V_1 = stackVariable0.get_Steps().GetEnumerator(); try { while (V_1.MoveNext()) { V_2 = V_1.get_Current(); V_0.Add(V_2); if (V_2 as VariableAssignmentAnalysisStep == null) { continue; } V_0.Add(new FieldAssignmentAnalysisStep(stateMachineDataSelector)); } } finally { if (V_1 != null) { V_1.Dispose(); } } return(new DecompilationPipeline(V_0)); }
private TextLanguage makeTextLanguage(string language, List <string> dictionary, int languageWeight, int dictionaryWeight) { // Create new TextLanguage object LanguageDatabase languageDatabase = Engine.CreateLanguageDatabase(); TextLanguage Language = languageDatabase.CreateTextLanguage(); if (language != null) { // Copy all attributes from predefined language Language.CopyFrom(Engine.PredefinedLanguages.Find(language).TextLanguage); Language.InternalName = "SampleTextLanguage"; } else { Language.CopyFrom(Engine.PredefinedLanguages.Find("English").TextLanguage); } // Bind new dictionary to first (and single) BaseLanguage object within TextLanguage //BaseLanguage baseLanguage = Language.BaseLanguages[0]; BaseLanguage baseLanguage = Language.BaseLanguages[0]; // Change internal dictionary name to user-defined baseLanguage.InternalName = "SampleBaseLanguage"; //set custom doctionary for base language setDictionary(language, baseLanguage, dictionary, languageWeight, dictionaryWeight); return(Language); }
public static void Initialize() { var types = typeof(BaseLanguage).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(BaseLanguage))) .ToArray(); Languages = types.Select(type => (BaseLanguage)Activator.CreateInstance(type)).ToList(); CurrentBaseLanguage = Languages.Find(x => x.Name == CustomizeItExtendedMod.Settings.Language); }
private bool CheckMethodAndDecompile(MethodDefinition methodDef, out BlockStatement methodBody) { if (!methodDef.get_HasParameters() || methodDef.get_Parameters().get_Count() != 1) { methodBody = null; return(false); } V_0 = BaseLanguage.get_IntermediateRepresenationPipeline(); dummyVar0 = V_0.Run(methodDef.get_Body(), this.language); methodBody = V_0.get_Body(); return(true); }
public void TestTranslateSingleString_NoDestLangSpecified() { BingLocanTranslator translator = this.GetNewBingLocanTranslator(); string stringToTranslate = @"What is your name?"; string expectedTranslation = @"Qual é seu nome?"; ILanguage destLanguage = new BaseLanguage("pt"); ITranslation translation = translator.Translate(stringToTranslate, destLanguage); Assert.IsNotNull(translation); Assert.AreEqual(stringToTranslate, translation.StringToTranslate); Assert.AreEqual(destLanguage, translation.DestLanguage); Assert.AreEqual(expectedTranslation, translation.TrnaslatedString); }
private void makeDictionary(string path, BaseLanguage baseLanguage, List <string> words) { LanguageDatabase languageDatabase = Engine.CreateLanguageDatabase(); Dictionary dictionary = languageDatabase.CreateNewDictionary(path, baseLanguage.LanguageId); dictionary.Name = "CustomDictionary"; // Add words to dictionary foreach (string word in words) { dictionary.AddWord(word, 100); } }
public void TestTranslateAsync() { BingLocanTranslator translator = this.GetNewBingLocanTranslator(); List <string> stringsToTranslate = new List <string> { @"What is your name?", @"How old are you?", @"My name is Sayed." }; List <string> expectedTranslations = new List <string> { @"Qual é seu nome?", @"São velhos ou não é?", @"Meu nome é Sayed.", }; ILanguage sourceLanguage = new BaseLanguage("en"); ILanguage destLangage = new BaseLanguage("pt"); int currentIndex = 0; translator .Translate(stringsToTranslate, destLangage, sourceLanguage) .OnTranslationComplete((payload, translationValues) => { Assert.AreEqual(stringsToTranslate.Count, translationValues.Count()); for (int i = 0; i < stringsToTranslate.Count; i++) { string stringToTranslate = stringsToTranslate[i]; string expectedTranslation = expectedTranslations[i]; ITranslation translation = translationValues.ElementAt(i); Assert.AreEqual(stringToTranslate, translation.StringToTranslate); Assert.AreEqual(expectedTranslation, translation.TrnaslatedString); currentIndex++; } }); // must give the service time to perform the translations Thread.Sleep(10000); Assert.IsTrue(currentIndex == stringsToTranslate.Count); }
private BlockStatement DecompileMethodPartially(MethodBody body, out DecompilationContext context, bool needDecompiledMember = false) { context = null; if (this.get_IsCachingEnabled() && this.cacheService.IsDecompiledMemberInCache(body.get_Method(), this.language, this.renameInvalidMembers)) { return(this.cacheService.GetDecompiledMemberFromCache(body.get_Method(), this.language, this.renameInvalidMembers).get_Member().get_Statement() as BlockStatement); } if ((int)(new ControlFlowGraphBuilder(body.get_Method())).CreateGraph().get_Blocks().Length > 2) { return(null); } try { stackVariable13 = new MethodSpecificContext(body); stackVariable15 = this.typeContext; if (stackVariable15 == null) { dummyVar0 = stackVariable15; stackVariable15 = new TypeSpecificContext(body.get_Method().get_DeclaringType()); } V_2 = new DecompilationContext(stackVariable13, stackVariable15, this.language); if (!needDecompiledMember) { V_2.get_MethodContext().set_EnableEventAnalysis(false); } V_1 = new DecompilationPipeline(BaseLanguage.get_IntermediateRepresenationPipeline().get_Steps(), V_2); context = V_1.Run(body, this.language); V_0 = V_1.get_Body(); } catch (Exception exception_0) { V_3 = exception_0; this.get_ExceptionsWhileDecompiling().Add(body.get_Method()); V_0 = new BlockStatement(); V_0.AddStatement(new ExceptionStatement(V_3, body.get_Method())); this.OnExceptionThrown(V_3); } return(V_0); }
public virtual void Write(ICodeFragment fragment, IOutputCache output) { BaseLanguage language = this.options.Language.CastTo <BaseLanguage>(); ClassTemplate template = (ClassTemplate)fragment; output.Add(template.Comment); output.Add(template.Attributes); output.Add(language.ClassScope).Add(" "); if (template.IsAbstract && language.HasAbstractClasses && !template.IsInterface) { output.Add("abstract "); } if (template.IsStatic && language.HasStaticClasses) { output.Add("static "); } else if (!string.IsNullOrEmpty(language.PartialKeyword)) { output.Add(language.PartialKeyword).Add(" "); } if (template.IsInterface) { output.Add("interface "); } else { output.Add("class "); } output.Add(template.Name); if (template.Generics.Count > 0) { output.Add("<").Add(template.Generics.Select(x => Code.Instance.Type(x.Name)), ", ").Add(">"); } template.BasedOn.OrderBy(x => x.ToType().IsInterface).ForEach(x => output.Add(x)); output.Add(template.Generics.Select(x => x.ToConstraints()).Where(x => x.Types.Count > 0)); output.StartBlock(); if (template.IsInterface) { template.Fields.ForEach(x => x.Visibility = Visibility.None); template.Properties.ForEach(x => x.Visibility = Visibility.None); } bool isFirst = true; if (template.Classes.Count > 0) { output.Add(template.Classes); isFirst = false; } if (template.Fields.Count > 0) { output.If(!isFirst).BreakLine().EndIf(); output.Add(template.Fields); isFirst = false; } if (template.Properties.Count > 0) { output.If(!isFirst).BreakLine().EndIf(); output.Add(template.Properties); isFirst = false; } if (template.Code != null) { output.If(!isFirst).BreakLine().EndIf(); output.Add(template.Code); isFirst = false; } if (template.Methods.Count > 0) { output.If(!isFirst).BreakLine().EndIf(); MethodTemplate last = template.Methods.Last(); foreach (MethodTemplate method in template.Methods) { output.Add(method); if (method != last) { output.BreakLine(); } } } if (this.options.Formatting.CollapseEmptyClasses && output.LastFragments.First().Equals(template)) { output.UnBreakLine(); output.Add(this.options.Formatting.CollapsedClassesSpacer, true); } output.EndBlock(); }
public AttributeWriter(BaseLanguage language) { this.Language = language; }
public override int GetHashCode() => DefaultName.GetHashCode() ^ Version.GetHashCode() ^ Author.GetHashCode() ^ TargetLanguage.GetHashCode() ^ SupportedLanguages.GetHashCode() ^ BaseLanguage.GetHashCode() ^ (Id.GetHashCode() * 7);
public FieldWriter(BaseLanguage language) { this.Language = language; }
public NamespaceWriter(BaseLanguage language) { this.Language = language; }