Beispiel #1
0
        public void Group()
        {
            lock (_groupingLock)
            {
                if (_hasGrouped)
                {
                    return;
                }

                _calls.Where(x => x.MessageType.IsConcrete())
                .GroupBy(x => x.MessageType)
                .Select(group => new HandlerChain(group))
                .Each(chain => { _chains = _chains.AddOrUpdate(chain.MessageType, chain); });

                _calls.Where(x => !x.MessageType.IsConcrete())
                .Each(call =>
                {
                    Chains
                    .Where(c => call.CouldHandleOtherMessageType(c.MessageType))
                    .Each(c => { c.AddAbstractedHandler(call); });
                });

                _hasGrouped = true;
            }
        }
Beispiel #2
0
        public List <TagViewModel> GetCommonTags()
        {
            if (SelectedEntries == null || SelectedEntries.Count() == 0)
            {
                return(new List <TagViewModel>());
            }

            var images = GetAllImages(SelectedEntries);

            if (images.Count() == 0)
            {
                return(new List <TagViewModel>());
            }

            var firstEntry = images.First();
            IEnumerable <TagViewModel> temp = Chains.Where(a => a.ImageID == firstEntry.ID).Select(a => a.Tag).ToList();

            foreach (var image in images)
            {
                IEnumerable <TagViewModel> tags = Chains.Where(a => a.ImageID == image.ID).Select(a => a.Tag).ToList();
                temp = temp.Intersect(tags).ToList();
            }

            return(temp.ToList());
        }
Beispiel #3
0
        public Rule(IEnumerable <Chain> chains, NonTerminalSymbol target)
        {
            if (chains == null)
            {
                throw new ArgumentNullException(nameof(chains));
            }

            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            Chains = chains.ToSortedSet().AsReadOnly();

            if (!Chains.Any())
            {
                throw new ArgumentException("Rule must contain at least one chain.");
            }

            if (Chains.AnyNull())
            {
                throw new ArgumentException("At least one null chain was found.");
            }

            Alphabet = Chains.SelectMany(chain => chain.Alphabet).ToSortedSet().AsReadOnly();
            Target   = target;
            ISet <NonTerminalSymbol> nonTerminals = Chains.SelectMany(chain => chain.NonTerminals).ToSortedSet();

            nonTerminals.Add(Target);
            NonTerminals = nonTerminals.AsReadOnly();
        }
Beispiel #4
0
 public void ParseInner(string message, bool hasRequestId)
 {
     foreach (var symbol in GetSymbols(message, hasRequestId))
     {
         Chains.Add(FutureSpread.Parse(symbol));
     }
 }
        public void ApplyCommand(IpTablesCommand command)
        {
            var chain = Chains.GetChain(command.ChainName, command.Table);

            switch (command.Type)
            {
            case IpTablesCommandType.Add:
                chain.AddRule(command.Rule);
                return;

            case IpTablesCommandType.Delete:
                chain.DeleteRule(command.Offset);
                return;

            case IpTablesCommandType.Replace:
                chain.ReplaceRule(command.Offset, command.Rule);
                return;

            case IpTablesCommandType.Insert:
                chain.InsertRule(command.Offset, command.Rule);
                return;
            }

            throw new IpTablesNetException("Unknown command");
        }
Beispiel #6
0
 private void RemoveChain(Chain chain)
 {
     if (Chains.Any(x => x.CurrentLocationHead == chain.CurrentLocationHead))
     {
         Chains.Dequeue();
     }
 }
