Example #1
0
        private PatternMatchRuleProcessor(System.Collections.ObjectModel.ReadOnlyCollection <PatternMatchRule> rules)
        {
            Debug.Assert(rules.Count() != 0, "At least one PatternMatchRule is required");
            Debug.Assert(rules.Where(r => r == null).Count() == 0, "Individual PatternMatchRules must not be null");

            this.ruleSet = rules;
        }
Example #2
0
 public static IEnumerable <string> GetVoices()
 {
     using (SpeechSynthesizer synthesizer = new SpeechSynthesizer())
     {
         System.Collections.ObjectModel.ReadOnlyCollection <InstalledVoice> installedVoices = synthesizer.GetInstalledVoices();
         IEnumerable <InstalledVoice> voices = installedVoices.Where(voice => voice.Enabled);
         return(voices.Select(voice => voice.VoiceInfo.Name));
     }
 }
Example #3
0
        public void DownloadS3()
        {
            try
            {
                setts = ser.Deserialize <Settings>((string)File.ReadAllText(@"Settings.xml"));
                if (nextRefreshS3 > DateTime.Parse(FimS3.Text))
                {
                    nextRefreshS3 = DateTime.Parse(InicioS3.Text);
                }
                else
                {
                    nextRefreshS3 = DateTime.Now.AddMinutes(Int32.Parse(intervaloS3.Text));
                }
                foreach (Settings.Clientes url in setts.ClientesList.Where(x => x.Active == "true"))
                {
                    try { S3.FindElement(By.Id("RandstadTheme_wt101_block_wtHeader_wt99_wt4_wtLogoutLink")).Click(); } catch {
                        //string uploadURL = "https://i.randstad.pt/PortalS3/UploadWizard.aspx?CloudClientId=4";
                        //S3.Navigate().GoToUrl(uploadURL);

                        //foreach (Settings.UploadFile item in setts.UploadFiles)
                        //{
                        //    string tempFile = item.Documento;
                        //    if (tempFile.Contains("{Now}")) tempFile = tempFile.Replace("{Now}", DateTime.Now.AddDays(-1).ToString("dd-MM-yyyy"));
                        //    S3.FindElement(By.CssSelector("#WebPatterns_wt3_block_wtMainContent_wt2_wtfiles input[type=file]")).SendKeys(tempFile);
                        // }
                    }
                    try { Thread.Sleep(1000); S3.Navigate().GoToUrl(DownSetts.Read("S3")); LoginS3(S3); } catch (Exception ex) { WriteLogFile.WriteLog("Log.txt", String.Format("[{0}]:{1}->Function:DownloadS3", DateTime.Now, ex.Message)); }
                    Thread.Sleep(1000);
                    S3.FindElement(By.Id("RandstadTheme_wt101_block_wtMainContent_WebPatterns_wt42_block_wtColumn1_wtStartDate")).Clear(); S3.FindElement(By.Id("RandstadTheme_wt101_block_wtMainContent_WebPatterns_wt42_block_wtColumn1_wtEndDate")).Clear();
                    S3.FindElement(By.Id("RandstadTheme_wt101_block_wtMainContent_WebPatterns_wt42_block_wtColumn1_wtStartDate")).SendKeys(DateTime.Now.Date.ToString("yyyy-MM-dd")); S3.FindElement(By.Id("RandstadTheme_wt101_block_wtMainContent_WebPatterns_wt42_block_wtColumn1_wtEndDate")).SendKeys(DateTime.Now.Date.ToString("yyyy-MM-dd"));
                    S3.FindElement(By.Id("RandstadTheme_wt101_block_wtMainContent_wt68")).Click(); //botao Filtrar

                    Thread.Sleep(1000);
                    System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> options = S3.FindElements(By.CssSelector(".select2-results-dept-0.select2-result.select2-result-selectable"));
                    IWebElement item2 = options.Where(x => x.Text == url.Cliente).FirstOrDefault();
                    item2.Click();
                    Thread.Sleep(1000);
                    System.Collections.ObjectModel.ReadOnlyCollection <IWebElement> linhas = S3.FindElements(By.CssSelector("table.TableRecords.OSFillParent.OSAutoMarginTop tbody tr "));
                    foreach (IWebElement d in linhas)
                    {
                        IWebElement file = d.FindElement(By.CssSelector("td:nth-of-type(2)"));
                        if (File.Exists(pathDownloadS3.Text + "\\" + file.Text))
                        {
                            continue;
                        }
                        d.FindElement(By.CssSelector("td div:not(.OSAutoMarginTop) a")).Click();
                        Thread.Sleep(1000);
                    }
                    Thread.Sleep(1000);
                }
            }catch (Exception ex) { WriteLogFile.WriteLog("LogS3.txt", String.Format("[{0}]:{1}->Function:DownloadS3", DateTime.Now, ex.Message)); }
            ctrlS3 = true;
            S3.Navigate().GoToUrl(DownSetts.Read("S3"));
            delaytimeS3 = DateTime.Now.AddSeconds(30);
            // lastRunS3LB.Text = DateTime.Now.ToString();
        }
