public void CreateAndReplaceIfRequired(string outputFileOriginal, string outputFile, TargetLanguage targetLanguage)
        {
            if (File.Exists(outputFileOriginal))
            {

                FileAttributes fa = File.GetAttributes(outputFileOriginal);
                fa = FileAttributes.Archive;
                File.SetAttributes(outputFileOriginal, fa);

                if (false == FileCompare(outputFileOriginal, outputFile))
                {
                    StreamWriter swo = new StreamWriter(outputFileOriginal);
                    swo.Close();
                    File.Delete(outputFileOriginal);
                    File.Copy(outputFile, outputFileOriginal);
                }
            }
            else
            {
                File.Copy(outputFile, outputFileOriginal);
            }

            File.Delete(outputFile);
            outputFile = outputFileOriginal;
        }
        /// <summary>
        /// Create an AccountInformation instance from an XML string
        /// </summary>
        /// <param name="element">An Account element</param>
        internal AccountInformation(XElement element)
            : this()
        {
            if (element != null)
            {
                this.Email = element.GetChildValue("Email");

                this.Currency = element.GetChildValue("Currency");

                this.TotalSpent = element.GetChildValueAsDecimal("TotalSpent");

                this.TranslationCredit = element.GetChildValueAsInt32("TranslationCredit");

                this.TranslationCreditUsed = element.GetChildValueAsInt32("TranslationCreditUsed");

                this.PrepaidCredit = element.GetChildValueAsDecimal("PrepaidCredit");

                this.ProductCount = element.GetChildValueAsInt32("ProductCount");

                XElement targetLanguagesElement = element.Element("TargetLanguages");
                if (targetLanguagesElement != null)
                {
                    List<TargetLanguage> targets = new List<TargetLanguage>();

                    foreach (XElement targetLanguageElement in targetLanguagesElement.Elements("TargetLanguage"))
                    {
                        TargetLanguage targetLanguage = new TargetLanguage(targetLanguageElement);
                        targets.Add(targetLanguage);
                    }

                    this.TargetLanguages = targets;
                }
            }
        }
 public CppWriter(
     List<String> classNamesNoNestedTypes,
     List<String> classNames,
     List<String> includeFiles,
     List<String> includeFilesToSkip,
     List<String> externalNamespaces,
     Dictionary<int, string> xsdnNamespaces,
     string destinationFolder,
     string outerClassName,
     Dictionary<string, List<ClassElement>> externalClassesToGenerateMap,
     Dictionary<string, string> externalClassesnNamespaces,
     Dictionary<string, string> externalEnumsnNamespaces,
     Dictionary<string, List<EnumElement>> externalEnumsToGenerateMap,
     TargetLanguage targetLanguage
     )
 {
     _targetLanguage = targetLanguage;
     _classNamesNoNestedTypes = classNamesNoNestedTypes;
     _classNames = classNames;
     _includeFiles = includeFiles;
     _includeFilesToSkip = includeFilesToSkip;
     _externalNamespaces = externalNamespaces;
     _xsdnNamespaces = xsdnNamespaces;
     _destinationFolder = destinationFolder;
     _outerClassName = outerClassName;
     _externalClassesToGenerateMap = externalClassesToGenerateMap;
     _externalClassesnNamespaces = externalClassesnNamespaces;
     _externalEnumsnNamespaces = externalEnumsnNamespaces;
     _externalEnumsToGenerateMap = externalEnumsToGenerateMap;
 }
        /**
         * Construct the generation object.
         *
         * @param theTargetLanguage
         *            The target language.
         */
        public EncogCodeGeneration(TargetLanguage theTargetLanguage)
        {
            targetLanguage = theTargetLanguage;

            switch (theTargetLanguage)
            {
                case TargetLanguage.NoGeneration:
                    throw new AnalystCodeGenerationError(
                        "No target language has been specified for code generation.");
                case TargetLanguage.Java:
                    generator = new GenerateEncogJava();
                    break;
                case TargetLanguage.CSharp:
                    generator = new GenerateCS();
                    break;
                case TargetLanguage.MQL4:
                    generator = new GenerateMQL4();
                    break;
                case TargetLanguage.NinjaScript:
                    generator = new GenerateNinjaScript();
                    break;
                case TargetLanguage.JavaScript:
                    generator = new GenerateEncogJavaScript();
                    break;
            }
        }
        public void ConstructorTest()
        {
            Int32 quoteID = 25;
            SourceLanguage sourceLanguage = new SourceLanguage("en-gb");
            TargetLanguage[] targetLanguage = new TargetLanguage[2] { new TargetLanguage("en-us"),
                                                                      new TargetLanguage("it-it")};
            Int32 totalTranslations = 14;
            Int32 translationCredit = 4;
            String currency = "USD";
            Decimal totalCost = 100.54m;
            Decimal prepaidCredit = 30.4m;
            Decimal amountDue = 1.4m;
            DateTime creationDate = DateTime.Now;

            var projects = new List<Project>();

            var quote = new Quote(quoteID: quoteID,
                                 creationDate: creationDate,
                                 totalTranslations: totalTranslations,
                                 translationCredit: translationCredit,
                                 currency: currency,
                                 totalCost: totalCost,
                                 prepaidCredit: prepaidCredit,
                                 amountDue: amountDue,
                                 projects: projects);

            Assert.AreEqual(quote.QuoteID, quoteID);
            Assert.AreEqual(quote.TotalTranslations, totalTranslations);
            Assert.AreEqual(quote.TranslationCredit, translationCredit);
            Assert.AreEqual(quote.Currency, currency);
            Assert.AreEqual(quote.TotalCost, totalCost);
            Assert.AreEqual(quote.PrepaidCredit, prepaidCredit);
            Assert.AreEqual(quote.AmountDue, amountDue);
        }
        public static CompileResult Compile(string typeSql, string typeSqlFileName, TargetLanguage targetLanguage = TargetLanguage.CSharp)
        {
            //create the antlr-based lexer and parser
            var lexer = new TypeSqlLexer(new ANTLRStringStream(typeSql));
             var rewriteTokenStream = new TokenRewriteStream(lexer);
            var parser = new TypeSqlParser(rewriteTokenStream);

            //parse the typeSql, producing the AST
            var ast = (CommonTree) parser.typesql().Tree;
             var nodeStream = new CommonTreeNodeStream(ast);

            //transform the AST into raw-sql
             var rawSqlOutput = new RawSqlTransform(nodeStream);
             nodeStream.TokenStream = rewriteTokenStream;
             rawSqlOutput.typeSql();
             string rawSql = rewriteTokenStream.ToString();

            //reset
             lexer.Reset();
             rewriteTokenStream.Reset();
             nodeStream.Reset();
            //and transform the AST into DAO source code
             var daoTransform = new DaoTransform(nodeStream){TemplateGroup = new StringTemplateGroup(
                new StreamReader(typeof(TypeSqlCompiler).Assembly.GetManifestResourceStream(string.Format("TypeSql.Parsing.DapperDao.{0}.stg", targetLanguage.ToString() ))),
                typeof (TemplateLexer))};
             var template = daoTransform.typeSql(typeSqlFileName, rawSql).Template;
             string daoSourceCode = template.ToString();

            return new CompileResult(daoSourceCode, rawSql);
        }
        public override bool Execute()
        {
            try
            {
                _resourcesName = "FxResources." + AssemblyName;

                using (_targetStream = File.CreateText(OutputSourceFilePath))
                {
                    if (String.Equals(Path.GetExtension(OutputSourceFilePath), ".vb", StringComparison.OrdinalIgnoreCase))
                    {
                        _targetLanguage = TargetLanguage.VB;
                    }
                    _keys = new Dictionary<string, int>();
                    WriteClassHeader();
					RunOnResFile();
					WriteDebugCode();
					WriteGetTypeProperty();
					WriteClassEnd();
					WriteResourceTypeClass();
                }
            }
            catch (Exception e)
            {
                Log.LogError("Failed to generate the resource code with error:\n" + e.Message);
                return false; // fail the task
            }

            return true;
        }