Beispiel #7
0
        private void ChainDeeper(Node firstNode, Node secondNode)
        {
            ElementsChain chain = new ElementsChain();

            chain.AddNode(firstNode);                                                                               // Добавляем текущую ноду в цепь
            chain.AddNode(secondNode);                                                                              // Добавляем предыдущую ноду в цепь

            Node currentNode = secondNode;
            Node prevNode    = firstNode;

            while (currentNode.Connections.Count < 3)
            {
                if (currentNode.Connections.Count < 2)                                                              // Тупик
                {
                    return;
                }
                Node nextNode = currentNode.Connections.Keys.FirstOrDefault(i => i != prevNode);
                prevNode    = currentNode;                                                                                          // Переходим на следующую
                currentNode = nextNode;
                chain.AddNode(currentNode);                                                                                         // Записываем ноду в цепь
            }
            if (Chains.FirstOrDefault(i => i.Nodes.First() == chain.Nodes.Last() && i.Nodes.Last() == chain.Nodes.First()) == null) // Проверка на существующий путь
            {
                Chains.Add(chain);                                                                                                  // Добавляем цепь в список цепей
            }
        }
Beispiel #8
0
 private async void FistAndChain()
 {
     Log.Debug("starting combo");
     while (Config.FistAndComboKey.Value.Active)
     {
         var target = Selector.Active.GetTargets().FirstOrDefault();
         if (target != null)
         {
             if (Fist.CanBeCasted() && Fist.CanHit(target))
             {
                 Fist.UseAbility(target.Position);
                 Log.Debug("Fist usages");
                 await Task.Delay(25);
             }
             if (Chains.CanBeCasted())
             {
                 if (Me.Distance2D(target) <= 400)
                 {
                     Chains.UseAbility();
                     Log.Debug("Chains usages");
                     await Task.Delay(100);
                 }
             }
         }
         await Task.Delay(1);
     }
 }
 private void ParseInner(string message, bool hasRequestid)
 {
     foreach (var symbol in GetSymbols(message, hasRequestid))
     {
         Chains.Add(EquityOption.Parse(symbol));
     }
 }
Beispiel #10
0
 public async void AutoChainer()
 {
     while (Config.AutoChain.Value)
     {
         if (!Config.FistAndComboKey.Value.Active && !Config.RemntantCombo.Value.Active)
         {
             var target = Selector.Active.GetTargets().FirstOrDefault();
             if (target != null)
             {
                 var mod = Me.FindModifier("modifier_ember_spirit_sleight_of_fist_caster");
                 if (mod != null)
                 {
                     if (Chains.CanBeCasted())
                     {
                         if (Me.Distance2D(target) <= 400)
                         {
                             Chains.UseAbility();
                             Log.Debug("Auto Chains usages");
                             await Task.Delay(100);
                         }
                     }
                 }
             }
         }
         await Task.Delay(1);
     }
 }
    public void InitializeInterface(string interfaceName, IRuleCreationContext context)
    {
        var applicableRules = rules.Where(r => r.Condition(context)).ToList();

        var chains = new Chains(new ChainBuilder(context, applicableRules), chainRegistrations);

        interfaceMap[interfaceName] = chains;
    }
Beispiel #12
0
        public Rule Reorganize(IDictionary <NonTerminalSymbol, NonTerminalSymbol> map)
        {
            if (map == null)
            {
                throw new ArgumentNullException(nameof(map));
            }

            return(new Rule(Chains.Select(chain => chain.Reorganize(map)), map.ValueOrDefault(Target, Target)));
        }
 private void refreshChains()
 {
     _ignoreChainsChanges = true;
     Chains.Clear();
     foreach (var chain in NetworkArchitectureData.Chains)
     {
         Chains.Add(new ChainViewModel(chain, this));
     }
     _ignoreChainsChanges = false;
 }
Beispiel #14
0
        /// <summary>
        ///  Condition of adding new chain in queue
        /// </summary>
        /// <returns>Return true if we can/should add new chain </returns>
        private bool CheckToAdd()
        {
            if (!Chains.Any())
            {
                AddChain(new Chain());
            }
            var lastChain = Chains.Last();

            return(lastChain.CurrentLocationHead - lastChain.WholeLenghtOfChain > 0);
        }
        private void CalculateAllChains(IGraph graph)
        {
            // add resulting edges to set
            var result = new Chains {
                Directed = Directed
            }.Run(graph);

            // mark the resulting paths
            MarkPaths(result.Chains, markedSources, markedTargets);
        }