Example #4
0
        IArchivingPolicy.Archive(
            StaticLibrary sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString libraryPath,
            System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> objectFiles,
            System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> headers)
        {
            if (0 == objectFiles.Count)
            {
                return;
            }

            var workspace = Bam.Core.Graph.Instance.MetaData as XcodeBuilder.WorkspaceMeta;
            var target    = workspace.EnsureTargetExists(sender);

            target.EnsureOutputFileReferenceExists(
                sender.CreateTokenizedString("@filename($(0))", libraryPath),
                XcodeBuilder.FileReference.EFileType.Archive,
                XcodeBuilder.Target.EProductType.StaticLibrary);
            var configuration = target.GetConfiguration(sender);

            if (sender.Macros["OutputName"].Equals(sender.Macros["modulename"]))
            {
                configuration.SetProductName(Bam.Core.TokenizedString.CreateVerbatim("${TARGET_NAME}"));
            }
            else
            {
                configuration.SetProductName(sender.Macros["OutputName"]);
            }

            foreach (var header in headers)
            {
                target.EnsureHeaderFileExists((header as HeaderFile).InputPath);
            }

            var excludedSource  = new XcodeBuilder.MultiConfigurationValue();
            var realObjectFiles = objectFiles.Where(item => !(item is AssembledObjectFile)); // C,C++,ObjC,ObjC++

            if (realObjectFiles.Any())
            {
                var xcodeConvertParameterTypes = new Bam.Core.TypeArray
                {
                    typeof(Bam.Core.Module),
                    typeof(XcodeBuilder.Configuration)
                };

                var sharedSettings = C.SettingsBase.SharedSettings(
                    realObjectFiles,
                    typeof(ClangCommon.XcodeCompilerImplementation),
                    typeof(XcodeProjectProcessor.IConvertToProject),
                    xcodeConvertParameterTypes);
                (sharedSettings as XcodeProjectProcessor.IConvertToProject).Convert(sender, configuration);

                foreach (var objFile in realObjectFiles)
                {
                    if (!(objFile as C.ObjectFileBase).PerformCompilation)
                    {
                        var fullPath = (objFile as C.ObjectFileBase).InputPath.Parse();
                        var filename = System.IO.Path.GetFileName(fullPath);
                        excludedSource.Add(filename);
                    }

                    var buildFile     = objFile.MetaData as XcodeBuilder.BuildFile;
                    var deltaSettings = (objFile.Settings as C.SettingsBase).CreateDeltaSettings(sharedSettings, objFile);
                    if (null != deltaSettings)
                    {
                        var commandLine = new Bam.Core.StringArray();
                        (deltaSettings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine);
                        if (commandLine.Count > 0)
                        {
                            // Cannot set per-file-per-configuration settings, so blend them together
                            if (null == buildFile.Settings)
                            {
                                buildFile.Settings = commandLine;
                            }
                            else
                            {
                                buildFile.Settings.AddRangeUnique(commandLine);
                            }
                        }
                    }
                    configuration.BuildFiles.Add(buildFile);
                }

                // now deal with other object file types
                var assembledObjectFiles = objectFiles.Where(item => item is AssembledObjectFile);
                foreach (var asmObj in assembledObjectFiles)
                {
                    var buildFile = asmObj.MetaData as XcodeBuilder.BuildFile;
                    configuration.BuildFiles.Add(buildFile);
                }
            }
            else
            {
                (objectFiles[0].Settings as XcodeProjectProcessor.IConvertToProject).Convert(sender, configuration);
                foreach (var objFile in objectFiles)
                {
                    if (!(objFile as C.ObjectFileBase).PerformCompilation)
                    {
                        var fullPath = (objFile as C.ObjectFileBase).InputPath.Parse();
                        var filename = System.IO.Path.GetFileName(fullPath);
                        excludedSource.Add(filename);
                    }

                    var buildFile = objFile.MetaData as XcodeBuilder.BuildFile;
                    configuration.BuildFiles.Add(buildFile);
                }
            }

            configuration["EXCLUDED_SOURCE_FILE_NAMES"] = excludedSource;

            // convert librarian settings to the Xcode project
            if (sender.Settings is XcodeProjectProcessor.IConvertToProject)
            {
                (sender.Settings as XcodeProjectProcessor.IConvertToProject).Convert(sender, configuration);
            }

            // order only dependents
            foreach (var required in sender.Requirements)
            {
                if (null == required.MetaData)
                {
                    continue;
                }
                if (required is HeaderLibrary)
                {
                    // the target for a HeaderLibrary has no FileReference output, and thus cannot be an order only dependency
                    continue;
                }

                var requiredTarget = required.MetaData as XcodeBuilder.Target;
                if (null != requiredTarget)
                {
                    target.Requires(requiredTarget);
                }
            }
            // any non-C module targets should be order-only dependencies
            // note: this is unlikely to happen, as StaticLibraries don't have hard 'dependencies'
            // because there is no fixed 'link' action at the end
            foreach (var dependent in sender.Dependents)
            {
                if (null == dependent.MetaData)
                {
                    continue;
                }
                if (dependent is C.CModule)
                {
                    continue;
                }
                var dependentTarget = dependent.MetaData as XcodeBuilder.Target;
                if (null != dependentTarget)
                {
                    target.Requires(dependentTarget);
                }
            }
            // however, there may be forwarded libraries, and these are useful order only dependents
            foreach (var dependent in (sender as IForwardedLibraries).ForwardedLibraries)
            {
                if (null == dependent.MetaData)
                {
                    continue;
                }
                var dependentTarget = dependent.MetaData as XcodeBuilder.Target;
                if (null != dependentTarget)
                {
                    target.Requires(dependentTarget);
                }
            }
        }
        IArchivingPolicy.Archive(
            StaticLibrary sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString libraryPath,
            System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> objectFiles,
            System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> headers)
        {
            if (0 == objectFiles.Count)
            {
                return;
            }

            var solution = Bam.Core.Graph.Instance.MetaData as VSSolutionBuilder.VSSolution;
            var project  = solution.EnsureProjectExists(sender);
            var config   = project.GetConfiguration(sender);

            config.SetType(VSSolutionBuilder.VSProjectConfiguration.EType.StaticLibrary);
            config.SetOutputPath(libraryPath);
            config.EnableIntermediatePath();

            foreach (var header in headers)
            {
                config.AddHeaderFile(header as HeaderFile);
            }

            var compilerGroup = config.GetSettingsGroup(VSSolutionBuilder.VSSettingsGroup.ESettingsGroup.Compiler);

            var realObjectFiles = objectFiles.Where(item => !((item is WinResource) || (item is AssembledObjectFile)));

            if (realObjectFiles.Any())
            {
                var vsConvertParameterTypes = new Bam.Core.TypeArray
                {
                    typeof(Bam.Core.Module),
                    typeof(VSSolutionBuilder.VSSettingsGroup),
                    typeof(string)
                };

                var sharedSettings = C.SettingsBase.SharedSettings(
                    realObjectFiles,
                    typeof(VisualCCommon.VSSolutionImplementation),
                    typeof(VisualStudioProcessor.IConvertToProject),
                    vsConvertParameterTypes);
                (sharedSettings as VisualStudioProcessor.IConvertToProject).Convert(sender, compilerGroup);

                foreach (var objFile in realObjectFiles)
                {
                    var deltaSettings = (objFile.Settings as C.SettingsBase).CreateDeltaSettings(sharedSettings, objFile);
                    config.AddSourceFile(objFile, deltaSettings);
                }
            }

            // now handle the other object file types

            // TODO: if there were many resource files, this could also have a common settings group? Not sure if VS supports this
            // and it's not as likely to have many resource files, as it would have many source files
            var resourceObjectFiles = objectFiles.Where(item => item is WinResource);

            foreach (var resObj in resourceObjectFiles)
            {
                config.AddResourceFile(resObj as WinResource, resObj.Settings);
            }

            var assembledObjectFiles = objectFiles.Where(item => item is AssembledObjectFile);

            foreach (var asmObj in assembledObjectFiles)
            {
                config.AddAssemblyFile(asmObj as AssembledObjectFile, asmObj.Settings);
            }

            var vsSettingsGroup = config.GetSettingsGroup(VSSolutionBuilder.VSSettingsGroup.ESettingsGroup.Librarian);

            (sender.Settings as VisualStudioProcessor.IConvertToProject).Convert(sender, vsSettingsGroup);

            // order only dependencies
            foreach (var required in sender.Requirements)
            {
                if (null == required.MetaData)
                {
                    continue;
                }

                var requiredProject = required.MetaData as VSSolutionBuilder.VSProject;
                if (null != requiredProject)
                {
                    config.RequiresProject(requiredProject);
                }
            }
            // any non-C module projects should be order-only dependencies
            // note: this is unlikely to happen, as StaticLibraries don't have hard 'dependencies'
            // because there is no fixed 'link' action at the end
            foreach (var dependent in sender.Dependents)
            {
                if (null == dependent.MetaData)
                {
                    continue;
                }
                if (dependent is C.CModule)
                {
                    continue;
                }
                var dependentProject = dependent.MetaData as VSSolutionBuilder.VSProject;
                if (null != dependentProject)
                {
                    config.RequiresProject(dependentProject);
                }
            }
            // however, there may be forwarded libraries, and these are useful order only dependents
            foreach (var dependent in (sender as IForwardedLibraries).ForwardedLibraries)
            {
                if (null == dependent.MetaData)
                {
                    continue;
                }
                var dependentProject = dependent.MetaData as VSSolutionBuilder.VSProject;
                if (null != dependentProject)
                {
                    config.RequiresProject(dependentProject);
                }
            }
        }
        ILinkingPolicy.Link(
            ConsoleApplication sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString executablePath,
            System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> objectFiles,
            System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> headers,
            System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> libraries)
        {
            if (0 == objectFiles.Count)
            {
                return;
            }

            var workspace   = Bam.Core.Graph.Instance.MetaData as XcodeBuilder.WorkspaceMeta;
            var target      = workspace.EnsureTargetExists(sender);
            var exeFilename = sender.CreateTokenizedString("@filename($(0))", executablePath);

            exeFilename.Parse();
            target.EnsureOutputFileReferenceExists(
                exeFilename,
                (sender is IDynamicLibrary) ? XcodeBuilder.FileReference.EFileType.DynamicLibrary : XcodeBuilder.FileReference.EFileType.Executable,
                (sender is IDynamicLibrary) ? XcodeBuilder.Target.EProductType.DynamicLibrary : XcodeBuilder.Target.EProductType.Executable);
            var configuration = target.GetConfiguration(sender);

            if (sender is IDynamicLibrary && !((sender is Plugin) || (sender is C.Cxx.Plugin)))
            {
                var productName = sender.Macros["OutputName"].ToString().Equals(sender.Macros["modulename"].ToString()) ?
                                  sender.CreateTokenizedString("${TARGET_NAME}.$(MajorVersion)") :
                                  sender.CreateTokenizedString("$(OutputName).$(MajorVersion)");
                lock (productName)
                {
                    if (!productName.IsParsed)
                    {
                        productName.Parse();
                    }
                }
                configuration.SetProductName(productName);
            }
            else
            {
                if (sender.Macros["OutputName"].ToString().Equals(sender.Macros["modulename"].ToString()))
                {
                    configuration.SetProductName(Bam.Core.TokenizedString.CreateVerbatim("${TARGET_NAME}"));
                }
                else
                {
                    configuration.SetProductName(sender.Macros["OutputName"]);
                }
            }

            foreach (var header in headers)
            {
                target.EnsureHeaderFileExists((header as HeaderFile).InputPath);
            }

            var excludedSource  = new XcodeBuilder.MultiConfigurationValue();
            var realObjectFiles = objectFiles.Where(item => !((item is WinResource) || (item is AssembledObjectFile)));

            if (realObjectFiles.Any())
            {
                var xcodeConvertParameterTypes = new Bam.Core.TypeArray
                {
                    typeof(Bam.Core.Module),
                    typeof(XcodeBuilder.Configuration)
                };

                var sharedSettings = C.SettingsBase.SharedSettings(
                    realObjectFiles,
                    typeof(ClangCommon.XcodeCompilerImplementation),
                    typeof(XcodeProjectProcessor.IConvertToProject),
                    xcodeConvertParameterTypes);
                XcodeSharedSettings.Tweak(sharedSettings);
                (sharedSettings as XcodeProjectProcessor.IConvertToProject).Convert(sender, configuration);

                foreach (var objFile in realObjectFiles)
                {
                    var asObjFileBase = objFile as C.ObjectFileBase;
                    if (!asObjFileBase.PerformCompilation)
                    {
                        var fullPath = asObjFileBase.InputPath.ToString();
                        var filename = System.IO.Path.GetFileName(fullPath);
                        excludedSource.Add(filename);
                    }

                    var buildFile     = objFile.MetaData as XcodeBuilder.BuildFile;
                    var deltaSettings = (objFile.Settings as C.SettingsBase).CreateDeltaSettings(sharedSettings, objFile);
                    if (null != deltaSettings)
                    {
                        var commandLine = new Bam.Core.StringArray();
                        (deltaSettings as CommandLineProcessor.IConvertToCommandLine).Convert(commandLine);
                        if (commandLine.Count > 0)
                        {
                            // Cannot set per-file-per-configuration settings, so blend them together
                            if (null == buildFile.Settings)
                            {
                                buildFile.Settings = commandLine;
                            }
                            else
                            {
                                buildFile.Settings.AddRangeUnique(commandLine);
                            }
                        }
                    }
                    configuration.BuildFiles.Add(buildFile);
                }

                // now deal with other object file types
                var assembledObjectFiles = objectFiles.Where(item => item is AssembledObjectFile);
                foreach (var asmObj in assembledObjectFiles)
                {
                    var buildFile = asmObj.MetaData as XcodeBuilder.BuildFile;
                    configuration.BuildFiles.Add(buildFile);
                }
            }
            else
            {
                (objectFiles[0].Settings as XcodeProjectProcessor.IConvertToProject).Convert(sender, configuration);
                foreach (var objFile in objectFiles)
                {
                    var asObjFileBase = objFile as C.ObjectFileBase;
                    if (!asObjFileBase.PerformCompilation)
                    {
                        var fullPath = asObjFileBase.InputPath.ToString();
                        var filename = System.IO.Path.GetFileName(fullPath);
                        excludedSource.Add(filename);
                    }

                    var buildFile = objFile.MetaData as XcodeBuilder.BuildFile;
                    configuration.BuildFiles.Add(buildFile);
                }
            }

            configuration["EXCLUDED_SOURCE_FILE_NAMES"] = excludedSource;

            // add library search paths prior to converting linker settings
            var linker = sender.Settings as C.ICommonLinkerSettings;

            foreach (var library in libraries)
            {
                if (library is C.StaticLibrary)
                {
                    var libDir = library.CreateTokenizedString("@dir($(0))", library.GeneratedPaths[C.StaticLibrary.Key]);
                    lock (libDir)
                    {
                        if (!libDir.IsParsed)
                        {
                            libDir.Parse();
                        }
                    }
                    linker.LibraryPaths.Add(libDir);
                }
                else if (library is C.IDynamicLibrary)
                {
                    var libDir = library.CreateTokenizedString("@dir($(0))", library.GeneratedPaths[C.DynamicLibrary.Key]);
                    lock (libDir)
                    {
                        if (!libDir.IsParsed)
                        {
                            libDir.Parse();
                        }
                    }
                    linker.LibraryPaths.Add(libDir);
                }
                else if (library is C.CSDKModule)
                {
                    // SDK modules are collections of libraries, not one in particular
                    // thus do nothing as they are undefined at this point, and may yet be pulled in automatically
                }
                else if (library is C.HeaderLibrary)
                {
                    // no library
                }
                else if (library is OSXFramework)
                {
                    // frameworks are dealt with elsewhere
                }
                else
                {
                    throw new Bam.Core.Exception("Don't know how to handle this module type, {0}", library.ToString());
                }
            }

            foreach (var library in libraries)
            {
                var libAsCModule = library as C.CModule;
                if (null == libAsCModule)
                {
                    throw new Bam.Core.Exception("Don't know how to handle library module of type '{0}'", library.GetType().ToString());
                }
                if (libAsCModule.IsPrebuilt)
                {
                    if (library is OSXFramework)
                    {
                        // frameworks are dealt with elsewhere
                    }
                    else if (library is C.StaticLibrary)
                    {
                        (sender.Tool as C.LinkerTool).ProcessLibraryDependency(sender as CModule, libAsCModule);
                    }
                    else
                    {
                        throw new Bam.Core.Exception("Don't know how to handle this prebuilt module dependency, '{0}'", library.GetType().ToString());
                    }
                }
                else
                {
                    if (library is C.StaticLibrary)
                    {
                        target.DependsOn(library.MetaData as XcodeBuilder.Target);
                    }
                    else if (library is C.IDynamicLibrary)
                    {
                        target.DependsOn(library.MetaData as XcodeBuilder.Target);
                    }
                    else if (library is C.CSDKModule)
                    {
                        // do nothing, just an area for external
                    }
                    else if (library is C.HeaderLibrary)
                    {
                        // no library
                    }
                    else if (library is OSXFramework)
                    {
                        // frameworks are dealt with elsewhere
                    }
                    else
                    {
                        throw new Bam.Core.Exception("Don't know how to handle this module type");
                    }
                }
            }

            // convert link settings to the Xcode project
            (sender.Settings as XcodeProjectProcessor.IConvertToProject).Convert(sender, configuration);

            var required_targets = new System.Collections.Generic.HashSet <XcodeBuilder.Target>();
            // order only dependencies - recurse into each, so that all layers
            // of order only dependencies are included
            var queue = new System.Collections.Generic.Queue <Bam.Core.Module>(sender.Requirements);

            while (queue.Count > 0)
            {
                var required = queue.Dequeue();
                foreach (var additional in required.Requirements)
                {
                    queue.Enqueue(additional);
                }

                if (null == required.MetaData)
                {
                    continue;
                }
                if (required is HeaderLibrary)
                {
                    // the target for a HeaderLibrary has no FileReference output, and thus cannot be an order only dependency
                    continue;
                }

                var requiredTarget = required.MetaData as XcodeBuilder.Target;
                if (null != requiredTarget)
                {
                    required_targets.Add(requiredTarget);
                }
            }
            // any non-C module projects should be order-only dependencies
            foreach (var dependent in sender.Dependents)
            {
                if (null == dependent.MetaData)
                {
                    continue;
                }
                if (dependent is C.CModule)
                {
                    continue;
                }
                var dependentTarget = dependent.MetaData as XcodeBuilder.Target;
                if (null != dependentTarget)
                {
                    required_targets.Add(dependentTarget);
                }
            }
            foreach (var reqTarget in required_targets)
            {
                target.Requires(reqTarget);
            }
        }