Beispiel #8
0
        public static void TranslateControls(Control control, string ressourceFile, TargetLanguage language, bool fullRecusive)
        {
            string ressourceContent = ReadString(ressourceFile);
            string[] splitArray = ressourceContent.Split(new string[] { "[End]" }, StringSplitOptions.RemoveEmptyEntries);
            Dictionary<string, string> translateTable = GetTranslateRessources(splitArray, language);

            string caption = "";
            if (translateTable.TryGetValue("this", out caption))
            {

                if (caption.IndexOf("{0}") > -1)
                {
                    string replaceValue = control.Tag as string;
                    if (!string.IsNullOrEmpty(replaceValue))
                        caption = caption.Replace("{0}", replaceValue);
                }
                
                control.Text = caption;
            }

            foreach (Control item in control.Controls)
            {
                string message = "";
                if (translateTable.TryGetValue(item.Name, out message))
                {
                    if (item is ComboBox)
                    {
                        ComboBox comboItem = item as ComboBox;
                        comboItem.Items.Clear();
                        string[] itemArray = message.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (string itemEntry in itemArray)
                            comboItem.Items.Add(itemEntry);
                    }
                    else
                    {
                        if (message.IndexOf("{0}") > -1)
                        {
                            string[] replaceValues = item.Tag as string[];
                            if (null != replaceValues)
                            { 
                                for (int i = 0; i < replaceValues.Length; i++)
                                {
                                    string replValue = replaceValues[i];
                                    message = message.Replace("{" + i.ToString() + "}", replValue);
                                }
                            }
                        } 
                        item.Text = message;
                    }
                }

                if (fullRecusive)
                    ForEachSubControls(item, translateTable);
            }
        }
        public string CreateFileName(string outputFile, string destinationFolder, out string outputFileOriginal, TargetLanguage targetLanguage, string xsd_Id)
        {
            if (targetLanguage == TargetLanguage.CSharp)
                outputFile = destinationFolder + "\\" + xsd_Id + ".cs";
            else if (targetLanguage == TargetLanguage.JAVA)
                outputFile = destinationFolder + "\\" + xsd_Id + ".java";
            else
                outputFile = destinationFolder + "\\" + xsd_Id + ".h";

            outputFileOriginal = outputFile;
            outputFile = outputFile + ".tmp";

            return outputFile;
        }
