Пример #1
0
 public void BestesTopicSelektieren()
 {
     if (this._aktDatei == null)
     {
         this.AktAIMLTopic = null;
     }
     else if (!(this._aktDatei is AIMLDatei))
     {
         this.AktAIMLTopic = null;
     }
     else
     {
         AIMLDatei aIMLDatei = (AIMLDatei)this._aktDatei;
         IOrderedEnumerable <AIMLTopic> source = from t in aIMLDatei.getTopics()
                                                 orderby t.Name
                                                 select t;
         AIMLTopic zuletztInDieserDateiGewaehlesTopic = aIMLDatei.ZuletztInDieserDateiGewaehlesTopic;
         if (zuletztInDieserDateiGewaehlesTopic != null && source.Contains(zuletztInDieserDateiGewaehlesTopic))
         {
             this.AktAIMLTopic = zuletztInDieserDateiGewaehlesTopic;
         }
         else if (source.Count() == 0)
         {
             this.AktAIMLTopic = null;
         }
         else
         {
             this.AktAIMLTopic = source.First();
         }
     }
 }
Пример #2
0
 public void BestesTopicSelektieren()
 {
     if (this._aktDatei == null)
     {
         this.AktAIMLTopic = (AIMLTopic)null;
     }
     else if (!(this._aktDatei is AIMLDatei))
     {
         this.AktAIMLTopic = (AIMLTopic)null;
     }
     else
     {
         AIMLDatei aktDatei = (AIMLDatei)this._aktDatei;
         IOrderedEnumerable <AIMLTopic> source = aktDatei.getTopics().OrderBy <AIMLTopic, string>((Func <AIMLTopic, string>)(t => t.Name));
         AIMLTopic dateiGewaehlesTopic         = aktDatei.ZuletztInDieserDateiGewaehlesTopic;
         if (dateiGewaehlesTopic != null && source.Contains <AIMLTopic>(dateiGewaehlesTopic))
         {
             this.AktAIMLTopic = dateiGewaehlesTopic;
         }
         else
         {
             this.AktAIMLTopic = source.Count <AIMLTopic>() != 0 ? source.First <AIMLTopic>() : (AIMLTopic)null;
         }
     }
 }
Пример #3
0
        private Dictionary <string, decimal> GetDateAndRateFromExchangeRatesApi(IOrderedEnumerable <DateTime> sortedDates,
                                                                                string baseCurrency, string targetCurrency)
        {
            var resultDictionary = new Dictionary <string, decimal>();

            //For now using as hard coded url string.
            var request  = WebRequest.Create("https://api.exchangeratesapi.io/history?start_at=" + sortedDates.First().ToString("yyyy-MM-dd") + "&end_at=" + sortedDates.Last().ToString("yyyy-MM-dd") + "&base=" + baseCurrency + "&symbols=" + targetCurrency);
            var response = request.GetResponse();

            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                var json            = reader.ReadToEnd();
                var exchangeHistory = JsonConvert.DeserializeObject <ExchangeResponse>(json);

                foreach (var rate in exchangeHistory.Rates)
                {
                    if (sortedDates.Contains(DateTime.Parse(rate.Key)))
                    {
                        var x = rate.Value;
                        foreach (var y in x.Values)
                        {
                            resultDictionary.Add(rate.Key, y);
                        }
                    }
                }
            }
            return(resultDictionary);
        }
Пример #4
0
 private void CheckDestinationIsActuallyDeployed(string destination, IOrderedEnumerable <string> deployedScripts)
 {
     if (destination == null)
     {
         return;
     }
     if (!deployedScripts.Contains(destination))
     {
         throw new Exception(string.Format("Destination is not actually deployed: {0}.", destination));
     }
 }
Пример #5
0
        private static string GetDay1Part1(IOrderedEnumerable <int> expenseReport)
        {
            var result = string.Empty;

            foreach (var expense in expenseReport)
            {
                if (!expenseReport.Contains(2020 - expense))
                {
                    continue;
                }
                result = $"Part 1 = {(2020 - expense) *expense}";
                break;
            }

            return(result);
        }
        private ObjectViewItem GenerateListEntry(string name, int index, IOrderedEnumerable <string> sceneObjects, IOrderedEnumerable <string> gameConfigObjects, IOrderedEnumerable <string> stageConfigObjects)
        {
            bool _isScene       = sceneObjects.Contains(name);
            bool _isGameConfig  = gameConfigObjects.Contains(name);
            bool _isStageConfig = stageConfigObjects.Contains(name);
            var  lvc            = new ObjectViewItem()
            {
                Content           = name,
                ObjectName        = name,
                IsChecked         = false,
                Tag               = index.ToString(),
                Obj_IsScene       = _isScene,
                Obj_IsGameConfig  = _isGameConfig,
                Obj_IsStageConfig = _isStageConfig
            };

            lvc.Checked += ObjectsList_ItemChecked;

            //if (!lvc.Obj_IsStageConfig) lvc.Foreground = Methods.Internal.Theming.GetSCBResource("Maniac_ObjectManager_RedTextColor");
            //else if (lvc.Obj_IsScene) lvc.Foreground = Methods.Internal.Theming.GetSCBResource("Maniac_ObjectManager_GreenTextColor");
            //else lvc.Foreground = Methods.Internal.Theming.GetSCBResource("NormalText");

            return(lvc);
        }
