示例#1
0
        /// <summary>
        /// Create a window on the current platform.
        /// </summary>
        /// <param name="options">The window to use.</param>
        /// <returns>A Silk.NET window using the current platform.</returns>
        public static IWindow Create(WindowOptions options)
        {
            if (Platforms.Count == 0)
            {
                throw NoPlatformException;
            }

            if (!Platforms.Any(x => x.IsApplicable))
            {
                throw NoPlatformException;
            }

            if (IsViewOnly)
            {
                throw new NotSupportedException
                      (
                          $"The currently bound window platform(s) {PlatformsStr}only support views, " +
                          "instead of windows. Use the view APIs instead."
                      );
            }

            foreach (var platform in Platforms)
            {
                if (platform.IsViewOnly)
                {
                    continue;
                }

                // ReSharper disable once PossibleNullReferenceException
                return(platform.CreateWindow(options));
            }

            throw NoPlatformException;
        }
示例#2
0
 public bool PreferredOnPlatform(PlatformUtil.OS os)
 {
     if (os == PlatformUtil.OS.Windows)
     {
         return(Platforms?.Any(x => string.Equals(x, os.ToString(), StringComparison.OrdinalIgnoreCase)) ?? false);
     }
     return(false);
 }
示例#3
0
        public bool PreferredOnCurrentPlatform()
        {
#if OS_WINDOWS
            const string CurrentPlatform = "windows";
            return(Platforms?.Any(x => string.Equals(x, CurrentPlatform, StringComparison.OrdinalIgnoreCase)) ?? false);
#else
            return(false);
#endif
        }
        bool DoesPlatformMatch(BrowserIdentification browserId)
        {
            if (Platforms == null || !Platforms.Any())
            {
                return(true);
            }

            return(Platforms.Any(x => x.Equals(browserId.Platform, StringComparison.InvariantCultureIgnoreCase)));
        }
示例#5
0
        public EmbedBuilder ToEmbed()
        {
            EmbedBuilder embedBuilder = new EmbedBuilder();

            embedBuilder.WithTitle(Name)
            .WithUrl(SiteDetailUrl)
            .WithDescription(Deck ?? "No Deck on Giant Bomb.")
            .WithImageUrl(Image?.MediumUrl ?? Image?.SmallUrl ?? Image?.ThumbUrl ?? Image?.SuperUrl ?? "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/No_image_available.svg/200px-No_image_available.svg.png")
            .WithFooter(x => x.Text = "Giant Bomb")
            .WithColor(new Discord.Color(0x00CC00))
            .WithCurrentTimestamp();

            if (OriginalReleaseDate != null)
            {
                embedBuilder.AddField(x =>
                {
                    x.Name     = "First release date";
                    x.Value    = OriginalReleaseDate?.Replace(" 00:00:00", "");
                    x.IsInline = true;
                });
            }
            else if (ExpectedReleaseDay != null && ExpectedReleaseMonth != null && ExpectedReleaseYear != null)
            {
                embedBuilder.AddField(x =>
                {
                    x.Name  = "Expected release date";
                    x.Value =
                        $"{ExpectedReleaseYear}-{(ExpectedReleaseMonth < 10 ? "0" + ExpectedReleaseMonth : ExpectedReleaseMonth.ToString())}-{ExpectedReleaseDay}";
                    x.IsInline = true;
                });
            }
            else if (ExpectedReleaseQuarter != null && ExpectedReleaseYear != null)
            {
                embedBuilder.AddField(x =>
                {
                    x.Name     = "Expected release quarter";
                    x.Value    = $"Q{ExpectedReleaseQuarter} {ExpectedReleaseYear}";
                    x.IsInline = true;
                });
            }

            if (Platforms != null && Platforms.Any())
            {
                embedBuilder.AddField(x =>
                {
                    x.Name     = "Platforms";
                    x.Value    = Platforms != null ? string.Join(", ", Platforms?.Select(y => y.Name)) : null;
                    x.IsInline = true;
                });
            }

            return(embedBuilder);
        }