Beispiel #16
0
        public void ReportDroprates(List <DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
        {
            float personalDropRate = 1f;
            float dropRate         = 1f / dropIds.Length * (personalDropRate * ratesInfo.parentDroprateChance);

            for (int index = 0; index < dropIds.Length; ++index)
            {
                drops.Add(new DropRateInfo(dropIds[index], 1, 1, dropRate, ratesInfo.conditions));
            }
            Chains.ReportDroprates(ChainedRules, personalDropRate, drops, ratesInfo);
        }
Beispiel #17
0
        public bool Equals(Rule other)
        {
            if (other == null)
            {
                return(false);
            }

            return
                (Target.Equals(other.Target) &&
                 Chains.SequenceEqual(other.Chains));
        }
Beispiel #18
0
        private void CreateContours(double[,] points, double[] contourX, double[] contourY, double[] contourZ, int gridSize, int steps, ContourType contourType)
        {
            Dictionary <Vector2, List <Vector2> >[] contours = new Dictionary <Vector2, List <Vector2> > [contourZ.Length];

            for (int heightCount = 0; heightCount < contourZ.Length; ++heightCount) //Loop through the different Z height segments
            {
                contours[heightCount] = new Dictionary <Vector2, List <Vector2> >();
            }

            Conrec.Contour(points, contourX, contourY, contourZ, contours); //Get contours for the points. Returns an array of contours for the different heights.

            foreach (Dictionary <Vector2, List <Vector2> > contourList in contours)
            {
                List <List <Vector2> > contourChains = Chains.Process(contourList);
                contourChains = Chains.Simplify(contourChains);

                foreach (List <Vector2> chains in contourChains)
                {
                    List <OSMWayND>  wayPaths = new List <OSMWayND>();
                    List <OSMWayTag> wayTags  = new List <OSMWayTag>();

                    foreach (Vector2 node in chains)
                    {
                        osmNodes.Add(CreateNode(unindexedNodeOffset++, new Vector3((node.x - gridSize) - ((steps * gridSize) / 2), 0, (node.y - gridSize) - ((steps * gridSize) / 2))));
                        wayPaths.Add(new OSMWayND {
                            @ref = (uint)unindexedNodeOffset - 1
                        });
                    }

                    wayPaths.Add(new OSMWayND {
                        @ref = (uint)(unindexedNodeOffset - chains.Count)
                    });                                                                               //Back to the first chain

                    switch (contourType)
                    {
                    case ContourType.Ground:
                        wayTags.Add(new OSMWayTag {
                            k = "natural", v = "coastline"
                        });
                        break;

                    case ContourType.Water:
                        wayTags.Add(new OSMWayTag {
                            k = "natural", v = "water"
                        });
                        break;
                    }

                    osmWays.Add(new OSMWay {
                        changeset = 50000000, id = (uint)unindexedWayOffset++, timestamp = DateTime.Now, user = "******", nd = wayPaths.ToArray(), tag = wayTags.ToArray(), version = 1
                    });
                }
            }
        }
 protected bool Equals(DungeonGeneratorConfiguration <TNode> other)
 {
     return(RoomsCanTouch == other.RoomsCanTouch &&
            EarlyStopIfIterationsExceeded == other.EarlyStopIfIterationsExceeded &&
            Nullable.Equals(EarlyStopIfTimeExceeded, other.EarlyStopIfTimeExceeded) &&
            RepeatModeOverride == other.RepeatModeOverride &&
            ThrowIfRepeatModeNotSatisfied == other.ThrowIfRepeatModeNotSatisfied &&
            Equals(ChainDecompositionConfiguration, other.ChainDecompositionConfiguration) &&
            Chains.SequenceEqual(other.Chains) &&
            Equals(SimulatedAnnealingConfiguration, other.SimulatedAnnealingConfiguration) &&
            SimulatedAnnealingMaxBranching == other.SimulatedAnnealingMaxBranching);
 }
Beispiel #20
0
        public void ReportDroprates(List <DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
        {
            DropRateInfoChainFeed ratesInfo1 = ratesInfo.With(1f);

            ratesInfo1.AddCondition(new EModeDropCondition());
            ruleForEMode.ReportDroprates(drops, ratesInfo1);
            DropRateInfoChainFeed ratesInfo2 = ratesInfo.With(1f);

            ratesInfo2.AddCondition(new NotEModeDropCondition());
            ruleForDefault.ReportDroprates(drops, ratesInfo2);
            Chains.ReportDroprates(ChainedRules, 1f, drops, ratesInfo);
        }
Beispiel #21
0
        private void ChainsSerach()
        {
            Chains.Clear();                                                                                 // Очищаем списки

            foreach (Node node in Nodes.Where(node => node.Connections.Count > 2))                          // Для каждого узла
            {
                foreach (Node nextNode in node.Connections.Keys.Where(i => !i.Visited))                     // Для каждой непосещенной ноды из смежных
                {
                    ChainDeeper(node, nextNode);                                                            // Уходим вглубь
                }
            }
        }
        public override void ReportDroprates(List <DropRateInfo> drops, DropRateInfoChainFeed ratesInfo)
        {
            float chance        = chanceNumerator / (float)chanceDenominator;
            float inverseChance = 1f - chance;

            float finalChance = chance;                           //First roll could be a success

            finalChance += inverseChance * rerollChance * chance; //Other success is when first roll fails, reroll happens, and it rolls a success

            float dropRate = finalChance * ratesInfo.parentDroprateChance;

            drops.Add(new DropRateInfo(itemId, amountDroppedMinimum, amountDroppedMaximum, dropRate, ratesInfo.conditions));
            Chains.ReportDroprates(base.ChainedRules, finalChance, drops, ratesInfo);
        }
 public DungeonGeneratorConfiguration <TNode> SmartClone()
 {
     return(new DungeonGeneratorConfiguration <TNode>()
     {
         RoomsCanTouch = RoomsCanTouch,
         EarlyStopIfIterationsExceeded = EarlyStopIfIterationsExceeded,
         EarlyStopIfTimeExceeded = EarlyStopIfTimeExceeded,
         RepeatModeOverride = RepeatModeOverride,
         ThrowIfRepeatModeNotSatisfied = ThrowIfRepeatModeNotSatisfied,
         ChainDecompositionConfiguration = ChainDecompositionConfiguration.SmartClone(),
         Chains = Chains?.Select(x => new Chain <TNode>(x.Nodes.ToList(), x.Number)).ToList(),
         SimulatedAnnealingConfiguration = SimulatedAnnealingConfiguration.SmartClone(),
         SimulatedAnnealingMaxBranching = SimulatedAnnealingMaxBranching,
     });
 }
Beispiel #24
0
        /// <summary>
        /// Create a new Block in the Blockchain
        /// </summary>
        /// <param name="proof">The proof given by the Proof of Work algorithm</param>
        /// <param name="previousHash">Hash of previous Block</param>
        public Block NewBlock(int proof, string previousHash = null)
        {
            var block = new Block
            {
                Index        = Chains.Count + 1,
                Timestamp    = DateTime.Now.ToUnixTime(),
                Transactions = CurrentTransactions,
                Proof        = proof,
                PreviousHash = previousHash ?? Hash(LastBlock)
            };

            //Reset the current list of transactions
            CurrentTransactions = new List <Transaction>();
            Chains.Add(block);
            return(block);
        }
Beispiel #25
0
        public void RemoveByImage(ImageViewModel image)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image == null");
            }

            ImageTagFacade.DeleteWhereIDIs(image.ID);

            var removeList = Chains.Where(it => it.ImageID == image.ID).ToList();

            foreach (var remove in removeList)
            {
                Chains.Remove(remove);
            }
        }