Example #7
0
        internal void Initialize(IClassificationTypeRegistryService service,
                                 IClassificationFormatMapService ClassificationFormatMapService)
        {
            try
            {
                if (initialized)
                {
                    return;
                }

                string ffn = _buffer.GetFFN();
                if (ffn == null)
                {
                    return;
                }

                Workspaces.Document document = Workspaces.Workspace.Instance.FindDocument(ffn);
                LanguageServer.IParserDescription _grammar_description = LanguageServer.ParserDescriptionFactory.Create(document);
                if (_grammar_description == null)
                {
                    return;
                }

                _to_classifiertype = new Dictionary <int, IClassificationType>();

                IClassificationFormatMap classificationFormatMap = ClassificationFormatMapService.GetClassificationFormatMap(category: "text");
                // hardwire colors to VS's colors of selected types.
                System.Collections.ObjectModel.ReadOnlyCollection <IClassificationType> list_of_formats = classificationFormatMap.CurrentPriorityOrder;

                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationNonterminalDef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrNonterminalDef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable CS0168 // Variable is declared but never used
                        catch (Exception eeks) { }
#pragma warning restore CS0168 // Variable is declared but never used
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationNonterminalRef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrNonterminalRef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationTerminalDef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrTerminalDef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationTerminalRef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrTerminalRef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationComment;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrComment")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationKeyword;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrKeyword")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationLiteral;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrLiteral")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationModeDef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrModeDef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationModeRef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrModeRef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationChannelDef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrChannelDef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationChannelRef;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrChannelRef")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationPunctuation;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrPunctuation")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                {
                    int    i   = (int)LanguageServer.Antlr4ParsingResults.AntlrClassifications.ClassificationOperator;
                    string val = _grammar_description.Map[i];
                    IClassificationType identiferClassificationType = service.GetClassificationType(val);
                    IClassificationType classificationType          = identiferClassificationType ?? service.CreateClassificationType(val, Array.Empty <IClassificationType>());
                    IClassificationType t = list_of_formats.Where(f => f != null && f.Classification == Options.Option.GetString("AntlrOperator")).FirstOrDefault();
                    if (t != null)
                    {
                        try
                        {
                            Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties identifierProperties = classificationFormatMap
                                                                                                                      .GetExplicitTextProperties(t);
                            classificationFormatMap.AddExplicitTextProperties(classificationType, identifierProperties);
                        }
#pragma warning disable 0168
                        catch (Exception eeks) { }
#pragma warning restore 0168
                    }
                    _to_classifiertype[i] = classificationType;
                }
                initialized = true;
            }