示例#6
0
        /// <summary>
        /// Saves the Visual Studio solution to a file.
        /// </summary>
        /// <param name="rootPath">A root path for the solution to make other paths relative to.</param>
        /// <param name="writer">The <see cref="TextWriter" /> to save the solution file to.</param>
        /// <param name="useFolders">Specifies if folders should be created.</param>
        /// <param name="collapseFolders">An optional value indicating whether or not folders containing a single item should be collapsed into their parent folder.</param>
        internal void Save(string rootPath, TextWriter writer, bool useFolders, bool collapseFolders = false)
        {
            writer.WriteLine(Header, _fileFormatVersion);

            if (SolutionItems.Count > 0)
            {
                writer.WriteLine($@"Project(""{SlnFolder.FolderProjectTypeGuid}"") = ""Solution Items"", ""Solution Items"", ""{Guid.NewGuid().ToSolutionString()}"" ");
                writer.WriteLine("	ProjectSection(SolutionItems) = preProject");
                foreach (string solutionItem in SolutionItems.Select(i => i.ToRelativePath(rootPath)))
                {
                    writer.WriteLine($"		{solutionItem} = {solutionItem}");
                }

                writer.WriteLine("	EndProjectSection");
                writer.WriteLine("EndProject");
            }

            foreach (SlnProject project in _projects.OrderBy(i => i.FullPath))
            {
                writer.WriteLine($@"Project(""{project.ProjectTypeGuid.ToSolutionString()}"") = ""{project.Name}"", ""{project.FullPath.ToRelativePath(rootPath)}"", ""{project.ProjectGuid.ToSolutionString()}""");
                writer.WriteLine("EndProject");
            }

            SlnHierarchy hierarchy = null;

            if (useFolders && _projects.Any(i => !i.IsMainProject))
            {
                hierarchy = new SlnHierarchy(_projects, collapseFolders);

                foreach (SlnFolder folder in hierarchy.Folders)
                {
                    writer.WriteLine($@"Project(""{folder.ProjectTypeGuid}"") = ""{folder.Name}"", ""{folder.FullPath.ToRelativePath(rootPath)}"", ""{folder.FolderGuid.ToSolutionString()}""");
                    writer.WriteLine("EndProject");
                }
            }

            writer.WriteLine("Global");

            if (useFolders && _projects.Count > 1 && hierarchy != null)
            {
                writer.WriteLine(@"	GlobalSection(NestedProjects) = preSolution");

                foreach (SlnFolder folder in hierarchy.Folders.Where(i => i.Parent != null))
                {
                    foreach (SlnProject project in folder.Projects)
                    {
                        writer.WriteLine($@"		{project.ProjectGuid.ToSolutionString()} = {folder.FolderGuid.ToSolutionString()}");
                    }

                    writer.WriteLine($@"		{folder.FolderGuid.ToSolutionString()} = {folder.Parent.FolderGuid.ToSolutionString()}");
                }

                writer.WriteLine("	EndGlobalSection");
            }

            writer.WriteLine("	GlobalSection(SolutionConfigurationPlatforms) = preSolution");

            HashSet <string> solutionPlatforms = Platforms != null && Platforms.Any()
                ? new HashSet <string>(GetValidSolutionPlatforms(Platforms), StringComparer.OrdinalIgnoreCase)
                : new HashSet <string>(GetValidSolutionPlatforms(_projects.SelectMany(i => i.Platforms)), StringComparer.OrdinalIgnoreCase);

            HashSet <string> solutionConfigurations = Configurations != null && Configurations.Any()
                ? new HashSet <string>(Configurations, StringComparer.OrdinalIgnoreCase)
                : new HashSet <string>(_projects.SelectMany(i => i.Configurations).Where(i => !i.IsNullOrWhiteSpace()), StringComparer.OrdinalIgnoreCase);

            foreach (string configuration in solutionConfigurations)
            {
                foreach (string platform in solutionPlatforms)
                {
                    if (!string.IsNullOrWhiteSpace(configuration) && !string.IsNullOrWhiteSpace(platform))
                    {
                        writer.WriteLine($"		{configuration}|{platform} = {configuration}|{platform}");
                    }
                }
            }

            writer.WriteLine("	EndGlobalSection");

            writer.WriteLine("	GlobalSection(ProjectConfigurationPlatforms) = postSolution");

            foreach (SlnProject project in _projects)
            {
                string projectGuid = project.ProjectGuid.ToSolutionString();

                foreach (string configuration in solutionConfigurations)
                {
                    bool foundConfiguration = TryGetProjectSolutionConfiguration(configuration, project, out string projectSolutionConfiguration);

                    foreach (string platform in solutionPlatforms)
                    {
                        bool foundPlatform = TryGetProjectSolutionPlatform(platform, project, out string projectSolutionPlatform, out string projectBuildPlatform);

                        writer.WriteLine($@"		{projectGuid}.{configuration}|{platform}.ActiveCfg = {projectSolutionConfiguration}|{projectSolutionPlatform}");

                        if (foundPlatform && foundConfiguration)
                        {
                            writer.WriteLine($@"		{projectGuid}.{configuration}|{platform}.Build.0 = {projectSolutionConfiguration}|{projectBuildPlatform}");
                        }

                        if (project.IsDeployable)
                        {
                            writer.WriteLine($@"		{projectGuid}.{configuration}|{platform}.Deploy.0 = {projectSolutionConfiguration}|{projectSolutionPlatform}");
                        }
                    }
                }
            }

            writer.WriteLine("	EndGlobalSection");

            writer.WriteLine("	GlobalSection(SolutionProperties) = preSolution");
            writer.WriteLine("		HideSolutionNode = FALSE");
            writer.WriteLine("	EndGlobalSection");

            writer.WriteLine("	GlobalSection(ExtensibilityGlobals) = postSolution");
            writer.WriteLine($"		SolutionGuid = {SolutionGuid.ToSolutionString()}");
            writer.WriteLine("	EndGlobalSection");

            writer.WriteLine("EndGlobal");
        }
示例#7
0
 public bool SupportedBy(PlatformInfo platform) =>
 Platforms.Any(platform.SupportsRunning);