Beispiel #10
0
        public ErrorDialog(Exception exception, TargetLanguage language)
        {
            InitializeComponent();
            Translator.TranslateControls(this, "Dialogs.ErrorDialog.txt", language);

            string errorLog = "";
            while (null != exception)
            {
                errorLog += exception.Message + Environment.NewLine;
                exception = exception.InnerException;
            }

            textBoxErrorLog.Text = errorLog;

        }
Beispiel #11
0
        /*
                private static int CompareResData(ResData x, ResData y)
                {
                    if (x.Hash == y.Hash) { return 0;  }
                    if (x.Hash > y.Hash) {return 1;  }
                    return -1;
                }

                void WriteValues()
                {
                    _list.Sort(CompareResData);
                    foreach (ResData d in _list)
                    {
                        _targetStream.WriteLine("            new ResData {0} Hash = {1}, Key = \"{2}\", Value = \"{3}\" {4}, ", "{", d.Hash, d.Key, d.Value, "}");
                    }
                }
        */
        ResGen(string firstSourceFile, string secondSourceFile, string targetFile, string assemblyName)
        {
            if (firstSourceFile != null)
                _firstSourceStream = File.OpenText(firstSourceFile);

            if (secondSourceFile != null)
                _secondSourceStream = File.OpenText(secondSourceFile);

            _targetStream = File.CreateText(targetFile);
            if (String.Equals(Path.GetExtension(targetFile), ".vb", StringComparison.OrdinalIgnoreCase))
            {
                _targetLanguage = TargetLanguage.VB;
            }

            _assemblyName = assemblyName;

            _currentLine = 0;
            _keys = new Dictionary<string, int>();
            //            _list = new List<ResData>();
        }
        public bool Execute()
        {
            try
            {
                string java;
                if (!string.IsNullOrEmpty(JavaExecutable))
                {
                    java = JavaExecutable;
                }
                else
                {
                    string javaHome = JavaHome;
                    java = Path.Combine(Path.Combine(javaHome, "bin"), "java.exe");
                }

                List <string> arguments = new List <string>();
                arguments.Add("-cp");
                arguments.Add(ToolPath);
                arguments.Add("org.antlr.v4.CSharpTool");

                arguments.Add("-o");
                arguments.Add(OutputPath);

                if (GenerateListener)
                {
                    arguments.Add("-listener");
                }
                else
                {
                    arguments.Add("-no-listener");
                }

                if (GenerateVisitor)
                {
                    arguments.Add("-visitor");
                }
                else
                {
                    arguments.Add("-no-visitor");
                }

                if (ForceAtn)
                {
                    arguments.Add("-force-atn");
                }

                if (AbstractGrammar)
                {
                    arguments.Add("-Dabstract=true");
                }

                if (!string.IsNullOrEmpty(TargetLanguage))
                {
                    string framework = TargetFrameworkVersion;
                    if (string.IsNullOrEmpty(framework))
                    {
                        framework = "v2.0";
                    }
                    if (framework.StartsWith("v4.5."))
                    {
                        framework = "v4.5";
                    }

                    string language;
                    if (TargetLanguage.Equals("CSharp", StringComparison.OrdinalIgnoreCase))
                    {
                        language = TargetLanguage + '_' + framework.Replace('.', '_');
                    }
                    else
                    {
                        language = TargetLanguage;
                    }

                    arguments.Add("-Dlanguage=" + language);
                }

                if (!string.IsNullOrEmpty(TargetNamespace))
                {
                    arguments.Add("-package");
                    arguments.Add(TargetNamespace);
                }

                arguments.AddRange(SourceCodeFiles);

                ProcessStartInfo startInfo = new ProcessStartInfo(java, JoinArguments(arguments))
                {
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                };

                this.BuildMessages.Add(new BuildMessage(TraceLevel.Info, "Executing command: \"" + startInfo.FileName + "\" " + startInfo.Arguments, "", 0, 0));

                Process process = new Process();
                process.StartInfo           = startInfo;
                process.ErrorDataReceived  += HandleErrorDataReceived;
                process.OutputDataReceived += HandleOutputDataReceived;
                process.Start();
                process.BeginErrorReadLine();
                process.BeginOutputReadLine();
                process.StandardInput.Close();
                process.WaitForExit();

                return(process.ExitCode == 0);
                //using (LoggingTraceListener traceListener = new LoggingTraceListener(_buildMessages))
                //{
                //    SetTraceListener(traceListener);
                //    ProcessArgs(args.ToArray());
                //    process();
                //}

                //_generatedCodeFiles.AddRange(GetGeneratedFiles().Where(file => LanguageSourceExtensions.Contains(Path.GetExtension(file), StringComparer.OrdinalIgnoreCase)));

                //int errorCount = GetNumErrors();
                //return errorCount == 0;
            }
            catch (Exception e)
            {
                if (e is TargetInvocationException && e.InnerException != null)
                {
                    e = e.InnerException;
                }

                _buildMessages.Add(new BuildMessage(e.Message));
                throw;
            }
        }