#pragma warning disable 0168
            catch (Exception eeks) { }
#pragma warning restore 0168
        }
        private TimeZoneInfo getWindowsTimezoneFromDescription(String tzDescription)
        {
            try {
                System.Collections.ObjectModel.ReadOnlyCollection <TimeZoneInfo> sysTZ = TimeZoneInfo.GetSystemTimeZones();

                //First let's just search with what we've got
                TimeZoneInfo tzi = sysTZ.FirstOrDefault(t => t.DisplayName == tzDescription || t.StandardName == tzDescription || t.Id == tzDescription);
                if (tzi != null)
                {
                    return(tzi);
                }

                log.Warn("Could not find timezone ID based on given description. Attempting some fuzzy logic...");
                if (tzDescription.StartsWith("(GMT"))
                {
                    log.Fine("Replace GMT with UTC");
                    String modTzDescription = tzDescription.Replace("(GMT", "(UTC");
                    tzi = sysTZ.FirstOrDefault(t => t.DisplayName == modTzDescription || t.StandardName == modTzDescription || t.Id == modTzDescription);
                    if (tzi != null)
                    {
                        return(tzi);
                    }

                    log.Fine("Removing offset prefix");
                    modTzDescription = System.Text.RegularExpressions.Regex.Replace(modTzDescription, @"^\(UTC[+-]\d{1,2}:\d{0,2}\)\s+", "").Trim();
                    tzi = sysTZ.FirstOrDefault(t => t.StandardName == modTzDescription || t.Id == modTzDescription);
                    if (tzi != null)
                    {
                        return(tzi);
                    }
                }


                //Try searching just by timezone offset. This would at least get the right time for the appointment, eg if the tzDescription doesn't match
                //because they it is in a different language that the user's system data.
                Int16?offset = null;
                offset = TimezoneDB.GetTimezoneOffset(tzDescription);
                if (offset != null)
                {
                    List <TimeZoneInfo> tzis = sysTZ.Where(t => t.BaseUtcOffset.Hours == offset).ToList();
                    if (tzis.Count == 0)
                    {
                        log.Warn("No timezone ID exists for organiser's GMT offset timezone " + tzDescription);
                    }
                    else if (tzis.Count == 1)
                    {
                        return(tzis.First());
                    }
                    else
                    {
                        String tzCountry = tzDescription.Substring(tzDescription.LastIndexOf("/") + 1);
                        if (string.IsNullOrEmpty(tzCountry))
                        {
                            log.Warn("Could not determine country; and multiple timezones exist with same GMT offset of " + offset + ". Picking the first.");
                            return(tzis.FirstOrDefault());
                        }
                        else
                        {
                            List <TimeZoneInfo> countryTzis = tzis.Where(t => t.DisplayName.Contains(tzCountry)).ToList();
                            if (countryTzis.Count == 0)
                            {
                                log.Warn("Could not find timezone with GMT offset of " + offset + " for country " + tzCountry + ". Picking the first offset match regardless of country.");
                                return(tzis.FirstOrDefault());
                            }
                            else if (countryTzis.Count == 1)
                            {
                                return(countryTzis.First());
                            }
                            else
                            {
                                log.Warn("Could not find unique timezone with GMT offset of " + offset + " for country " + tzCountry + ". Picking the first.");
                                return(countryTzis.FirstOrDefault());
                            }
                        }
                    }
                }
                else
                {
                    //Check if it's already an IANA value
                    NodaTime.TimeZones.TzdbDateTimeZoneSource         tzDBsource = TimezoneDB.Instance.Source;
                    IEnumerable <NodaTime.TimeZones.TzdbZoneLocation> a          = tzDBsource.ZoneLocations.Where(l => l.ZoneId == tzDescription);
                    if (a.Count() >= 1)
                    {
                        log.Debug("It appears to be an IANA timezone already!");
                        Microsoft.Office.Interop.Outlook.TimeZone tz = WindowsTimeZone(tzDescription);
                        if (tz != null)
                        {
                            return(TimeZoneInfo.FindSystemTimeZoneById(tz.ID));
                        }
                    }
                }
            } catch (System.Exception ex) {
                log.Warn("Failed to get the organiser's timezone ID for " + tzDescription);
                OGCSexception.Analyse(ex);
            }
            return(null);
        }