Пример #7
0
        private static void ExecuteSetParent(BoneViewModel target)
        {
            IOrderedEnumerable <RigResource.RigResource.Bone> descendants = target.Manager.GetDescendants(target.Bone).OrderBy(x => x.Name);
            List <RigResource.RigResource.Bone> choices = target.Manager.Bones.Where(x => x != target.Bone && !descendants.Contains(x)).ToList();

            choices.Sort((x, y) => x.Name.CompareTo(y.Name));
            var  dialog = new BoneSelectDialog(choices, "Select a New Parent...");
            bool result = dialog.ShowDialog() ?? false;

            if (result)
            {
                target.Manager.SetParent(target.Bone, dialog.SelectedBone);
            }
        }
 private static bool IsParent(int id, IOrderedEnumerable <int> parentIds)
 {
     return(parentIds.Contains(id));
 }
Пример #9
0
        public List <ItemIndex> sortItems(List <ItemIndex> itemList, Inventory inventory, String sortOrder)
        {
            IOrderedEnumerable <ItemIndex> finalOrder = itemList.OrderBy(a => 1);

            foreach (char c in sortOrder.ToCharArray())
            {
                switch (c)
                {
                case '0':     // Tier Ascending
                    finalOrder = finalOrder.ThenBy(item => mod.config.SortingTierOrder[(int)ItemCatalog.GetItemDef(item).tier]);
                    break;

                case '1':     // Tier Descending
                    finalOrder = finalOrder.ThenByDescending(item => mod.config.SortingTierOrder[(int)ItemCatalog.GetItemDef(item).tier]);
                    break;

                case '2':     // Stack Size Ascending
                    finalOrder = finalOrder.ThenBy(item => inventory.itemStacks[(int)item]);
                    break;

                case '3':     // Stack Size Descending
                    finalOrder = finalOrder.ThenByDescending(item => inventory.itemStacks[(int)item]);
                    break;

                case '4':     // Pickup Order
                    finalOrder = finalOrder.ThenBy(item => inventory.itemAcquisitionOrder.IndexOf(item));
                    break;

                case '5':     // Pickup Order Reversed
                    finalOrder = finalOrder.ThenByDescending(item => inventory.itemAcquisitionOrder.IndexOf(item));
                    break;

                case '6':     // Alphabetical
                    finalOrder = finalOrder.ThenBy(item => Language.GetString(ItemCatalog.GetItemDef(item).nameToken));
                    break;

                case '7':     // Alphabetical Reversed
                    finalOrder = finalOrder.ThenByDescending(item => Language.GetString(ItemCatalog.GetItemDef(item).nameToken));
                    break;

                case '8':     // Random"
                    Random random = new Random();
                    finalOrder = finalOrder.ThenBy(item => random.Next());
                    break;

                case 'C':     // Special Command Centered
                    ItemDef firstItemDef = ItemCatalog.GetItemDef(finalOrder.First());
                    if (firstItemDef != null && mod.commandImprovements.lastItem[(int)firstItemDef.tier] != ItemIndex.None && finalOrder.Contains(mod.commandImprovements.lastItem[(int)firstItemDef.tier]))
                    {
                        int roundUp = (int)Math.Ceiling((double)finalOrder.Count() / 5) * 5;
                        int offset;
                        if (roundUp == 5)
                        {
                            offset = finalOrder.Count() / 2;
                        }
                        else if (roundUp % 10 == 0)
                        {
                            offset = (roundUp / 2) - 3;
                        }
                        else
                        {
                            offset = roundUp / 2;
                        }
                        List <ItemIndex> finalOrderList = finalOrder.ToList();
                        finalOrderList.Remove(mod.commandImprovements.lastItem[(int)firstItemDef.tier]);
                        finalOrderList.Insert(offset, mod.commandImprovements.lastItem[(int)firstItemDef.tier]);
                        finalOrder = finalOrderList.OrderBy(a => 1);
                    }
                    break;

                case 'i':     // ItemIndex Ascending
                    finalOrder = finalOrder.ThenBy(itemIndex => itemIndex);
                    break;

                case 'I':     // ItemIndex Ascending
                    finalOrder = finalOrder.ThenByDescending(itemIndex => itemIndex);
                    break;

                case 's':     // Scrap First
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.Scrap));
                    break;

                case 'S':     // Scrap Last
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).DoesNotContainTag(ItemTag.Scrap));
                    break;

                case 'd':     // Damage First
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.Damage));
                    break;

                case 'D':     // Damage Last
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).DoesNotContainTag(ItemTag.Damage));
                    break;

                case 'h':     // Healing First
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.Healing));
                    break;

                case 'H':     // Healing Last
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).DoesNotContainTag(ItemTag.Healing));
                    break;

                case 'u':     // Utility First
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.Utility));
                    break;

                case 'U':     // Utility Last
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).DoesNotContainTag(ItemTag.Utility));
                    break;

                case 'o':     // OnKillEffect First
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.OnKillEffect));
                    break;

                case 'O':     // OnKillEffect Last
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).DoesNotContainTag(ItemTag.OnKillEffect));
                    break;

                case 'e':     // EquipmentRelated First
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.EquipmentRelated));
                    break;

                case 'E':     // EquipmentRelated Last
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).DoesNotContainTag(ItemTag.EquipmentRelated));
                    break;

                case 'p':     // SprintRelated First
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.SprintRelated));
                    break;

                case 'P':     // SprintRelated Last
                    finalOrder = finalOrder.ThenByDescending(item => ItemCatalog.GetItemDef(item).DoesNotContainTag(ItemTag.SprintRelated));
                    break;
                }
            }
            return(finalOrder.ToList());
        }