Beispiel #13
0
        public VsProject(TargetLanguage targetLanguage, string fileName, string projName, string sourcePath, string defaultNamespace, string dialect)
        {
            this.fileName         = fileName;
            this.projName         = projName;
            this.sourcePath       = sourcePath;
            this.defaultNamespace = defaultNamespace;

            XmlDocument doc;

            doc = new XmlDocument();
            if (targetLanguage == TargetLanguage.VB)
            {
                doc.LoadXml(VsProject.vbtemplate);
            }
            else
            {
                doc.LoadXml(VsProject.cstemplate);
            }
            this.dialect = dialect;

            string existingGuid = null;
            string toolsVersion = null;

            existingGuid = AnalyzeExistingProjectFile(fileName, out toolsVersion);

            this.project = new Project(doc.DocumentElement);
            PropertyGroup mainPropertyGroup = this.project.MainPropertyGroup;

            if (existingGuid != null)
            {
                mainPropertyGroup["ProjectGuid"] = existingGuid;
            }
            else
            {
                mainPropertyGroup["ProjectGuid"] = "{" + Guid.NewGuid().ToString() + "}";
            }

            mainPropertyGroup["AssemblyName"]  = projName;
            mainPropertyGroup["RootNamespace"] = defaultNamespace;

            foreach (ItemGroup ig in project.ItemGroups)
            {
                foreach (Reference reference in ig.References)
                {
                    if (reference.Include == "NDO")                        // This is a marker
                    {
                        reference.Include = typeof(NDO.PersistenceManager).Assembly.FullName;
#warning We must define the hint path relative to the solution .\packages\ndo.dll.v.0.0\lib\net4.x\NDO.dll
                        //reference.HintPath = NDO.NDOApplicationPath.Instance + @"\NDO.dll";
                        break;
                    }
                }
            }

            this.compileItemGroup = project.NewItemGroup();

#if UseXml
            XmlNode pnode = doc.SelectSingleNode("/Project");
            ((XmlElement)pnode).SetAttribute("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
            pnode = doc.SelectSingleNode("/Project/PropertyGroup/ProjectGuid");
            if (existingGuid != null)
            {
                pnode.InnerText = existingGuid;
            }
            else
            {
                pnode.InnerText = "{" + Guid.NewGuid().ToString() + "}";
            }
            pnode           = doc.SelectSingleNode("/Project/PropertyGroup/AssemblyName");
            pnode.InnerText = projName;
            pnode           = doc.SelectSingleNode("/Project/PropertyGroup/RootNamespace");
            pnode.InnerText = defaultNamespace;
            pnode           = doc.SelectSingleNode("/Project/ItemGroup/Reference[@Include='NDO']");
            ((XmlElement)pnode).SetAttribute("Include", typeof(NDO.PersistenceManager).Assembly.FullName);
            //pnode = pnode.SelectSingleNode("HintPath");
            //pnode.InnerText = NDO.NDOApplicationPath.Instance + @"\NDO.dll";

            pnode                 = doc.SelectSingleNode("/Project/ItemGroup/Compile[@Include='###Marker###']");
            this.filesElement     = (XmlElement)pnode.ParentNode;
            filesElement.InnerXml = string.Empty;
#endif
        }
Beispiel #14
0
 public GeneratorAttribute(TargetLanguage language, double order = 0)
 {
     Language = language;
     Order    = order;
 }
Beispiel #15
0
        internal void CopyFilesForWebsite(string websiteRoot, string configurationFile, Role role, TargetLanguage language)
        {
            if (!File.Exists(configurationFile))
            {
                Console.WriteLine("Could not find configuration file " + configurationFile);
            }
            // Find corresponding webapp
            // Get Database driver

            string theRole     = null;
            string theLanguage = null;

            switch (role)
            {
            case Role.PreviewWebService:
                theRole = "preview-webservice";
                break;

            case Role.PreviewWeb:
                theRole = "preview-web";
                break;

            case Role.Upload:
                theRole = "upload";
                break;

            case Role.WebService:
                theRole = "webservice";
                break;
            }
            switch (language)
            {
            case TargetLanguage.Aspnet:
                theLanguage = "Aspnet";
                break;

            case TargetLanguage.Jsp:
                theLanguage = "Jsp";
                break;
            }

            XDocument config = XDocument.Load(configurationFile);
            string    jdbc   = config.Root.Element("Folder").Attribute("source").Value;

            jdbc += Path.DirectorySeparatorChar + config.Root.Element("Folder").Element("File").Value;

            string version = string.Empty;

            if (Configuration.ServerVersion == ServerVersion.Version7)
            {
                version = "7.0.0";
            }
            else if (Configuration.ServerVersion == ServerVersion.Version6)
            {
                version = "6.1.0";
            }
            else
            {
                Console.WriteLine("Unknown server version.");
                return;
            }


            XElement webapps = null;

            foreach (XElement node in config.Root.Elements("Webapps"))
            {
                if (node.Attribute("Version").Value.Equals(version))
                {
                    webapps = node;
                }
            }

            if (webapps == null)
            {
                Console.WriteLine("Could not find any webapp configured for version " + version);
                return;
            }

            string webapp = null;

            foreach (XElement node in webapps.Nodes())
            {
                if (node.Attribute("role").Value.Equals(theRole) && node.Attribute("language").Value.Equals(theLanguage))
                {
                    webapp = node.Element("File").Value;
                    break;
                }
            }
            if (webapp == null)
            {
                Console.WriteLine("Could not find webapp for role " + theRole + " and language " + theLanguage);
                return;
            }
            FastZip zip = new FastZip();

            zip.ExtractZip(webapp, websiteRoot, FastZip.Overwrite.Never, null, null, null, false);

            // TODO: Copy/Modify Configuration files for role
            string configFolder = null;
            string libFolder    = null;

            if (language == TargetLanguage.Aspnet)
            {
                configFolder = websiteRoot + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar +
                               "config";
                libFolder = websiteRoot + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar + "lib";
            }
            else
            {
                configFolder = websiteRoot + Path.DirectorySeparatorChar + "WEB-INF" + Path.DirectorySeparatorChar +
                               "classes";
                libFolder = websiteRoot + Path.DirectorySeparatorChar + "WEB-INF" + Path.DirectorySeparatorChar + "lib";
            }
            if (!Directory.Exists(configFolder))
            {
                Directory.CreateDirectory(configFolder);
            }

            if (!File.Exists(libFolder + Path.DirectorySeparatorChar + Path.GetFileName(jdbc)))
            {
                File.Copy(jdbc, libFolder + Path.DirectorySeparatorChar + Path.GetFileName(jdbc));
            }


            // Set permissions if web site
            if (role == Role.PreviewWeb)
            {
                DirectoryInfo     info     = new DirectoryInfo(websiteRoot);
                DirectorySecurity security = info.GetAccessControl();
                security.AddAccessRule(new FileSystemAccessRule("Network Service", FileSystemRights.Write | FileSystemRights.Read | FileSystemRights.ListDirectory | FileSystemRights.ReadAndExecute | FileSystemRights.Modify | FileSystemRights.CreateFiles | FileSystemRights.CreateDirectories | FileSystemRights.WriteAttributes | FileSystemRights.Delete | FileSystemRights.DeleteSubdirectoriesAndFiles, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow));
                info.SetAccessControl(security);
            }
        }
 /// <summary>
 /// Defines the language
 /// </summary>
 /// <param name="targetLanguage">The language.</param>
 /// <returns>The LanguageSpecificTypeDefinition</returns>
 public LanguageSpecificTypeDefinition InLanguage(TargetLanguage targetLanguage)
 {
     this.TargetLanguage = targetLanguage;
     return(this);
 }
Beispiel #17
0
 public TranslationOptions(TargetLanguage targetLanguage, TargetApi targetApi, TranslationFlags flags)
 {
     TargetLanguage = targetLanguage;
     TargetApi      = targetApi;
     Flags          = flags;
 }
        /// <summary>
        /// Update an existing file object from XML
        /// </summary>
        /// <param name="element"></param>
        internal void UpdateFromXElement(XElement element)
        {
            if (element != null)
            {
                this.AssetID = element.GetChildValueAsInt32("AssetID");

                String fileStatus = element.GetChildValue("Status");

                if (!String.IsNullOrEmpty(fileStatus) && Enum.IsDefined(typeof(FileStatus), fileStatus.Replace(" ", "")))
                {
                    this.Status = (FileStatus)(Enum.Parse(typeof(FileStatus), fileStatus.Replace(" ", "")));
                }

                this.URL = element.GetChildValueAsUri("URL");

                this.ProjectID = element.GetChildValueAsInt32("ProjectID");

                this.Name = element.GetChildValue("Name");
                this.Name = String.IsNullOrEmpty(this.Name) ? element.GetChildValue("FileName") : this.Name;

                this.UploadDate = element.GetChildValueAsDateTime("UploadDate");

                this.SourceLanguage = new SourceLanguage(element.Element("SourceLanguage"));

                XElement targetLanguagesElement = element.Element("TargetLanguages");
                if (targetLanguagesElement != null)
                {
                    List<TargetLanguage> targetLanguages = new List<TargetLanguage>();

                    foreach (XElement targetLanguageElement in targetLanguagesElement.Elements("TargetLanguage"))
                    {
                        TargetLanguage targetLanguage = new TargetLanguage(targetLanguageElement);
                        targetLanguages.Add(targetLanguage);
                    }

                    this.TargetLanguages = targetLanguages.ToArray<TargetLanguage>();
                }

            }
        }
Beispiel #19
0
 set => Set(TargetLanguage, value);
 public CodeCheckForNullExpression(string variableName, TargetLanguage targetLanguage)
 {
     SetValue(variableName, targetLanguage);
 }
Beispiel #21
0
        private static Dictionary<string, string> GetTranslateRessources(string[] splitArray, TargetLanguage language)
        {
            Dictionary<string, string> resultDictionary = new Dictionary<string, string>();

            foreach (string item in splitArray)
            {
                string[] lines = item.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string line in lines)
                {
                    if ("[" + language.ToString() + "]" == line.Trim())
                    {
                        AddToDictionary(resultDictionary, lines);
                        return resultDictionary;
                    }
                }
            }

            throw new IndexOutOfRangeException(language.ToString() + " not found.");
        }
