예제 #1
0
        /*********
        ** Private methods
        *********/
        /// <summary>Draw borders for each unconnected edge of a tile.</summary>
        /// <param name="spriteBatch">The sprite batch being drawn.</param>
        /// <param name="group">The machine group.</param>
        /// <param name="tile">The group tile.</param>
        /// <param name="color">The border color.</param>
        private void DrawEdgeBorders(SpriteBatch spriteBatch, IMachineGroup group, Vector2 tile, Color color)
        {
            int   borderSize = 3;
            float screenX    = tile.X * Game1.tileSize - Game1.viewport.X;
            float screenY    = tile.Y * Game1.tileSize - Game1.viewport.Y;
            float tileSize   = Game1.tileSize;

            IReadOnlySet <Vector2> tiles = group.GetTiles(this.LocationKey);

            // top
            if (!tiles.Contains(new Vector2(tile.X, tile.Y - 1)))
            {
                spriteBatch.DrawLine(screenX, screenY, new Vector2(tileSize, borderSize), color); // top
            }
            // bottom
            if (!tiles.Contains(new Vector2(tile.X, tile.Y + 1)))
            {
                spriteBatch.DrawLine(screenX, screenY + tileSize, new Vector2(tileSize, borderSize), color); // bottom
            }
            // left
            if (!tiles.Contains(new Vector2(tile.X - 1, tile.Y)))
            {
                spriteBatch.DrawLine(screenX, screenY, new Vector2(borderSize, tileSize), color); // left
            }
            // right
            if (!tiles.Contains(new Vector2(tile.X + 1, tile.Y)))
            {
                spriteBatch.DrawLine(screenX + tileSize, screenY, new Vector2(borderSize, tileSize), color); // right
            }
        }
예제 #2
0
 private static void SetIfSelected(string sectionName, IReadOnlySet <string> sections, Action setDashboardAction)
 {
     if (sections.Contains(sectionName))
     {
         setDashboardAction();
     }
 }
