public static string ToLabel(SupportedLanguage supportedLanguage) { switch (supportedLanguage) { case SupportedLanguage.EnUS: return "LANGUAGE_US_ENGLISH"; case SupportedLanguage.PtBR: return "LANGUAGE_BR_PORTUGUESE"; case SupportedLanguage.EnGB: return "LANGUAGE_GB_ENGLISH"; case SupportedLanguage.GeDE: return "LANGUAGE_DE_GERMAN"; case SupportedLanguage.EsUS: return "LANGUAGE_US_SPANISH"; case SupportedLanguage.EsLA: return "LANGUAGE_LA_SPANISH"; case SupportedLanguage.FrFR: return "LANGUAGE_FR_FRENCH"; case SupportedLanguage.ItIT: return "LANGUAGE_IT_ITALIAN"; case SupportedLanguage.JaJP: return "LANGUAGE_JP_JAPANESE"; case SupportedLanguage.ZhCN: return "LANGUAGE_CN_CHINESE"; } return "NotSpecified"; }
public NRefactoryInsightWindowHandler(SupportedLanguage language) { this.language = language; if (language == SupportedLanguage.CSharp) { eofToken = CSTokens.EOF; commaToken = CSTokens.Comma; openParensToken = CSTokens.OpenParenthesis; closeParensToken = CSTokens.CloseParenthesis; openBracketToken = CSTokens.OpenSquareBracket; closeBracketToken = CSTokens.CloseSquareBracket; openBracesToken = CSTokens.OpenCurlyBrace; closeBracesToken = CSTokens.CloseCurlyBrace; statementEndToken = CSTokens.Semicolon; languageProperties = LanguageProperties.CSharp; } else { eofToken = VBTokens.EOF; commaToken = VBTokens.Comma; openParensToken = VBTokens.OpenParenthesis; closeParensToken = VBTokens.CloseParenthesis; openBracketToken = -1; closeBracketToken = -1; openBracesToken = VBTokens.OpenCurlyBrace; closeBracesToken = VBTokens.CloseCurlyBrace; statementEndToken = VBTokens.EOL; languageProperties = LanguageProperties.VBNet; } }
public void EnableRecognition(SupportedLanguage language) { _language = language; _session = PXCMSession.CreateInstance(); var audioSource = FindAudioSource(); _session.CreateImpl(out _speechRecognition); for (int i = 0; ; i++) { PXCMSpeechRecognition.ProfileInfo profile; if (_speechRecognition.QueryProfile(i, out profile) != RealSenseCamera.NoError) { break; } var languageLabel = profile.language.ToString(); SupportedLanguage sdkLanguage = SupportedLanguageMapper.FromString(languageLabel); if (sdkLanguage != SupportedLanguage.NotSpecified) { _recognitionProfiles.Add(sdkLanguage, profile); } } if (language == SupportedLanguage.NotSpecified) { language = _recognitionProfiles.Keys.First(); } if (!_recognitionProfiles.ContainsKey(language)) { throw new LanguageNotSupportedException(language); } _speechRecognition.SetProfile(_recognitionProfiles[language]); _speechRecognition.SetDictation(); _speechRecognition.StartRec(audioSource, _speechRecognitionHandler); }
public WatchInputBox(string text, string caption) : base() { InitializeComponent(); // UI text = StringParser.Parse(text); this.Title = StringParser.Parse(caption); this.ConsolePanel.Content = console; if (ProjectService.CurrentProject == null) language = GetLanguageFromActiveViewContent(); else language = GetLanguage(ProjectService.CurrentProject.Language); resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language.ToString())); switch (language) { case SupportedLanguage.CSharp: console.SetHighlighting("C#"); break; case SupportedLanguage.VBNet: console.SetHighlighting("VBNET"); break; } // get process this.Process = ((WindowsDebugger)DebuggerService.CurrentDebugger).DebuggedProcess; }
protected NRefactoryCodeCompletionBinding(SupportedLanguage language) { this.language = language; if (language == SupportedLanguage.CSharp) { eofToken = CSTokens.EOF; commaToken = CSTokens.Comma; openParensToken = CSTokens.OpenParenthesis; closeParensToken = CSTokens.CloseParenthesis; openBracketToken = CSTokens.OpenSquareBracket; closeBracketToken = CSTokens.CloseSquareBracket; openBracesToken = CSTokens.OpenCurlyBrace; closeBracesToken = CSTokens.CloseCurlyBrace; languageProperties = LanguageProperties.CSharp; } else { eofToken = VBTokens.EOF; commaToken = VBTokens.Comma; openParensToken = VBTokens.OpenParenthesis; closeParensToken = VBTokens.CloseParenthesis; openBracketToken = -1; closeBracketToken = -1; openBracesToken = VBTokens.OpenCurlyBrace; closeBracesToken = VBTokens.CloseCurlyBrace; languageProperties = LanguageProperties.VBNet; } }
public JsFile GetJsFileFromCodeSnippet(string codeSnippet, SupportedLanguage language) { var file = new JsFile(); var snippetParser = new SnippetParser(language); var jsFile = new JsFile { FullPath = string.Empty }; var parsedNode = snippetParser.Parse(codeSnippet); if (parsedNode.Children.Count > 0) { var visitor = new AstVisitor { Model = jsFile }; parsedNode.AcceptVisitor(visitor, null); file = visitor.Model; return file; } return null; }
public JsFile GetJsFileFromCodeFile(string path, SupportedLanguage language) { TextReader textReader = File.OpenText(path); var file = new JsFile(); using (var parser = ParserFactory.CreateParser(language, textReader)) { var jsFile = new JsFile { FullPath = path }; parser.Parse(); if (parser.Errors.Count <= 0) { var visitor = new AstVisitor { Model = jsFile }; parser.CompilationUnit.AcceptVisitor(visitor, null); file = visitor.Model; return file; } } return null; }
public NRefactoryASTConvertVisitor(IProjectContent projectContent, SupportedLanguage language) { if (language == SupportedLanguage.VBNet) cu = new VBNetCompilationUnit(projectContent); else cu = new DefaultCompilationUnit(projectContent); }
internal static string LoadOutputName(XmlDocument doc, SupportedLanguage language) { var manager = CreateNamespaceManager(doc); string result = null; var assemblyNameElement = doc.SelectSingleNode( "msbuild:Project/msbuild:PropertyGroup/msbuild:AssemblyName", manager) as XmlElement; if (assemblyNameElement != null) { var fileName = assemblyNameElement.InnerText; var extension = ".jar"; if (language != SupportedLanguage.Java) { extension = ".exe"; var outputTypeElement = doc.SelectSingleNode( "msbuild:Project/msbuild:PropertyGroup/msbuild:OutputType", manager) as XmlElement; if (outputTypeElement != null) { var outputType = outputTypeElement.InnerText; if (outputType == "Library") { extension = ".dll"; } } } result = fileName + extension; } return result; }
INode Parse(SupportedLanguage sourceLanguage, string sourceCode, out string error) { project = new DefaultProjectContent(); project.ReferencedContents.AddRange(ReferencedContents); if (sourceLanguage == SupportedLanguage.VBNet) { project.Language = LanguageProperties.VBNet; project.DefaultImports = new DefaultUsing(project); project.DefaultImports.Usings.AddRange(DefaultImportsToAdd); } else { project.Language = LanguageProperties.CSharp; } SnippetParser parser = new SnippetParser(sourceLanguage); INode result = parser.Parse(sourceCode); error = parser.Errors.ErrorOutput; specials = parser.Specials; if (parser.Errors.Count != 0) return null; wasExpression = parser.SnippetType == SnippetType.Expression; if (wasExpression) { // Special case 'Expression': expressions may be replaced with other statements in the AST by the ConvertVisitor, // but we need to return a 'stable' node so that the correct transformed AST is returned. // Thus, we wrap any expressions into a statement block. result = MakeBlockFromExpression((Expression)result); } // now create a dummy compilation unit around the snippet result switch (parser.SnippetType) { case SnippetType.CompilationUnit: compilationUnit = (CompilationUnit)result; break; case SnippetType.Expression: case SnippetType.Statements: compilationUnit = MakeCompilationUnitFromTypeMembers( MakeMethodFromBlock( (BlockStatement)result )); break; case SnippetType.TypeMembers: compilationUnit = MakeCompilationUnitFromTypeMembers(result.Children); break; default: throw new NotSupportedException("Unknown snippet type: " + parser.SnippetType); } // convert NRefactory CU in DOM CU NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(project); visitor.VisitCompilationUnit(compilationUnit, null); visitor.Cu.FileName = sourceLanguage == SupportedLanguage.CSharp ? "a.cs" : "a.vb"; // and register the compilation unit in the DOM foreach (IClass c in visitor.Cu.Classes) { project.AddClassToNamespaceList(c); } parseInfo = new ParseInformation(); parseInfo.SetCompilationUnit(visitor.Cu); return result; }
public static bool ChangeLanguage(SupportedLanguage language, params Form[] forms) { CultureInfo currentCulture; if (language == SupportedLanguage.Automatic) { currentCulture = CultureInfo.InstalledUICulture; } else { string cultureName; switch (language) { default: case SupportedLanguage.English: cultureName = "en-US"; break; case SupportedLanguage.German: cultureName = "de-DE"; break; case SupportedLanguage.French: cultureName = "fr-FR"; break; case SupportedLanguage.Hungarian: cultureName = "hu-HU"; break; case SupportedLanguage.Korean: cultureName = "ko-KR"; break; case SupportedLanguage.SimplifiedChinese: cultureName = "zh-CN"; break; case SupportedLanguage.Turkish: cultureName = "tr-TR"; break; } currentCulture = CultureInfo.GetCultureInfo(cultureName); } if (!currentCulture.Equals(Thread.CurrentThread.CurrentUICulture)) { Helpers.SetDefaultUICulture(currentCulture); DebugHelper.WriteLine("Language changed to: " + currentCulture.DisplayName); foreach (Form form in forms) { ComponentResourceManager resources = new ComponentResourceManager(form.GetType()); ApplyResourceToControl(form, resources, currentCulture); resources.ApplyResources(form, "$this", currentCulture); } return true; } return false; }
public static IParser ast(this string csharpCodeOrFile, SupportedLanguage language) { var codeToParse = (csharpCodeOrFile.fileExists()) ? csharpCodeOrFile.fileContents() : csharpCodeOrFile; var parser = ParserFactory.CreateParser(language, new StringReader(codeToParse)); parser.Parse(); return parser; }
private string GetExtension(SupportedLanguage lang) { if (lang == SupportedLanguage.CSharp) return "cs"; else if (lang == SupportedLanguage.Java) return "java"; else throw new NotSupportedException(); }
/// <summary> /// Initializes a new instance of <see cref="Project"/>, which is rooted at <paramref name="folder"/> /// and is called <paramref name="projectName"/>. /// </summary> /// /// <param name="projectName"> /// The name of the project. /// </param> /// /// <param name="folder"> /// The path to the project. This folder should contain <c><paramref name="projectName"/>.csproj</c>. /// </param> /// /// <param name="language"> /// The programming language used by the source code inside the project. /// </param> /// /// <param name="references"> /// The files representing re-usable code libraries referenced by the project. /// </param> /// /// <param name="outputName"> /// The name of the file (assembly or JAR) that will be generated by the project. /// </param> public Project(string projectName, string folder, SupportedLanguage language, IList<FileInfo> references, string outputName) { _name = projectName; _folder = folder; _language = language; _references = references; _outputName = outputName; }
public LookupTableVisitor(SupportedLanguage language) { this.language = language; if (language == SupportedLanguage.VBNet) { variables = new Dictionary<string, List<LocalLookupVariable>>(StringComparer.InvariantCultureIgnoreCase); } else { variables = new Dictionary<string, List<LocalLookupVariable>>(StringComparer.InvariantCulture); } }
public static Parser.ILexer CreateLexer(SupportedLanguage language, TextReader textReader) { switch (language) { case SupportedLanguage.CSharp: return new ICSharpCode.NRefactory.Parser.CSharp.Lexer(textReader); case SupportedLanguage.VBNet: return new ICSharpCode.NRefactory.Parser.VB.Lexer(textReader); } throw new System.NotSupportedException(language + " not supported."); }
public static CodeDomProvider CreateCodeProvider(SupportedLanguage language = SupportedLanguage.CSharp) { switch (language) { default: case SupportedLanguage.CSharp: return new CSharpCodeProvider(); case SupportedLanguage.VBNet: return new VBCodeProvider(); } }
public static Parser.ILexer CreateLexer(SupportedLanguage language, TextReader textReader, LexerMemento state) { switch (language) { case SupportedLanguage.CSharp: //return new ICSharpCode.NRefactory.Parser.CSharp.Lexer(textReader, state); throw new System.NotSupportedException("C# Lexer does not support loading a previous state."); case SupportedLanguage.VBNet: return new ICSharpCode.NRefactory.Parser.VB.Lexer(textReader, state); } throw new System.NotSupportedException(language + " not supported."); }
protected NRefactoryCodeCompletionBinding(SupportedLanguage language) { this.language = language; if (language == SupportedLanguage.CSharp) { languageProperties = LanguageProperties.CSharp; } else { languageProperties = LanguageProperties.VBNet; } insightHandler = new NRefactoryInsightWindowHandler(language); }
INode Parse(SupportedLanguage sourceLanguage, string sourceCode, out string error) { project = new DefaultProjectContent(); project.ReferencedContents.AddRange(ReferencedContents); if (sourceLanguage == SupportedLanguage.VBNet) { project.DefaultImports = new DefaultUsing(project); project.DefaultImports.Usings.AddRange(DefaultImportsToAdd); } SnippetParser parser = new SnippetParser(sourceLanguage); INode result = parser.Parse(sourceCode); error = parser.Errors.ErrorOutput; specials = parser.Specials; if (parser.Errors.Count != 0) return null; // now create a dummy compilation unit around the snippet result switch (parser.SnippetType) { case SnippetType.CompilationUnit: compilationUnit = (CompilationUnit)result; break; case SnippetType.Expression: compilationUnit = MakeCompilationUnitFromTypeMembers( MakeMethodFromBlock( MakeBlockFromExpression( (Expression)result ))); break; case SnippetType.Statements: compilationUnit = MakeCompilationUnitFromTypeMembers( MakeMethodFromBlock( (BlockStatement)result )); break; case SnippetType.TypeMembers: compilationUnit = MakeCompilationUnitFromTypeMembers(result.Children); break; default: throw new NotSupportedException("Unknown snippet type: " + parser.SnippetType); } // convert NRefactory CU in DOM CU NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(project); visitor.VisitCompilationUnit(compilationUnit, null); visitor.Cu.FileName = sourceLanguage == SupportedLanguage.CSharp ? "a.cs" : "a.vb"; // and register the compilation unit in the DOM foreach (IClass c in visitor.Cu.Classes) { project.AddClassToNamespaceList(c); } parseInfo = new ParseInformation(); parseInfo.SetCompilationUnit(visitor.Cu); return result; }
public static INode Parse(string code, SupportedLanguage language) { SnippetParser parser = new SnippetParser(language); INode astRoot = parser.Parse(code); if (parser.Errors.Count > 0) { throw new GetValueException(parser.Errors.ErrorOutput); } if (parser.SnippetType != SnippetType.Expression && parser.SnippetType != SnippetType.Statements) { throw new GetValueException("Code must be expression or statement"); } return astRoot; }
public static bool Convert(SupportedLanguage inputLanguage, string ProvidedSource, out string ConvertedSource, out string ErrorMessage) { NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(inputLanguage); string convertedCode = converter.Convert(ProvidedSource); ConvertedSource = convertedCode; ErrorMessage = ""; return true; }
/// <summary> /// Get a ILanguageHelper from SupportedLanguage enum. /// </summary> /// <param name="language">supported language</param> /// <returns>ILanguageHelper implementation</returns> public static ILanguageHelper GetLanguageHelper(SupportedLanguage language) { switch (language) { case SupportedLanguage.CSharp: return new CSharpHelper(); case SupportedLanguage.VisualBasic: return new VisualBasicHelper(); default: throw new System.NotSupportedException("this language is not supported"); } }
void TestProgram(SupportedLanguage sourceLanguage, string sourceCode, string expectedOutput) { DefaultProjectContent pc = new DefaultProjectContent(); pc.ReferencedContents.Add(projectContentRegistry.Mscorlib); pc.ReferencedContents.Add(projectContentRegistry.GetProjectContentForReference("System.Windows.Forms", "System.Windows.Forms")); if (sourceLanguage == SupportedLanguage.VBNet) { pc.ReferencedContents.Add(projectContentRegistry.GetProjectContentForReference("Microsoft.VisualBasic", "Microsoft.VisualBasic")); pc.DefaultImports = new DefaultUsing(pc); pc.DefaultImports.Usings.Add("System"); pc.DefaultImports.Usings.Add("Microsoft.VisualBasic"); } pc.Language = sourceLanguage == SupportedLanguage.CSharp ? LanguageProperties.CSharp : LanguageProperties.VBNet; HostCallback.GetCurrentProjectContent = delegate { return pc; }; ICSharpCode.NRefactory.IParser parser = ParserFactory.CreateParser(sourceLanguage, new StringReader(sourceCode)); parser.Parse(); Assert.AreEqual("", parser.Errors.ErrorOutput); NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(pc); visitor.VisitCompilationUnit(parser.CompilationUnit, null); visitor.Cu.FileName = sourceLanguage == SupportedLanguage.CSharp ? "a.cs" : "a.vb"; foreach (IClass c in visitor.Cu.Classes) { pc.AddClassToNamespaceList(c); } ParseInformation parseInfo = new ParseInformation(); parseInfo.SetCompilationUnit(visitor.Cu); if (sourceLanguage == SupportedLanguage.CSharp) { CSharpToVBNetConvertVisitor convertVisitor = new CSharpToVBNetConvertVisitor(pc, parseInfo); convertVisitor.RootNamespaceToRemove = "RootNamespace"; parser.CompilationUnit.AcceptVisitor(convertVisitor, null); } else { VBNetToCSharpConvertVisitor convertVisitor = new VBNetToCSharpConvertVisitor(pc, parseInfo); parser.CompilationUnit.AcceptVisitor(convertVisitor, null); } IOutputAstVisitor outputVisitor = sourceLanguage == SupportedLanguage.CSharp ? (IOutputAstVisitor)new VBNetOutputVisitor() : new CSharpOutputVisitor(); outputVisitor.Options.IndentationChar = ' '; outputVisitor.Options.IndentSize = 2; using (SpecialNodesInserter.Install(parser.Lexer.SpecialTracker.RetrieveSpecials(), outputVisitor)) { outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null); } Assert.AreEqual("", outputVisitor.Errors.ErrorOutput); Assert.AreEqual(expectedOutput.Replace("\r", ""), outputVisitor.Text.Trim().Replace("\r", "")); }
/// <summary> /// Locates the translation in internal (cache) list and returns. /// If not found will return NULL (to ease check) /// </summary> /// <param name="propertyName">Name of the property.</param> /// <param name="language">Value of the SupportedLanguage.</param> /// <param name="textType">Value of the TranslatedTextType</param> /// <returns>Found translation string or NULL if not found</returns> private string LocateTranslation(string propertyName, SupportedLanguage language, TranslatedTextType textType) { // FOR: because it is fastest locator http://www.schnieds.com/2009/03/linq-vs-foreach-vs-for-loop-performance.html for (int i = 0; i < this.modelElementTranslations.Count; i++) { if (this.modelElementTranslations[i].PropertyName == propertyName && this.modelElementTranslations[i].Language == language && this.modelElementTranslations[i].TranslationType == textType) { return this.modelElementTranslations[i].TranslatedText; } } // not found if came here return null; }
ICompilationUnit Parse(string code, SupportedLanguage language, params IProjectContent[] references) { DefaultProjectContent pc = new DefaultProjectContent(); foreach (var reference in references) { pc.AddReferencedContent(reference); } NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(pc, language); using (IParser p = ParserFactory.CreateParser(language, new StringReader(code))) { p.ParseMethodBodies = false; p.Parse(); visitor.Specials = p.Lexer.SpecialTracker.CurrentSpecials; visitor.VisitCompilationUnit(p.CompilationUnit, null); } return visitor.Cu; }
ICompilationUnit Parse(string code, SupportedLanguage language, bool referenceMscorlib) { DefaultProjectContent pc = new DefaultProjectContent(); if (referenceMscorlib) { pc.AddReferencedContent(SharedProjectContentRegistryForTests.Instance.Mscorlib); } NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(pc); using (IParser p = ParserFactory.CreateParser(language, new StringReader(code))) { p.ParseMethodBodies = false; p.Parse(); visitor.Specials = p.Lexer.SpecialTracker.CurrentSpecials; visitor.VisitCompilationUnit(p.CompilationUnit, null); } return visitor.Cu; }
/// <returns> Returned value or null for statements </returns> public static Value Evaluate(string code, SupportedLanguage language, StackFrame context) { SnippetParser parser = new SnippetParser(language); INode astRoot = parser.Parse(code); if (parser.SnippetType == SnippetType.Expression || parser.SnippetType == SnippetType.Statements) { if (parser.Errors.Count > 0) { throw new GetValueException(parser.Errors.ErrorOutput); } try { EvaluateAstVisitor visitor = new EvaluateAstVisitor(context); return astRoot.AcceptVisitor(visitor, null) as Value; } catch (NotImplementedException e) { throw new GetValueException("Language feature not implemented: " + e.Message); } } throw new GetValueException("Code must be expression or statement"); }
/// <summary> /// Compile source code /// </summary> /// <param name="code">full source code to compile</param> /// <param name="references">assembly references</param> /// <param name="language">target language</param> /// <param name="profile">compiler profile</param> public void Compile(string code, string[] references, SupportedLanguage language, CompilerProfile profile) { var properties = new Dictionary<string, string> {{CompilerVersion, profile.CompilerVersion}}; CodeDomProvider provider; switch (language) { case SupportedLanguage.CSharp: provider = new CSharpCodeProvider(properties); break; case SupportedLanguage.VisualBasic: provider = new VBCodeProvider(properties); break; default: throw new ArgumentException(); } var parameters = new CompilerParameters { GenerateExecutable = false, GenerateInMemory = false, IncludeDebugInformation = false }; parameters.ReferencedAssemblies.AddRange(references); var CompilerOptions = new List<string>(); if (language == SupportedLanguage.CSharp) CompilerOptions.Add("/unsafe"); if (profile.NoStdLib) CompilerOptions.Add("/nostdlib"); if (CompilerOptions.Count > 0) parameters.CompilerOptions = string.Join(" ", CompilerOptions.ToArray()); var results = provider.CompileAssemblyFromSource(parameters, code); AssemblyLocation = null; Errors = results.Errors; if (!results.Errors.HasErrors) AssemblyLocation = results.CompiledAssembly.Location; }
public static int getIdForSuportedLanguage(SupportedLanguage language) { switch (language) { case SupportedLanguage.Cpp: return 1; case SupportedLanguage.Java: return 2; case SupportedLanguage.DotNet: return 3; case SupportedLanguage.ASP_VB6: return 4; case SupportedLanguage.Cobol: return 5; default: DI.log.error("in MySqlRules_OunceV6.getIdForSuportedLanguage, unsupported language: {0}", language.ToString()); return -1; } }
public void Say(string sentence, SupportedLanguage language) { _speechSynthesis.Say(sentence, language); }
public static string GetTypeFullName(string assemblyFilePath, uint moduleToken, uint typeToken, SupportedLanguage language) { return(GetTypeNamespace(assemblyFilePath, moduleToken, typeToken) + "." + GetTypeName(assemblyFilePath, moduleToken, typeToken, language)); }
public static ICollection <IPropertyMethod> GetPropertyMethods(string assemblyFilePath, uint moduleToken, uint typeToken, uint propertyToken, SupportedLanguage language) { IMemberDefinition member = GetMember(assemblyFilePath, moduleToken, typeToken, propertyToken, language); if (!(member is PropertyDefinition)) { throw new NotSupportedException("Member is not a property."); } PropertyDefinition property = member as PropertyDefinition; ICollection <IPropertyMethod> result = new List <IPropertyMethod>(); if (property.GetMethod != null) { result.Add(new PropertyMethod(PropertyMethodType.GetMethod, property.GetMethod.MetadataToken.ToUInt32())); } if (property.SetMethod != null) { result.Add(new PropertyMethod(PropertyMethodType.SetMethod, property.SetMethod.MetadataToken.ToUInt32())); } return(result); }
public static ICollection <IEventMethod> GetEventMethods(string assemblyFilePath, uint moduleToken, uint typeToken, uint eventToken, SupportedLanguage language) { IMemberDefinition member = GetMember(assemblyFilePath, moduleToken, typeToken, eventToken, language); if (!(member is EventDefinition)) { throw new NotSupportedException("Member is not an event."); } EventDefinition @event = member as EventDefinition; ICollection <IEventMethod> result = new List <IEventMethod>(); if (@event.AddMethod != null) { result.Add(new EventMethod(EventMethodType.AddMethod, @event.AddMethod.MetadataToken.ToUInt32())); } if (@event.RemoveMethod != null) { result.Add(new EventMethod(EventMethodType.RemoveMethod, @event.RemoveMethod.MetadataToken.ToUInt32())); } if (@event.InvokeMethod != null) { result.Add(new EventMethod(EventMethodType.InvokeMethod, @event.InvokeMethod.MetadataToken.ToUInt32())); } return(result); }
public static ICollection <string> GetTypeAttributes(string assemblyFilePath, uint moduleToken, uint typeToken, SupportedLanguage language) { TypeDefinition type = GetTypeDefinition(assemblyFilePath, moduleToken, typeToken); StringWriter stringWriter = new StringWriter(); AttributeWriter attributeWriter = GetAttributeWriter(type, language, stringWriter); attributeWriter.WriteMemberAttributesAndNewLine(type); return(stringWriter.ToString().Split('\n')); }
protected override void OnCreateMainForm() { base.OnCreateMainForm(); RegistrySettings.Load(); UserLookAndFeel.Default.SkinName = RegistrySettings.SkinName; SupportedLanguage current = SupportedLanguage.Türkçe; // default if (Enum.TryParse(RegistrySettings.Language, out current)) { } LanguageManager.ChangeLanguage(current, null); /* MainForm = new mainFrm(); * return;*/ if (RegistrySettings.KeepLoggedIn) { var loginResult = KODevLoginManager.Login(StaticReference.Decrypt(RegistrySettings.Username, RegistrySettings._key, RegistrySettings._keySize), StaticReference.Decrypt(RegistrySettings.Password, RegistrySettings._key, RegistrySettings._keySize)); switch (loginResult.Result.Substring(0, 29)) { //LOGINSTATUS_KEY_3 (TOKEN METHODU İÇİN) Token mevcut, fakat süresi dolmuş. Yeniden ID şifre ile token almak gerekli. case "LS003F5esRwzAPt33psnJdEt7eJkT": //LOGINSTATUS_KEY_4 (TOKEN METHODU İÇİN) Token mevcut, geçerli fakat kullanıcının gönderdiği değer yanlış! case "LS004GUcuNEM67D2P5PbUXqTLPHTt": //LOGINSTATUS_KEY_5 (PAROLA METHODU İÇİN) Hesap şuan kullanımda (token başkasında.) case "LS004rPrCHnnYLHUREjrh2fUggjQJ": //LOGINSTATUS_KEY_1 (PAROLA METHODU İÇİN) ID veya Parola yanlış. case "LS001Gs84DmanHUWmrWwLgDKysrFk": StaticReference.ShowError((XtraForm)MainForm, loginResult.Message); // failure, redirect to login page using (frmLogin login = new frmLogin()) { login.ShowDialog(); } break; //LOGINSTATUS_KEY_2 (TOKEN METHODU İÇİN) Token mevcut, geçerli ve doğru. case "LS002RvkzvsDWeLdGDGCKHDKx8SuP": //LOGINSTATUS_KEY_T (PAROLA METHODU İÇİN) ID ve Parola doğru, token değeri JSON içerisinde token kısmına eklenir. case "LS00TF5esRwzAPt33psnJdEt7eJkT": RegistrySettings.LoggedIn = true; break; //LOGINSTATUS_KEY_E case "LS00Ef9TV4vPbmGh9tytn7HdTMZp2": StaticReference.ShowError((XtraForm)MainForm, loginResult.Message); break; } } else { using (frmLogin login = new frmLogin()) { login.ShowDialog(); } } if (RegistrySettings.LoggedIn) { MainForm = new mainFrm(); } else { Environment.Exit(0); } }
private Image GetLanguageIcon(SupportedLanguage language) { Image icon; switch (language) { default: case SupportedLanguage.Automatic: icon = Resources.globe; break; case SupportedLanguage.Dutch: icon = Resources.nl; break; case SupportedLanguage.English: icon = Resources.us; break; case SupportedLanguage.French: icon = Resources.fr; break; case SupportedLanguage.German: icon = Resources.de; break; case SupportedLanguage.Hungarian: icon = Resources.hu; break; case SupportedLanguage.Korean: icon = Resources.kr; break; case SupportedLanguage.PortugueseBrazil: icon = Resources.br; break; case SupportedLanguage.Russian: icon = Resources.ru; break; case SupportedLanguage.SimplifiedChinese: icon = Resources.cn; break; case SupportedLanguage.Spanish: icon = Resources.es; break; case SupportedLanguage.Turkish: icon = Resources.tr; break; case SupportedLanguage.Vietnamese: icon = Resources.vn; break; } return(icon); }
public static IAssemblyDecompilationResults GenerateFiles(string assemblyFilePath, AssemblyDefinition assembly, string targetPath, SupportedLanguage language, CancellationToken cancellationToken, bool decompileDangerousResources, IFileGenerationNotifier notifier = null) { ILanguage decompilerLanguage = GetLanguage(language); string csprojFileName = Path.ChangeExtension(Path.GetFileName(assemblyFilePath), decompilerLanguage.VSProjectFileExtension); string csprojTargetPath = Path.Combine(targetPath, csprojFileName); Dictionary <ModuleDefinition, Mono.Collections.Generic.Collection <TypeDefinition> > assemblyUserDefinedTypes = Utilities.GetUserDefinedTypes(assembly, decompileDangerousResources); Dictionary <ModuleDefinition, Mono.Collections.Generic.Collection <Resource> > assemblyResources = Utilities.GetResources(assembly); IDecompilationPreferences decompilationPreferences = new DecompilationPreferences() { DecompileDangerousResources = decompileDangerousResources }; JustAssemblyProjectBuilder projectBuilder; if (notifier != null) { projectBuilder = new JustAssemblyProjectBuilder(assemblyFilePath, assembly, assemblyUserDefinedTypes, assemblyResources, csprojTargetPath, decompilerLanguage, decompilationPreferences, new FileGenerationNotifier(notifier)); } else { projectBuilder = new JustAssemblyProjectBuilder(assemblyFilePath, assembly, assemblyUserDefinedTypes, assemblyResources, csprojTargetPath, decompilerLanguage, decompilationPreferences, null); } return(projectBuilder.GenerateFiles(cancellationToken)); }
/// <summary> /// Initializes a new instance of the <see cref="CollinsDictionaryGetEntry"/> class. /// </summary> /// <param name="account">The instance of the <see cref="Account"/> class to use to store the OAuth 2.0 account /// credentials.</param> /// <param name="wordId">The word ID of the definition to be retrieved.</param> /// <param name="language">Language Enum</param> public CollinsDictionaryGetEntry(Account account, string wordId, SupportedLanguage language) : base(new Uri(Config.TellOPConfiguration.GetEndpoint("TellOP.API.CollinsDictionaryGetEntry." + language.ToLCID()) + "?entryId=" + Uri.EscapeDataString(wordId)), HttpMethod.Get, account) { }
private void LanguageChangedHandler(object sender, SupportedLanguage language) { this.UpdateLanguage(language); }
public OxfordDictionaryAPI(Account account, SupportedLanguage language) : base(Config.TellOPConfiguration.GetEndpointAsUri("TellOP.API.OxfordDictionary." + language), HttpMethod.Get, account) { throw new NotImplementedException("Calling this constructor without passing the search term is not supported"); }
private ApiAi InitializeAPIAIProvider(string accessToken, SupportedLanguage supportedLanguage) { AIConfiguration aiConfig = new AIConfiguration(accessToken, supportedLanguage ?? SUPPORTED_LANGUAGE); return(new ApiAi(aiConfig)); }
public APIAIProvider(string accessToken = ACCESS_TOKEN, SupportedLanguage supportedLanguage = null) { this._apiAI = InitializeAPIAIProvider(accessToken, supportedLanguage ?? SUPPORTED_LANGUAGE); }
internal static IMemberDefinition GetMember(string assemblyFilePath, uint moduleToken, uint typeToken, uint memberToken, SupportedLanguage language) { MembersCacheKey key = new MembersCacheKey() { AssemblyFilePath = assemblyFilePath, ModuleToken = moduleToken, TypeToken = typeToken, MemberToken = memberToken }; IMemberDefinition result; if (!MembersCache.TryGetValue(key, out result)) { TypeDefinition type = GetTypeDefinition(assemblyFilePath, moduleToken, typeToken); IEnumerable <IMemberDefinition> typeMembers = type.GetMembersSorted(true, GetLanguage(language)); result = typeMembers.Where(x => x.MetadataToken.ToUInt32() == memberToken).FirstOrDefault(); MembersCache.Add(key, result); } return(result); }
public TaggerFactory(TagOptions options, SupportedLanguage lang) { _lang = lang; _options = options; _tagger = new ITag(); }
public static SentenceEvaluationResult Evaluate(SupportedLanguage language, string script, byte[] wavData) { var wordList = script.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); var words = wordList.Select(w => language == SupportedLanguage.English ? w.ToUpper() : w).ToArray(); foreach (var word in words) { if (!phonemeDictionary.Contains(word)) { Trace.TraceError("ScoringHost::Evaluate(), unable to identify the word, Content={0}", word); throw new ArgumentOutOfRangeException(word); } } var mfcData = FeatureGenerator.ExtractMfcFeature(wavData); if (mfcData == null || mfcData.Length == 0) { Trace.TraceError("ScoringHost::Evaluate(), mfc extraction error!"); throw new ArgumentException("mfc extraction error!"); } double[] f0Data = FeatureGenerator.ExtractF0Feature(wavData); if (f0Data == null || f0Data.Length == 0) { Trace.TraceWarning("ScoringHost::Evaluate(), f0 extraction error!"); throw new InvalidDataException("f0 extraction error!"); } if (SupportedLanguage.Chinese == language) { mfcData = FeatureGenerator.AppendF0Feature(f0Data, mfcData); } IList <string> wordsWithSilence = new List <string>(words); wordsWithSilence.Insert(0, "<s>"); wordsWithSilence.Add("</s>"); int maxLength = 0; if (language == SupportedLanguage.English) { maxLength = PhonemeResultMaxLength * 12 * words.Length; } else if (language == SupportedLanguage.Chinese) { maxLength = PhonemeResultMaxLength * 5 * words.Length; } if (maxLength < EvaluateResultMinLength) { maxLength = EvaluateResultMinLength; } var resultBuffer = new StringBuilder(maxLength); var resultLength = NativeMethods.Evaluate( mfcData, string.Empty, resultBuffer, maxLength, wordsWithSilence.ToArray(), wordsWithSilence.Count); if (resultLength < 0) { Trace.TraceError("ScoringHost::Evaluate(), invalid audio content, length of evaluation result: {0}.", resultLength); throw new ArgumentException("Invalid audio content."); } var evaluationResult = resultBuffer.ToString(0, resultLength); var phonemeEvaluationResults = evaluationResult.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); try { return(CreateSentenceEvaluationResult(words.Length, phonemeEvaluationResults, f0Data, language)); } catch (ArgumentException) { Trace.TraceError("ScoringHost::Evaluate(), bad phoneme evaluation result, sentence: {0}, result: {1}", script, evaluationResult); throw; } }
public ClassifierFactory(ClassifyOptions options, SupportedLanguage lang) { _lang = lang; _options = options; featureExtractor = new IFeatureExtractor(); }
INode Parse(SupportedLanguage sourceLanguage, string sourceCode, out string error) { project = new DefaultProjectContent(); project.ReferencedContents.AddRange(ReferencedContents); if (sourceLanguage == SupportedLanguage.VBNet) { project.DefaultImports = new DefaultUsing(project); project.DefaultImports.Usings.AddRange(DefaultImportsToAdd); } SnippetParser parser = new SnippetParser(sourceLanguage); INode result = parser.Parse(sourceCode); error = parser.Errors.ErrorOutput; specials = parser.Specials; if (parser.Errors.Count != 0) { return(null); } wasExpression = parser.SnippetType == SnippetType.Expression; if (wasExpression) { // Special case 'Expression': expressions may be replaced with other statements in the AST by the ConvertVisitor, // but we need to return a 'stable' node so that the correct transformed AST is returned. // Thus, we wrap any expressions into a statement block. result = MakeBlockFromExpression((Expression)result); } // now create a dummy compilation unit around the snippet result switch (parser.SnippetType) { case SnippetType.CompilationUnit: compilationUnit = (CompilationUnit)result; break; case SnippetType.Expression: case SnippetType.Statements: compilationUnit = MakeCompilationUnitFromTypeMembers( MakeMethodFromBlock( (BlockStatement)result )); break; case SnippetType.TypeMembers: compilationUnit = MakeCompilationUnitFromTypeMembers(result.Children); break; default: throw new NotSupportedException("Unknown snippet type: " + parser.SnippetType); } // convert NRefactory CU in DOM CU NRefactoryASTConvertVisitor visitor = new NRefactoryASTConvertVisitor(project); visitor.VisitCompilationUnit(compilationUnit, null); visitor.Cu.FileName = sourceLanguage == SupportedLanguage.CSharp ? "a.cs" : "a.vb"; // and register the compilation unit in the DOM foreach (IClass c in visitor.Cu.Classes) { project.AddClassToNamespaceList(c); } parseInfo = new ParseInformation(); parseInfo.SetCompilationUnit(visitor.Cu); return(result); }
private void updateLanguage(SupportedLanguage l) { this.btnYes.Text = l.GetText(MsgCode.yes); this.btnNo.Text = l.GetText(MsgCode.no); }
public static int GetMaximumPossibleTargetPathLength(string assemblyFilePath, SupportedLanguage language, bool decompileDangerousResources) { AssemblyDefinition assembly = GlobalAssemblyResolver.Instance.GetAssemblyDefinition(assemblyFilePath); ILanguage decompilerLanguage = GetLanguage(language); JustAssemblyFilePathsAnalyzer filePathsAnalyzer = new JustAssemblyFilePathsAnalyzer(assembly, decompilerLanguage, decompileDangerousResources); return(filePathsAnalyzer.GetMaximumPossibleTargetPathLength()); }
public static AccessModifier GetMemberAccessModifier(string assemblyFilePath, uint moduleToken, uint typeToken, uint memberToken, SupportedLanguage language) { IMemberDefinition member = GetMember(assemblyFilePath, moduleToken, typeToken, memberToken, language); if (member is MethodDefinition) { return(GetVisibilityDefinitionAccessModifiers(member as MethodDefinition)); } if (member is FieldDefinition) { return(GetVisibilityDefinitionAccessModifiers(member as FieldDefinition)); } if (member is PropertyDefinition) { PropertyDefinition property = member as PropertyDefinition; MethodDefinition moreVisibleMethod = property.GetMethod.GetMoreVisibleMethod(property.SetMethod); return(GetVisibilityDefinitionAccessModifiers(moreVisibleMethod)); } if (member is EventDefinition) { EventDefinition @event = member as EventDefinition; MethodDefinition moreVisibleMethod = @event.AddMethod.GetMoreVisibleMethod(@event.RemoveMethod); return(GetVisibilityDefinitionAccessModifiers(moreVisibleMethod)); } throw new NotSupportedException("Unexpected member type."); }
public SnippetParser(SupportedLanguage language) { this.language = language; }
Program(string vkToken, string aiToken, SupportedLanguage lang) { this.vkToken = vkToken; aiConfig = new AIConfiguration(aiToken, lang); }
public static string GetCultureName(SupportedLanguage language) { string cultureName; switch (language) { case SupportedLanguage.Dutch: cultureName = "nl-NL"; break; default: case SupportedLanguage.English: cultureName = "en-US"; break; case SupportedLanguage.French: cultureName = "fr-FR"; break; case SupportedLanguage.German: cultureName = "de-DE"; break; case SupportedLanguage.Hungarian: cultureName = "hu-HU"; break; case SupportedLanguage.Indonesian: cultureName = "id-ID"; break; case SupportedLanguage.Italian: cultureName = "it-IT"; break; case SupportedLanguage.Korean: cultureName = "ko-KR"; break; case SupportedLanguage.PortugueseBrazil: cultureName = "pt-BR"; break; case SupportedLanguage.Russian: cultureName = "ru-RU"; break; case SupportedLanguage.SimplifiedChinese: cultureName = "zh-CN"; break; case SupportedLanguage.Spanish: cultureName = "es-ES"; break; case SupportedLanguage.TraditionalChinese: cultureName = "zh-TW"; break; case SupportedLanguage.Turkish: cultureName = "tr-TR"; break; case SupportedLanguage.Ukrainian: cultureName = "uk-UA"; break; case SupportedLanguage.Vietnamese: cultureName = "vi-VN"; break; } return(cultureName); }
public static string GetMemberName(string assemblyFilePath, uint moduleToken, uint typeToken, uint memberToken, SupportedLanguage language) { IMemberDefinition member = GetMember(assemblyFilePath, moduleToken, typeToken, memberToken, language); ILanguage decompilerLanguage = GetLanguage(language); return(MemberNamingUtils.GetMemberDeclartionForLanguage(member, decompilerLanguage, true)); }
public static ICollection <string> GetMemberAttributes(string assemblyFilePath, uint moduleToken, uint typeToken, uint memberToken, SupportedLanguage language) { IMemberDefinition member = GetMember(assemblyFilePath, moduleToken, typeToken, memberToken, language); StringWriter stringWriter = new StringWriter(); AttributeWriter attributeWriter = GetAttributeWriter(member, language, stringWriter); attributeWriter.WriteMemberAttributesAndNewLine(member); return(stringWriter.ToString().Split('\n').Where(s => !string.IsNullOrEmpty(s)).ToList()); }
public void EnableRecognition(SupportedLanguage language) { _speechRecognition.EnableRecognition(language); }
public StemmerFactory(StemOptions options, SupportedLanguage lang) { _lang = lang; _options = options; _stemmer = new IStem(); }
private static SentenceEvaluationResult CreateSentenceEvaluationResult(int wordsCount, string[] phonemeNativeResults, double[] f0Data, SupportedLanguage language) { if (phonemeNativeResults == null || phonemeNativeResults.Length <= 0) { throw new ArgumentException("Phoneme evaluation result is null or empty."); } var validPhonemeNativeResults = phonemeNativeResults.Select(l => new PhonemeNativeResult(l)).Where(p => p.IsValid); var startWordsCount = validPhonemeNativeResults.Count(n => n.IsStartOfWord); if (startWordsCount != wordsCount) { throw new ArgumentException("Word count of phoneme evaluation result is not equal to original sentence."); } if (!validPhonemeNativeResults.First().IsStartOfWord) { throw new ArgumentException("The first phoneme is not start of a word."); } var enumerator = validPhonemeNativeResults.GetEnumerator(); List <PhonemeEvaluationResult> wordPhonemeEvaluationResults = null; var sentenceEvaluationResult = new SentenceEvaluationResult { Words = new List <WordEvaluationResult>(), }; var currentWord = string.Empty; while (true) { var eof = !enumerator.MoveNext(); if ((eof || enumerator.Current.IsStartOfWord) && (wordPhonemeEvaluationResults != null && wordPhonemeEvaluationResults.Count != 0)) { var phonemesAvgScore = wordPhonemeEvaluationResults.Average(n => n.Score); sentenceEvaluationResult.Words.Add( new WordEvaluationResult { Score = Math.Round(ScoringHost.GetScorePercentage(phonemesAvgScore), 2), StartTime = wordPhonemeEvaluationResults.First().StartTime, EndTime = wordPhonemeEvaluationResults.Last().EndTime, Word = currentWord, Phonemes = wordPhonemeEvaluationResults, }); } if (eof) { break; } if (enumerator.Current.IsStartOfWord) { currentWord = enumerator.Current.Word; wordPhonemeEvaluationResults = new List <PhonemeEvaluationResult>(); } var phonemeEvaluationResult = new PhonemeEvaluationResult(enumerator.Current); if (language == SupportedLanguage.English) { phonemeEvaluationResult.Phoneme = PhonemeConverter.ConvertToIPA(phonemeEvaluationResult.Phoneme, currentWord, wordPhonemeEvaluationResults.Count()); } wordPhonemeEvaluationResults.Add(phonemeEvaluationResult); } var wordsAvgScore = sentenceEvaluationResult.Words.Average(w => w.Score); sentenceEvaluationResult.Score = Math.Round(wordsAvgScore, 2); sentenceEvaluationResult.ToneF0Data = f0Data; return(sentenceEvaluationResult); }
public static ICollection <Tuple <MemberType, uint> > GetTypeMembers(string assemblyFilePath, uint moduleToken, uint typeToken, SupportedLanguage language) { ICollection <Tuple <MemberType, uint> > result = new List <Tuple <MemberType, uint> >(); TypeDefinition type = GetTypeDefinition(assemblyFilePath, moduleToken, typeToken); IEnumerable <string> attributesToSkip = null; if (Utilities.ShouldBePartial(type)) { attributesToSkip = new string[1] { "System.CodeDom.Compiler.GeneratedCodeAttribute" }; } ModuleDefinition module = GetModuleDefinition(assemblyFilePath, moduleToken); IEnumerable <IMemberDefinition> typeMembers = type.GetMembersSorted(false, GetLanguage(language), attributesToSkip, null); return(typeMembers.Select(x => new Tuple <MemberType, uint>(GetMemberType(x), x.MetadataToken.ToUInt32())).ToList()); }