Beispiel #22
0
 public static void TranslateControls(Control control, string ressourceFile, TargetLanguage language)
 {
     TranslateControls(control, ressourceFile, language, true);
 }
Beispiel #23
0
            protected override void OnValueChanged(CQRSdslDiagram element, TargetLanguage oldValue, TargetLanguage newValue)
            {
                base.OnValueChanged(element, oldValue, newValue);

                // Pass on the change to the CQRS model
            }
Beispiel #24
0
 static int GetOrder(TargetLanguage language) => (int)language;
Beispiel #25
0
        public static void PerformModelGenerate(TargetLanguage targetLanguage, TargetDatabaseConnector targetDatabaseConnector, string connectionString, string directory, string @namespace)
        {
            IModelGenerator generator = default;

            switch (targetLanguage)
            {
            case TargetLanguage.CSharp:
                switch (targetDatabaseConnector)
                {
                case TargetDatabaseConnector.SQLServer:
                    generator = new CSharpGenerator <SqlConnection, SqlParameter>(connectionString, directory, @namespace, x => $"[{x}]");
                    break;

                case TargetDatabaseConnector.Oracle:
                    generator = new CSharpGenerator <OracleConnection, OracleParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.MySQL:
                    generator = new CSharpGenerator <MySqlConnection, MySqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.PostgreSQL:
                    generator = new CSharpGenerator <NpgsqlConnection, NpgsqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.SQLite:
                    generator = new CSharpGenerator <SQLiteConnection, SQLiteParameter>(connectionString, directory, @namespace);
                    break;
                }
                break;

            case TargetLanguage.VisualBasic:
                switch (targetDatabaseConnector)
                {
                case TargetDatabaseConnector.SQLServer:
                    generator = new VisualBasicGenerator <SqlConnection, SqlParameter>(connectionString, directory, @namespace, x => $"[{x}]");
                    break;

                case TargetDatabaseConnector.Oracle:
                    generator = new VisualBasicGenerator <OracleConnection, OracleParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.MySQL:
                    generator = new VisualBasicGenerator <MySqlConnection, MySqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.PostgreSQL:
                    generator = new VisualBasicGenerator <NpgsqlConnection, NpgsqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.SQLite:
                    generator = new VisualBasicGenerator <SQLiteConnection, SQLiteParameter>(connectionString, directory, @namespace);
                    break;
                }
                break;

            case TargetLanguage.TypeScript:
                switch (targetDatabaseConnector)
                {
                case TargetDatabaseConnector.SQLServer:
                    generator = new TypeScriptGenerator <SqlConnection, SqlParameter>(connectionString, directory, @namespace, x => $"[{x}]");
                    break;

                case TargetDatabaseConnector.Oracle:
                    generator = new TypeScriptGenerator <OracleConnection, OracleParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.MySQL:
                    generator = new TypeScriptGenerator <MySqlConnection, MySqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.PostgreSQL:
                    generator = new TypeScriptGenerator <NpgsqlConnection, NpgsqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.SQLite:
                    generator = new TypeScriptGenerator <SQLiteConnection, SQLiteParameter>(connectionString, directory, @namespace);
                    break;
                }
                break;

            case TargetLanguage.PHP:
                switch (targetDatabaseConnector)
                {
                case TargetDatabaseConnector.SQLServer:
                    generator = new PHPGenerator <SqlConnection, SqlParameter>(connectionString, directory, @namespace, x => $"[{x}]");
                    break;

                case TargetDatabaseConnector.Oracle:
                    generator = new PHPGenerator <OracleConnection, OracleParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.MySQL:
                    generator = new PHPGenerator <MySqlConnection, MySqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.PostgreSQL:
                    generator = new PHPGenerator <NpgsqlConnection, NpgsqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.SQLite:
                    generator = new PHPGenerator <SQLiteConnection, SQLiteParameter>(connectionString, directory, @namespace);
                    break;
                }
                break;

            case TargetLanguage.Python:
                switch (targetDatabaseConnector)
                {
                case TargetDatabaseConnector.SQLServer:
                    generator = new PythonGenerator <SqlConnection, SqlParameter>(connectionString, directory, @namespace, x => $"[{x}]");
                    break;

                case TargetDatabaseConnector.Oracle:
                    generator = new PythonGenerator <OracleConnection, OracleParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.MySQL:
                    generator = new PythonGenerator <MySqlConnection, MySqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.PostgreSQL:
                    generator = new PythonGenerator <NpgsqlConnection, NpgsqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.SQLite:
                    generator = new PythonGenerator <SQLiteConnection, SQLiteParameter>(connectionString, directory, @namespace);
                    break;
                }
                break;

            case TargetLanguage.Python37:
                switch (targetDatabaseConnector)
                {
                case TargetDatabaseConnector.SQLServer:
                    generator = new Python37Generator <SqlConnection, SqlParameter>(connectionString, directory, @namespace, x => $"[{x}]");
                    break;

                case TargetDatabaseConnector.Oracle:
                    generator = new Python37Generator <OracleConnection, OracleParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.MySQL:
                    generator = new Python37Generator <MySqlConnection, MySqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.PostgreSQL:
                    generator = new Python37Generator <NpgsqlConnection, NpgsqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.SQLite:
                    generator = new Python37Generator <SQLiteConnection, SQLiteParameter>(connectionString, directory, @namespace);
                    break;
                }
                break;

            case TargetLanguage.Java:
                switch (targetDatabaseConnector)
                {
                case TargetDatabaseConnector.SQLServer:
                    generator = new JavaGenerator <SqlConnection, SqlParameter>(connectionString, directory, @namespace, x => $"[{x}]");
                    break;

                case TargetDatabaseConnector.Oracle:
                    generator = new JavaGenerator <OracleConnection, OracleParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.MySQL:
                    generator = new JavaGenerator <MySqlConnection, MySqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.PostgreSQL:
                    generator = new JavaGenerator <NpgsqlConnection, NpgsqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.SQLite:
                    generator = new JavaGenerator <SQLiteConnection, SQLiteParameter>(connectionString, directory, @namespace);
                    break;
                }
                break;

            case TargetLanguage.CPP:
                switch (targetDatabaseConnector)
                {
                case TargetDatabaseConnector.SQLServer:
                    generator = new CPPGenerator <SqlConnection, SqlParameter>(connectionString, directory, @namespace, x => $"[{x}]");
                    break;

                case TargetDatabaseConnector.Oracle:
                    generator = new CPPGenerator <OracleConnection, OracleParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.MySQL:
                    generator = new CPPGenerator <MySqlConnection, MySqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.PostgreSQL:
                    generator = new CPPGenerator <NpgsqlConnection, NpgsqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.SQLite:
                    generator = new CPPGenerator <SQLiteConnection, SQLiteParameter>(connectionString, directory, @namespace);
                    break;
                }
                break;

            case TargetLanguage.Golang:
                switch (targetDatabaseConnector)
                {
                case TargetDatabaseConnector.SQLServer:
                    generator = new GolangGenerator <SqlConnection, SqlParameter>(connectionString, directory, @namespace, x => $"[{x}]");
                    break;

                case TargetDatabaseConnector.Oracle:
                    generator = new GolangGenerator <OracleConnection, OracleParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.MySQL:
                    generator = new GolangGenerator <MySqlConnection, MySqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.PostgreSQL:
                    generator = new GolangGenerator <NpgsqlConnection, NpgsqlParameter>(connectionString, directory, @namespace);
                    break;

                case TargetDatabaseConnector.SQLite:
                    generator = new GolangGenerator <SQLiteConnection, SQLiteParameter>(connectionString, directory, @namespace);
                    break;
                }
                break;
            }
            generator.Generate();
        }