예제 #3
0
        private async Task <bool> EvaluateAllFilesAsync(IReadOnlySet <AbsolutePath> evaluationGoals, QualifierId qualifierId)
        {
            // TODO: consider revisiting this and keeping track of individually evaluated projects, so partial
            // evaluation is possible
            Contract.Assert(m_rushWorkspaceResolver.ComputedProjectGraph.Succeeded);

            RushGraphResult result = m_rushWorkspaceResolver.ComputedProjectGraph.Result;

            // TODO add support for qualifiers
            IReadOnlySet <RushProject> filteredBuildFiles = result.RushGraph.Projects
                                                            .Where(project => evaluationGoals.Contains(project.ProjectPath(m_context.PathTable)))
                                                            .ToReadOnlySet();

            var pipConstructor = new RushPipConstructor(m_context,
                                                        m_host,
                                                        result.ModuleDefinition,
                                                        m_rushResolverSettings,
                                                        m_rushWorkspaceResolver.UserDefinedEnvironment,
                                                        m_rushWorkspaceResolver.UserDefinedPassthroughVariables);

            var graphConstructor = new ProjectGraphToPipGraphConstructor <RushProject>(pipConstructor, m_host.Configuration.FrontEnd.MaxFrontEndConcurrency());

            var scheduleResult = await graphConstructor.TrySchedulePipsForFilesAsync(filteredBuildFiles, qualifierId);

            return(scheduleResult.Succeeded);
        }
        private Dictionary <string, string> Get2WordCombinations(IReadOnlyCollection <string> inputData, IReadOnlySet <string> allNLetterWords)
        {
            var resultSet = new Dictionary <string, string>();

            foreach (var baseWord in inputData)
            {
                foreach (var otherWord in inputData)
                {
                    if (baseWord.Equals(otherWord, StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }
                    var tempCombination = $"{baseWord}+{otherWord}";
                    var tempResult      = baseWord + otherWord;
                    if (tempResult.Length == _maxWordLength)
                    {
                        if (resultSet.ContainsKey(tempCombination))
                        {
                            continue;
                        }
                        if (!allNLetterWords.Contains(tempResult))
                        {
                            continue;
                        }
                        resultSet.Add($"{baseWord}+{otherWord}", tempResult);
                    }
                }
            }

            return(resultSet);
        }
예제 #5
0
        public static long NextInt(IRng rng, int bytes, bool signed)
        {
            long value;

            do
            {
                switch (bytes)
                {
                case 1:
                    value = signed ? (long)rng.NextInt8() : rng.NextUInt8();
                    break;

                case 2:
                    value = signed ? (long)rng.NextInt16() : rng.NextUInt16();
                    break;

                case 4:
                    value = signed ? (long)rng.NextInt32() : rng.NextUInt32();
                    break;

                case 8:
                    value = signed ? rng.NextInt64() : (long)rng.NextUInt64();
                    break;

                default: throw new NotSupportedException();
                }
            } while (EdgeCases.Contains(value));

            return(value);
        }
예제 #6
0
        static int CountNeighbors(IReadOnlySet <HyperCube> actives, int x, int y, int z, int w)
        {
            int count = 0;

            for (int xx = x - 1; xx <= x + 1; xx++)
            {
                for (int yy = y - 1; yy <= y + 1; yy++)
                {
                    for (int zz = z - 1; zz <= z + 1; zz++)
                    {
                        for (int ww = w - 1; ww <= w + 1; ww++)
                        {
                            if (x == xx & y == yy && z == zz && w == ww)
                            {
                                continue;
                            }

                            if (actives.Contains(new HyperCube(xx, yy, zz, ww)))
                            {
                                count++;
                            }
                        }
                    }
                }
            }

            return(count);
        }
예제 #7
0
 protected override bool NeedsProxy(Symbol localOrParameter)
 {
     Debug.Assert(
         localOrParameter.Kind == SymbolKind.Local ||
         localOrParameter.Kind == SymbolKind.Parameter
         );
     return(_hoistedVariables.Contains(localOrParameter));
 }
 public bool SetEquals(IReadOnlySet <T> other)
 {
     if (other == null)
     {
         return(false);
     }
     return(this.Count == other.Count && this.All(item => other.Contains(item)));
 }
예제 #9
0
 private static IReadOnlySet <V> Step(IReadOnlySet <V> activeCells, Func <V, IEnumerable <V> > getNear)
 {
     return(activeCells
            .SelectMany(getNear)
            .CountFrequency()
            .Where(g => g.Value == 3 || g.Value == 2 && activeCells.Contains(g.Key))
            .Select(g => g.Key)
            .ToHashSet());
 }
예제 #10
0
        private static async IAsyncEnumerable <PluginBase.PluginBase> LoadPlugins(IReadOnlySet <string> disabledPlugins, bool checkUpdates = true, bool checkPrerelease = false)
        {
            if (!Directory.Exists("./Plugins"))
            {
                Directory.CreateDirectory("./Plugins");
            }
            var manifests = Directory.EnumerateFiles("./Plugins", "manifest.json", SearchOption.AllDirectories);

            foreach (var manifest in manifests)
            {
                var manifestJson = await File.ReadAllTextAsync(manifest);

                var pluginManifest = JsonConvert.DeserializeObject <PluginManifest>(manifestJson);

                if (pluginManifest is null)
                {
                    _log.LogWarning("Error loading manifest {ManifestFile}. Skipping...", manifest);
                    continue;
                }

                if (disabledPlugins.Contains(pluginManifest.Entrypoint))
                {
                    continue;
                }

                if (checkUpdates)
                {
                    await CheckPluginVersion(pluginManifest, checkPrerelease);
                }

                var dllPath = Path.Combine(Directory.GetParent(manifest) !.FullName, pluginManifest.Entrypoint);
                var loader  = PluginLoader.CreateFromAssemblyFile(
                    dllPath,
                    sharedTypes: new[] { typeof(PluginBase.PluginBase), typeof(ILogger), typeof(ILoggerFactory) },
                    isUnloadable: false);

                foreach (var pluginType in loader
                         .LoadDefaultAssembly()
                         .GetTypes()
                         .Where(t => typeof(PluginBase.PluginBase).IsAssignableFrom(t) && !t.IsAbstract))
                {
                    if (Activator.CreateInstance(pluginType) is not PluginBase.PluginBase plugin)
                    {
                        _log.LogError("{ClassName} does not contain a class inheriting {BaseClassName}. Skipping...", pluginType.Name, nameof(PluginBase.PluginBase));
                        yield break;
                    }

                    _log.LogInformation("Loaded plugin {ClassName}", pluginType.Name);

                    yield return(plugin);
                }
            }
        }
예제 #11
0
        static long Find2(IReadOnlySet <int> entries)
        {
            foreach (int entry in entries)
            {
                if (entries.Contains(2020 - entry))
                {
                    return(entry * (2020 - entry));
                }
            }

            throw new InvalidOperationException("No match found");
        }
예제 #12
0
        protected override void DrawWorld(SpriteBatch spriteBatch)
        {
            if (!Context.IsPlayerFree)
            {
                return;
            }

            // draw each tile
            IReadOnlySet <Vector2> junimoChestTiles = this.JunimoGroup.GetTiles(this.LocationKey);

            foreach (Vector2 tile in TileHelper.GetVisibleTiles(expand: 1))
            {
                // get tile's screen coordinates
                float screenX  = tile.X * Game1.tileSize - Game1.viewport.X;
                float screenY  = tile.Y * Game1.tileSize - Game1.viewport.Y;
                int   tileSize = Game1.tileSize;

                // get machine group
                IMachineGroup?group = null;
                Color?        color = null;
                if (junimoChestTiles.Contains(tile))
                {
                    color = this.JunimoGroup.HasInternalAutomation
                        ? Color.Green * 0.2f
                        : Color.Red * 0.2f;
                    group = this.JunimoGroup;
                }
                else if (this.MachineData is not null)
                {
                    if (this.MachineData.ActiveTiles.TryGetValue(tile, out group))
                    {
                        color = Color.Green * 0.2f;
                    }
                    else if (this.MachineData.DisabledTiles.TryGetValue(tile, out group) || this.MachineData.OutdatedTiles.ContainsKey(tile))
                    {
                        color = Color.Red * 0.2f;
                    }
                }
                color ??= Color.Black * 0.5f;

                // draw background
                spriteBatch.DrawLine(screenX + this.TileGap, screenY + this.TileGap, new Vector2(tileSize - this.TileGap * 2, tileSize - this.TileGap * 2), color);

                // draw group edge borders
                if (group != null)
                {
                    this.DrawEdgeBorders(spriteBatch, group, tile, group.HasInternalAutomation ? Color.Green : Color.Red);
                }
            }

            // draw cursor
            this.DrawCursor();
        }
            public AddingTxEventArgs CanAddTransaction(Block block, Transaction currentTx, IReadOnlySet <Transaction> transactionsInBlock, IStateProvider stateProvider)
            {
                AddingTxEventArgs args = new(transactionsInBlock.Count, currentTx, block, transactionsInBlock);

                long gasRemaining = block.Header.GasLimit - block.GasUsed;

                // No more gas available in block for any transactions,
                // the only case we have to really stop
                if (GasCostOf.Transaction > gasRemaining)
                {
                    return(args.Set(TxAction.Stop, "Block full"));
                }

                if (currentTx.SenderAddress is null)
                {
                    return(args.Set(TxAction.Skip, "Null sender"));
                }

                if (currentTx.GasLimit > gasRemaining)
                {
                    return(args.Set(TxAction.Skip, $"Not enough gas in block, gas limit {currentTx.GasLimit} > {gasRemaining}"));
                }

                if (transactionsInBlock.Contains(currentTx))
                {
                    return(args.Set(TxAction.Skip, "Transaction already in block"));
                }

                IReleaseSpec spec = _specProvider.GetSpec(block.Number);

                if (stateProvider.IsInvalidContractSender(spec, currentTx.SenderAddress))
                {
                    return(args.Set(TxAction.Skip, $"Sender is contract"));
                }

                UInt256 expectedNonce = stateProvider.GetNonce(currentTx.SenderAddress);

                if (expectedNonce != currentTx.Nonce)
                {
                    return(args.Set(TxAction.Skip, $"Invalid nonce - expected {expectedNonce}"));
                }

                UInt256 balance = stateProvider.GetBalance(currentTx.SenderAddress);

                if (!HasEnoughFounds(currentTx, balance, args, block, spec))
                {
                    return(args);
                }

                AddingTransaction?.Invoke(this, args);
                return(args);
            }
예제 #14
0
        public static async Task Run()
        {
            string[] lines = await Loading.Load(nameof(Day4));

            int validCount = 0;

            for (int l = 0; l < lines.Length; l++)
            {
                var  keys  = new HashSet <string>();
                bool valid = true;
                while (l < lines.Length && !string.IsNullOrWhiteSpace(lines[l]))
                {
                    foreach (var pair in lines[l].Split())
                    {
                        var parts = pair.Split(':');
                        if (parts.Length != 2)
                        {
                            Console.WriteLine($"Passport key:value pair with an unexpected number of ':' characters: {pair}");
                            valid = false;
                        }
                        else if (!ValidKeys.Contains(parts[0]))
                        {
                            Console.WriteLine($"Invalid key: {parts[0]}");
                            valid = false;
                        }
                        else if (!keys.Add(parts[0]))
                        {
                            Console.WriteLine($"Duplicate key: {parts[0]}");
                            valid = false;
                        }
                    }

                    l++;
                }

                if (valid)
                {
                    var missing = RequiredKeys.Where(k => !keys.Contains(k)).ToList();
                    if (missing.Count != 0)
                    {
                        Console.WriteLine($"Missing keys: {missing.JoinWithLast(", ", ", and ")}");
                    }
                    else
                    {
                        validCount++;
                    }
                }
            }

            Console.WriteLine($"Valid passports: {validCount}");
        }
예제 #15
0
        // Check if the NPC matches an entry in the list
        private static bool NpcMatchesListEditorID(INpcGetter npc)
        {
            if (NpCsToProtect.Contains(npc.EditorID ?? ""))
            {
                return(true);
            }
            if (PatcherOutputLevel == OutputLevel.Debug)
            {
                Console.WriteLine("[INFO] \"" + npc.EditorID +
                                  "\" is not in the list of NPCs to mark as protected.");
            }

            return(false);
        }
        public object ReadThing(VoxBinaryReader thingReader, Type hintType)
        {
            var type = typeReader.ReadType(thingReader);

            // special cases for type deserialization
            if (type == typeof(TBoolTrue) || type == typeof(TBoolFalse) || type == typeof(TNull))
            {
                // fall straight to reader, ignoring hintType
                return(thingReaderWriterContainer.Get(type).ReadBody(thingReader));
            }
            else if (type == typeof(Type))
            {
                Trace.Assert(hintType == null || typeof(Type).IsAssignableFrom(hintType));
                return(thingReaderWriterContainer.Get(type).ReadBody(thingReader));
            }
            else if (integerTypes.Contains(type))
            {
                var value = thingReaderWriterContainer.Get(type).ReadBody(thingReader);
                if (hintType == null)
                {
                    return(value);
                }
                else if (hintType.IsEnum)
                {
                    return(Convert.ChangeType(value, Enum.GetUnderlyingType(hintType)));
                }
                else
                {
                    return(Convert.ChangeType(value, hintType));
                }
            }

            if (hintType != null)
            {
                var simplifiedType = TypeSimplifier.SimplifyType(hintType);

                if (type == simplifiedType)
                {
                    type = hintType;
                }
                else if (!hintType.IsAssignableFrom(type))
                {
                    logger.Error($"Unable to convert from {type.FullName} to hinted {hintType.FullName}.");
                    throw new InvalidStateException();
                }
            }
            return(thingReaderWriterContainer.Get(type).ReadBody(thingReader));
        }
예제 #17
0
파일: Markdown.cs 프로젝트: Quahu/Disqord
        public static string Escape(ReadOnlySpan <char> text)
        {
            var builder = new StringBuilder(text.Length);

            for (var i = 0; i < text.Length; i++)
            {
                var character = text[i];
                if (EscapedCharacters.Contains(character))
                {
                    builder.Append('\\');
                }

                builder.Append(character);
            }

            return(builder.ToString());
        }
예제 #18
0
 static void CheckMemberAndTypeParams(Type t, string groupDesc)
 {
     if (t.IsEnum)
     {
         return;
     }
     if (t.IsConstructedGenericType)
     {
         CheckMemberAndTypeParams(t.GetGenericTypeDefinition(), groupDesc);
         foreach (var typeParam in t.GenericTypeArguments)
         {
             CheckMemberAndTypeParams(typeParam, groupDesc);
         }
         return;
     }
     Assert.IsTrue(KnownGoodFromStdlib.Contains(t) || KnownGoodFromBizHawk.ContainsKey(t), $"type {t.FullName}, present in {groupDesc}, may not be serializable");
 }
예제 #19
0
        /// <summary>
        /// Reads content of a source file.
        /// </summary>
        /// <param name="file">Source file information.</param>
        /// <param name="diagnostics">Storage for diagnostics.</param>
        /// <param name="normalizedFilePath">If given <paramref name="file"/> opens successfully, set to normalized absolute path of the file, null otherwise.</param>
        /// <returns>File content or null on failure.</returns>
        internal SourceText TryReadFileContent(CommandLineSourceFile file, IList <DiagnosticInfo> diagnostics, out string normalizedFilePath)
        {
            var filePath = file.Path;

            try
            {
                using (var data = OpenFileForReadWithSmallBufferOptimization(filePath))
                {
                    normalizedFilePath = (string)PortableShim.FileStream.Name.GetValue(data);
                    return(EncodedStringText.Create(data, Arguments.Encoding, Arguments.ChecksumAlgorithm, canBeEmbedded: EmbeddedSourcePaths.Contains(file.Path)));
                }
            }
            catch (Exception e)
            {
                diagnostics.Add(ToFileReadDiagnostics(this.MessageProvider, e, filePath));
                normalizedFilePath = null;
                return(null);
            }
        }
예제 #20
0
        /// <summary>
        /// </summary>
        /// <param name="fullName">The full name of the format.</param>
        /// <param name="shortName">The short name of the format.</param>
        public ImageFormat(
            string fullName,
            string shortName,
            string primaryMimeType,
            string primaryExtension,
            IReadOnlySet <string> mimeTypes,
            IReadOnlySet <string> extensions)
        {
            FullName  = fullName ?? throw new ArgumentNullException(nameof(fullName));
            ShortName = shortName ?? throw new ArgumentNullException(nameof(shortName));
            MimeType  = primaryMimeType ?? throw new ArgumentNullException(nameof(primaryMimeType));
            Extension = ValidateExtension(primaryExtension) ?? throw new ArgumentNullException(nameof(primaryExtension));

            if (mimeTypes == null)
            {
                throw new ArgumentNullException(nameof(mimeTypes));
            }
            if (mimeTypes.Count == 0)
            {
                throw new ArgumentEmptyException(nameof(mimeTypes));
            }
            if (!mimeTypes.Contains(primaryMimeType))
            {
                throw new ArgumentException("The set doesn't contain the primary MIME type.", nameof(mimeTypes));
            }

            if (extensions == null)
            {
                throw new ArgumentNullException(nameof(extensions));
            }
            if (extensions.Count == 0)
            {
                throw new ArgumentEmptyException(nameof(extensions));
            }
            if (!extensions.Contains(primaryExtension))
            {
                throw new ArgumentException("The set doesn't contain the primary extension.", nameof(mimeTypes));
            }

            MimeTypes  = new ReadOnlySet <string>(mimeTypes, StringComparer.OrdinalIgnoreCase);
            Extensions = new ReadOnlySet <string>(extensions, StringComparer.OrdinalIgnoreCase);
        }
        /// <inheritdoc />
        public void UpdateInterests(TInterest interest, IReadOnlySet <TKey> addTo, IReadOnlySet <TKey> removeFrom)
        {
            IInterestMapContracts.UpdateInterests(this, addTo, removeFrom);

            foreach (var key in addTo)
            {
                if (!removeFrom.Contains(key))
                {
                    this.AddInterest(key, interest);
                }
            }

            foreach (var key in removeFrom)
            {
                if (!addTo.Contains(key))
                {
                    this.RemoveInterest(key, interest);
                }
            }
        }
예제 #22
0
            public Builder SortValue <TField, TSortEntity, TSortValue>
            (
                Expression <Func <TEntity, TField> > fieldSelector,
                DbSet <TSortEntity> sortEntities,
                Expression <Func <TSortEntity, TField> > sortEntityKeySelector,
                Expression <Func <TSortEntity, TSortValue> > sortEntityValueSelector
            ) where TSortEntity : class
            {
                var field = fieldSelector.GetImmediatePropertyName();
                var sortEntityKeyPropertyName   = sortEntityKeySelector.GetImmediatePropertyName();
                var sortEntityValuePropertyName = sortEntityValueSelector.GetImmediatePropertyName();

                if (!NumericTypes.Contains(typeof(TSortValue)))
                {
                    throw new ArgumentException($"Sort value selector must select a numeric property (not {sortEntityValuePropertyName} of type {typeof(TSortValue).FullName})", nameof(sortEntityValueSelector));
                }

                _sortValueJoinInfos.Add(new SortValueJoinInfo(field, sortEntities, sortEntityKeyPropertyName, sortEntityValuePropertyName));

                return(this);
            }
예제 #23
0
        private static HashSet <Point4D> HyperCycle(IReadOnlySet <Point4D> state)
        {
            var newState = new HashSet <Point4D>();

            foreach (var thisHyperCube in ActiveHyperCubesAndNeighbours(state))
            {
                var neighbours       = HyperNeighbours(thisHyperCube);
                var activeNeighbours = neighbours.Count(state.Contains);
                if (!state.Contains(thisHyperCube))
                {
                    if (activeNeighbours == 3)
                    {
                        newState.Add(thisHyperCube);
                    }
                }
                else if (activeNeighbours == 2 || activeNeighbours == 3)
                {
                    newState.Add(thisHyperCube);
                }
            }
            return(newState);
        }
예제 #24
0
        private void ValidateTypeExistsInChangeLog(string resourceName, ApiVersion version, Type type, IReadOnlySet <Type> typesToSearch, bool addMissingResources = true)
        {
            if (!typesToSearch.Contains(type))
            {
                if (addMissingResources)
                {
                    AddMissingResource(version, type);
                }
                else
                {
                    // FIXME: localize
                    var message = string.Format("Resource '{0}' binds type '{1}', but this type was not found in the change log. Did you forget to add it?", resourceName, type.Name);
                    throw new ChangeLogException(message);
                }
            }

            var members = AccessorMembers.Create(type, AccessorMemberTypes.Properties, AccessorMemberScope.Public);

            foreach (var member in members)
            {
                if (typeof(IResource).IsAssignableFrom(member.Type))
                {
                    ValidateTypeExistsInChangeLog(resourceName, version, member.Type, typesToSearch, addMissingResources);
                }

                if (member.Type.ImplementsGeneric(typeof(IEnumerable <>)) && member.Type.IsGenericType)
                {
                    var arguments      = member.Type.GetGenericArguments();
                    var underlyingType = arguments[0];
                    if (typeof(IResource).IsAssignableFrom(underlyingType))
                    {
                        ValidateTypeExistsInChangeLog(resourceName, version, underlyingType, typesToSearch, addMissingResources);
                    }
                }
            }
        }
예제 #25
0
        private static List <Pair> BruteColor(HashSet <Pair> pairs, IReadOnlySet <Restriction> restrictions)
        {
            List <Pair> pairs1 = new();

            pairs1.AddRange(pairs);
            for (int i = 0; i < pairs1.Count; i++)
            {
                for (int j = i + 1; j < pairs1.Count; j++)
                {
                    for (int k = j + 1; k < pairs1.Count; k++)
                    {
                        for (int l = k + 1; l < pairs1.Count; l++)
                        {
                            if (pairs1[i].Variable == pairs1[j].Variable ||
                                pairs1[i].Variable == pairs1[k].Variable ||
                                pairs1[i].Variable == pairs1[l].Variable ||
                                pairs1[j].Variable == pairs1[k].Variable ||
                                pairs1[j].Variable == pairs1[l].Variable ||
                                pairs1[k].Variable == pairs1[l].Variable)
                            {
                                continue;
                            }

                            if (restrictions.Contains(new Restriction(pairs1[i], pairs1[j])) ||
                                restrictions.Contains(new Restriction(pairs1[i], pairs1[k])) ||
                                restrictions.Contains(new Restriction(pairs1[i], pairs1[l])) ||
                                restrictions.Contains(new Restriction(pairs1[j], pairs1[k])) ||
                                restrictions.Contains(new Restriction(pairs1[j], pairs1[l])) ||
                                restrictions.Contains(new Restriction(pairs1[k], pairs1[l])))
                            {
                                continue;
                            }

                            return(new() { pairs1[i], pairs1[j], pairs1[k], pairs1[l] });
                        }
                    }
                }
            }
            return(null);
        }
 private bool IsSpecDirty(AbsolutePath path)
 {
     return(m_dirtySpecs == null || m_dirtySpecs.Contains(path));
 }
예제 #27
0
    public PublisherViewModel(LeagueYear leagueYear, Publisher publisher, LocalDate currentDate, Publisher?nextDraftPublisher,
                              bool userIsInLeague, bool outstandingInvite, SystemWideValues systemWideValues, IReadOnlySet <Guid> counterPickedPublisherGameIDs)
    {
        PublisherID   = publisher.PublisherID;
        LeagueID      = leagueYear.League.LeagueID;
        UserID        = publisher.User.Id;
        PublisherName = publisher.PublisherName;
        PublisherIcon = publisher.PublisherIcon;
        LeagueName    = leagueYear.League.LeagueName;
        PlayerName    = publisher.User.UserName;
        Year          = leagueYear.Year;
        DraftPosition = publisher.DraftPosition;
        AutoDraft     = publisher.AutoDraft;

        Games = publisher.PublisherGames
                .OrderBy(x => x.Timestamp)
                .Select(x => new PublisherGameViewModel(x, currentDate, counterPickedPublisherGameIDs.Contains(x.PublisherGameID), leagueYear.Options.CounterPicksBlockDrops))
                .ToList();
        FormerGames = publisher.FormerPublisherGames
                      .OrderBy(x => x.PublisherGame.Timestamp)
                      .Select(x => new PublisherGameViewModel(x, currentDate))
                      .ToList();
        GameSlots = publisher.GetPublisherSlots(leagueYear.Options)
                    .Select(x => new PublisherSlotViewModel(x, currentDate, leagueYear, systemWideValues, counterPickedPublisherGameIDs))
                    .ToList();

        AverageCriticScore   = publisher.AverageCriticScore;
        TotalFantasyPoints   = publisher.GetTotalFantasyPoints(leagueYear.SupportedYear, leagueYear.Options);
        TotalProjectedPoints = publisher.GetProjectedFantasyPoints(leagueYear, systemWideValues, currentDate);
        Budget = publisher.Budget;

        if (nextDraftPublisher is not null && nextDraftPublisher.PublisherID == publisher.PublisherID)
        {
            NextToDraft = true;
        }

        UserIsInLeague    = userIsInLeague;
        PublicLeague      = leagueYear.Options.PublicLeague;
        OutstandingInvite = outstandingInvite;

        var dateToCheck = currentDate;

        if (leagueYear.SupportedYear.Finished)
        {
            dateToCheck = new LocalDate(Year, 12, 31);
        }

        GamesReleased = publisher.PublisherGames
                        .Where(x => !x.CounterPick)
                        .Where(x => x.MasterGame is not null)
                        .Count(x => x.MasterGame !.MasterGame.IsReleased(dateToCheck));
        var allWillRelease = publisher.PublisherGames
                             .Where(x => !x.CounterPick)
                             .Where(x => x.MasterGame is not null)
                             .Count(x => x.WillRelease());

        GamesWillRelease = allWillRelease - GamesReleased;

        FreeGamesDropped             = publisher.FreeGamesDropped;
        WillNotReleaseGamesDropped   = publisher.WillNotReleaseGamesDropped;
        WillReleaseGamesDropped      = publisher.WillReleaseGamesDropped;
        FreeDroppableGames           = leagueYear.Options.FreeDroppableGames;
        WillNotReleaseDroppableGames = leagueYear.Options.WillNotReleaseDroppableGames;
        WillReleaseDroppableGames    = leagueYear.Options.WillReleaseDroppableGames;
    }
예제 #28
0
 private static bool AllChildrenParsed(Bag bag, IReadOnlySet <string> parsedBags)
 {
     return(bag.Bags.All(b => parsedBags.Contains(b.Item1.Colour)));
 }
예제 #29
0
 public IEnumerable <IModListingGetter> Get(IReadOnlySet <ModKey> blacklisted)
 {
     return(_profileLoadOrderProvider.Get()
            .Where(x => !blacklisted.Contains(x.ModKey)));
 }
예제 #30
0
        private Task <bool> EvaluateAllFilesAsync(IReadOnlySet <AbsolutePath> evaluationGoals, QualifierId qualifierId)
        {
            Contract.Assert(m_msBuildWorkspaceResolver.ComputedProjectGraph.Succeeded);

            ProjectGraphResult result = m_msBuildWorkspaceResolver.ComputedProjectGraph.Result;

            GlobalProperties qualifier = MsBuildResolverUtils.CreateQualifierAsGlobalProperties(qualifierId, m_context);

            IReadOnlySet <ProjectWithPredictions> filteredBuildFiles = result.ProjectGraph.ProjectNodes
                                                                       .Where(project => evaluationGoals.Contains(project.FullPath))
                                                                       .Where(project => ProjectMatchesQualifier(project, qualifier))
                                                                       .ToReadOnlySet();

            var graphConstructor = new PipGraphConstructor(m_context, m_host, result.ModuleDefinition, m_msBuildResolverSettings, result.MsBuildExeLocation, m_frontEndName);

            return(graphConstructor.TrySchedulePipsForFilesAsync(filteredBuildFiles, qualifierId));
        }