Beispiel #26
0
        public int CompareTo(Rule other)
        {
            if (other == null)
            {
                return(1);
            }

            int result = Target.CompareTo(other.Target);

            if (result != 0)
            {
                return(result);
            }

            return(Chains.SequenceCompare(other.Chains));
        }
        public new GraphBasedGeneratorConfiguration <TNode> SmartClone()
        {
            return(new GraphBasedGeneratorConfiguration <TNode>()
            {
                RoomsCanTouch = RoomsCanTouch,
                EarlyStopIfIterationsExceeded = EarlyStopIfIterationsExceeded,
                EarlyStopIfTimeExceeded = EarlyStopIfTimeExceeded,
                RepeatModeOverride = RoomTemplateRepeatMode.NoImmediate,
                ThrowIfRepeatModeNotSatisfied = ThrowIfRepeatModeNotSatisfied,
                ChainDecompositionConfiguration = ChainDecompositionConfiguration.SmartClone(),
                Chains = Chains?.Select(x => new Chain <TNode>(x.Nodes.ToList(), x.Number)).ToList(),
                SimulatedAnnealingConfiguration = SimulatedAnnealingConfiguration.SmartClone(),
                SimulatedAnnealingMaxBranching = SimulatedAnnealingMaxBranching,

                OptimizeCorridorConstraints = OptimizeCorridorConstraints,
            });
        }