Beispiel #26
0
 public static Boolean IsCaseSensitive(this TargetLanguage targetLanguage)
 {
     return(targetLanguage.IsCSharp() || targetLanguage.IsFSharp());
 }
Beispiel #27
0
 /// <summary>
 ///     Set a property as a target language.
 /// </summary>
 /// <param name="name">The name of the property.</param>
 /// <param name="targetLanguage">The target language.</param>
 public void SetProperty(String name, TargetLanguage targetLanguage)
 {
     _data[name] = targetLanguage.ToString().ToUpper();
 }
Beispiel #28
0
        internal void CreateConfigFiles(string rootFolder, string role, string name, XElement site, TargetLanguage language)
        {
            string configPath = string.Empty;

            if (language == TargetLanguage.Aspnet)
            {
                configPath = rootFolder + "\\bin\\config";
            }
            else
            {
                configPath = rootFolder + "\\WEB-INF\\classes";
            }

            // Write Logback
            WriteLogBack(configPath + Path.DirectorySeparatorChar + "logback.xml", name);

            List <string> filesToCopy = new List <string>();

            if (Directory.Exists("ConfigSamples\\" + role))
            {
                filesToCopy.AddRange(Directory.GetFiles("ConfigSamples\\" + role));
            }

            foreach (string file in filesToCopy)
            {
                string filename = Path.GetFileName(file);
                WriteConfigFile(file, configPath + Path.DirectorySeparatorChar + filename, name, site);
            }

            /*
             * switch (role)
             * {
             *  case "upload":
             *      WriteConfigFile("ConfigSamples\\cd_deployer_conf.xml", configPath + Path.DirectorySeparatorChar + "cd_deployer_conf.xml", name);
             *      WriteConfigFile("ConfigSamples\\cd_storage_conf-deployer.xml", configPath + Path.DirectorySeparatorChar + "cd_storage_conf.xml", null, storage);
             *      break;
             *  case "preview":
             *      WriteConfigFile("ConfigSamples\\cd_storage_conf-preview.xml", configPath + Path.DirectorySeparatorChar + "cd_storage_conf.xml", null, storage);
             *      WriteConfigFile("ConfigSamples\\cd_ambient_conf-preview.xml", configPath + Path.DirectorySeparatorChar + "cd_ambient_conf.xml");
             *      WriteConfigFile("ConfigSamples\\cd_dynamic_conf-preview.xml", configPath + Path.DirectorySeparatorChar + "cd_dynamic_conf.xml");
             *      WriteConfigFile("ConfigSamples\\cd_link_conf.xml", configPath + Path.DirectorySeparatorChar + "cd_link_conf.xml");
             *      WriteConfigFile("ConfigSamples\\cd_wai_conf.xml", configPath + Path.DirectorySeparatorChar + "cd_wai_conf.xml");
             *      break;
             * }*/
        }