Example #9
0
        private static string FindFullVoiceName(string voiceArgument)
        {
            string voiceName = null;

            using (SpeechSynthesizer synthesizer = new SpeechSynthesizer())
            {
                System.Collections.ObjectModel.ReadOnlyCollection <InstalledVoice> installedVoices = synthesizer.GetInstalledVoices();
                System.Collections.Generic.IEnumerable <InstalledVoice>            enabledVoices   = installedVoices.Where(voice => voice.Enabled);

                InstalledVoice selectedVoice = enabledVoices.FirstOrDefault(voice => voice.VoiceInfo.Name.ToLowerInvariant().Contains(voiceArgument));
                if (selectedVoice != null)
                {
                    voiceName = selectedVoice.VoiceInfo.Name;
                }
            }
            return(voiceName);
        }
Example #10
0
        ILinkingPolicy.Link(
            ConsoleApplication sender,
            Bam.Core.ExecutionContext context,
            Bam.Core.TokenizedString executablePath,
            System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> objectFiles,
            System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> headers,
            System.Collections.ObjectModel.ReadOnlyCollection <Bam.Core.Module> libraries)
        {
            if (0 == objectFiles.Count)
            {
                if (headers.Count > 0)
                {
                    this.CreateHeaderOnlyLibrary(sender, headers);
                }
                return;
            }

            var solution = Bam.Core.Graph.Instance.MetaData as VSSolutionBuilder.VSSolution;
            var project  = solution.EnsureProjectExists(sender);
            var config   = project.GetConfiguration(sender);

            config.SetType((sender is IDynamicLibrary) ? VSSolutionBuilder.VSProjectConfiguration.EType.DynamicLibrary : VSSolutionBuilder.VSProjectConfiguration.EType.Application);
            config.SetOutputPath(executablePath);
            config.EnableIntermediatePath();

            foreach (var header in headers)
            {
                config.AddHeaderFile(header as HeaderFile);
            }

            var compilerGroup = config.GetSettingsGroup(VSSolutionBuilder.VSSettingsGroup.ESettingsGroup.Compiler);

            var realObjectFiles = objectFiles.Where(item => !((item is WinResource) || (item is AssembledObjectFile)));

            if (realObjectFiles.Any())
            {
                var vsConvertParameterTypes = new Bam.Core.TypeArray
                {
                    typeof(Bam.Core.Module),
                    typeof(VSSolutionBuilder.VSSettingsGroup),
                    typeof(string)
                };

                var sharedSettings = C.SettingsBase.SharedSettings(
                    realObjectFiles,
                    typeof(VisualCCommon.VSSolutionImplementation),
                    typeof(VisualStudioProcessor.IConvertToProject),
                    vsConvertParameterTypes);
                (sharedSettings as VisualStudioProcessor.IConvertToProject).Convert(sender, compilerGroup);

                foreach (var objFile in realObjectFiles)
                {
                    var deltaSettings = (objFile.Settings as C.SettingsBase).CreateDeltaSettings(sharedSettings, objFile);
                    config.AddSourceFile(objFile, deltaSettings);
                }

                // now handle the other object file types

                // TODO: if there were many resource files, this could also have a common settings group? Not sure if VS supports this
                // and it's not as likely to have many resource files, as it would have many source files
                var resourceObjectFiles = objectFiles.Where(item => item is WinResource);
                foreach (var resObj in resourceObjectFiles)
                {
                    config.AddResourceFile(resObj as WinResource, resObj.Settings);
                }

                var assembledObjectFiles = objectFiles.Where(item => item is AssembledObjectFile);
                foreach (var asmObj in assembledObjectFiles)
                {
                    config.AddAssemblyFile(asmObj as AssembledObjectFile);
                }
            }
            else
            {
                (objectFiles[0].Settings as VisualStudioProcessor.IConvertToProject).Convert(sender, compilerGroup);
                foreach (var objFile in objectFiles)
                {
                    config.AddSourceFile(objFile, null);
                }
            }

            foreach (var input in libraries)
            {
                if ((null != input.MetaData) && VSSolutionBuilder.VSProject.IsBuildable(input))
                {
                    if ((input is C.StaticLibrary) || (input is C.IDynamicLibrary))
                    {
                        config.LinkAgainstProject(solution.EnsureProjectExists(input));
                    }
                    else if ((input is C.CSDKModule) || (input is C.HeaderLibrary))
                    {
                        continue;
                    }
                    else if (input is OSXFramework)
                    {
                        throw new Bam.Core.Exception("Frameworks are not supported on Windows: {0}", input.ToString());
                    }
                    else
                    {
                        throw new Bam.Core.Exception("Don't know how to handle this buildable library module, {0}", input.ToString());
                    }
                }
                else
                {
                    if (input is C.StaticLibrary)
                    {
                        // TODO: probably a simplification of the DLL codepath
                        throw new System.NotImplementedException();
                    }
                    else if (input is C.IDynamicLibrary)
                    {
                        // TODO: this might be able to shift out of the conditional
                        (sender.Tool as C.LinkerTool).ProcessLibraryDependency(sender as CModule, input as CModule);
                    }
                    else if ((input is C.CSDKModule) || (input is C.HeaderLibrary))
                    {
                        continue;
                    }
                    else if (input is OSXFramework)
                    {
                        throw new Bam.Core.Exception("Frameworks are not supported on Windows: {0}", input.ToString());
                    }
                    else
                    {
                        throw new Bam.Core.Exception("Don't know how to handle this prebuilt library module, {0}", input.ToString());
                    }
                }
            }

            var linkerGroup = config.GetSettingsGroup(VSSolutionBuilder.VSSettingsGroup.ESettingsGroup.Linker);

            (sender.Settings as VisualStudioProcessor.IConvertToProject).Convert(sender, linkerGroup);

            // order only dependencies
            foreach (var required in sender.Requirements)
            {
                if (null == required.MetaData)
                {
                    continue;
                }

                var requiredProject = required.MetaData as VSSolutionBuilder.VSProject;
                if (null != requiredProject)
                {
                    config.RequiresProject(requiredProject);
                }
            }
            // any non-C module projects should be order-only dependencies
            foreach (var dependent in sender.Dependents)
            {
                if (null == dependent.MetaData)
                {
                    continue;
                }
                if (dependent is C.CModule)
                {
                    continue;
                }
                var dependentProject = dependent.MetaData as VSSolutionBuilder.VSProject;
                if (null != dependentProject)
                {
                    config.RequiresProject(dependentProject);
                }
            }
        }