Beispiel #28
0
        public async Task <IActionResult> SaveChain(ChainViewModel data)
        {
            if (!ModelState.IsValid)
            {
                return(await Create(data));
            }

            var newChain = new Chains()
            {
                IdGroup   = data.IdGroup.Value,
                IsEnabled = true,
                Name      = data.Name
            };
            await _context.Chains.AddAsync(newChain);

            await _context.SaveChangesAsync();

            data.Id = newChain.Id;
            return(RedirectToAction(nameof(Edit), data));
        }
        static void Main(string[] _)
        {
            try
            {
                // Create a session into the platform
                using (ISession session = Configuration.Sessions.GetSession())
                {
                    if (session.Open() == Session.State.Opened)
                    {
                        IChainResponse response = Chains.Definition("0#.FCHI").GetData();

                        if (response.IsSuccess)
                        {
                            Console.WriteLine($"\nRetrieved Chain RIC: {response.Data.DisplayName}");

                            // Display the 30 first elements of the chain
                            int idx = 0;
                            foreach (string constituent in response.Data.Constituents.Take(30))
                            {
                                Console.WriteLine($"\t{++idx,2}. {constituent}");
                            }

                            if (response.Data.Constituents.Count > 30)
                            {
                                Console.WriteLine($"\t...\n\t<total of {response.Data.Constituents.Count} elements.>");
                            }
                        }
                        else
                        {
                            Console.WriteLine(response.Status);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************");
            }
        }
Beispiel #30
0
        private void ChangePosition(CRFGraph graph, int time)
        {
            //jedes proposal gleich wahrscheinlich
            var p      = (double)graph.Nodes.Count() / (graph.Data.NumberCategories + 2 * graph.Nodes.Count());
            var random = Random.NextDouble();

            if (random <= p)
            {
                CountTransitionNodeProposal++;
                ChangePositionNode(graph, time);
            }
            else if (random > p && random <= p * 2)
            {
                CountTransitionNeighborhoodProposal++;
                ChangePositionNeighborhood(graph, time);
            }
            else
            {
                CountTransitionCategoryProposal++;
                ChangePositionCategory(graph, time);
            }


            //out of perRun , collect sample for tests
            if (time > 0)
            {
                //get list of samples for current graph
                var samples = TestSamples[Chains.IndexOf(graph)];

                int[] sample = new int[graph.Nodes.Count()];
                foreach (var node in graph.Nodes)
                {
                    sample[node.GraphId] = node.Data.TempAssign;
                }

                samples.Add(sample);
            }
        }