Beispiel #29
0
 public Assembly(string projectName, string rootNamespace, string targetDir, bool useClassField, bool mapStringsAsGuids, TargetLanguage targetLanguage)
 {
     this.projectName       = projectName;
     this.rootNamespace     = rootNamespace;
     this.targetDir         = targetDir;
     this.mapStringsAsGuids = mapStringsAsGuids;
     this.useClassField     = useClassField;
     this.targetLanguage    = targetLanguage;
 }
 public CodeCheckForNullExpression(CodeVariableReferenceExpression variableReference, TargetLanguage targetLanguage)
 {
     SetValue(variableReference.VariableName, targetLanguage);
 }
 /// <summary>
 ///     Get the extension fot the specified language.
 /// </summary>
 /// <param name="lang">The specified language.</param>
 /// <returns></returns>
 public static string GetExtension(TargetLanguage lang)
 {
     if (lang == TargetLanguage.Java)
     {
         return "java";
     }
     else if (lang == TargetLanguage.JavaScript)
     {
         return "html";
     }
     else if (lang == TargetLanguage.CSharp)
     {
         return "cs";
     }
     else if (lang == TargetLanguage.MQL4)
     {
         return "mql4";
     }
     else if (lang == TargetLanguage.NinjaScript)
     {
         return "cs";
     }
     else
     {
         return "txt";
     }
 }
Beispiel #32
0
 public static Boolean IsFSharp(this TargetLanguage targetLanguage)
 {
     return((targetLanguage >= TargetLanguage.FSharp_2_0) && (targetLanguage <= TargetLanguage.FSharp_Latest));
 }
Beispiel #33
0
 public override int GetHashCode() => DefaultName.GetHashCode() ^ Version.GetHashCode() ^ Author.GetHashCode()
 ^ TargetLanguage.GetHashCode() ^ SupportedLanguages.GetHashCode() ^ BaseLanguage.GetHashCode()
 ^ (Id.GetHashCode() * 7);
Beispiel #34
0
 public static Boolean IsVisualBasic(this TargetLanguage targetLanguage)
 {
     return((targetLanguage >= TargetLanguage.VisualBasic_7_0) && (targetLanguage <= TargetLanguage.VisualBasic_Latest));
 }
 /// <summary>
 ///     Set a property as a target language.
 /// </summary>
 /// <param name="name">The name of the property.</param>
 /// <param name="targetLanguage">The target language.</param>
 public void SetProperty(String name, TargetLanguage targetLanguage)
 {
     _data[name] = targetLanguage.ToString().ToUpper();
 }
 private static bool GetMetadataAsBoolean(ITaskItem taskItem, TargetLanguage prefix, string metadataName)
 => bool.TryParse(GetMetadata(taskItem, prefix, metadataName), out var value)
     ? value
     : default(bool);