Esempio n. 1
0
        public override bool Execute(ScriptInterface bot, int required)
        {
            if (Map != null)
            {
                bot.Strategy.GetNavigator(Map).Navigate(bot);
            }

            bot.Shops.Load(ShopID);

            MergeItem merge = bot.Shops.MergeItems.Find(x => x.Name.Equals(Item, StringComparison.OrdinalIgnoreCase));

            if (merge == null)
            {
                return(false);
            }
            while (!bot.Inventory.Contains(Item, required))
            {
                foreach (ItemBase item in merge.Requirements)
                {
                    if (!bot.Strategy.Obtain(item.Name, item.Quantity))
                    {
                        return(false);
                    }
                }
                bot.Shops.BuyItem(merge.Name);
            }

            return(bot.Inventory.Contains(Item, required));
        }
Esempio n. 2
0
    private static void DisplayMergeItem(ref MergeItem item, string message)
    {
        if (!string.IsNullOrEmpty(item.path))
        {
            GUILayout.Label(item.path);
        }

        if (GUILayout.Button(message))
        {
            var path = LocalizationEditorUtils.GetFilePathFromUser("Select a localisation data file");
            if (!string.IsNullOrEmpty(path))
            {
                string jsonData = File.ReadAllText(path);
                item.data = JsonUtility.FromJson <LocalizationData>(jsonData);
                LocalizationEditorUtils.LastPath = path;
                if (LocalizationEditorUtils.IsDataInvalid(item.data))
                {
                    LocalizationEditorUtils.OnError("Couldn't read data from provided file! Please provide a valid file");
                }
                else
                {
                    item.path = path;
                    LocalizationEditorUtils.LastPath = path;
                }
            }
        }

        GUILayout.Space(50.0f);
    }
Esempio n. 3
0
        private void ListMI(MergeItem mi)
        {
            logMsgDbLn2("");

            if (mi.depth == 0)
            {
                logMsgDbLn2("modify| depth is", "zero / root");
            }

            if (mi.bookmarkType == bookmarkType.LEAF)
            {
                logMsgDbLn2("modify| item is", "LEAF");
                logMsgDbLn2("modify| path", mi.fileItem.outlinePath);
            }
            else if (mi.bookmarkType == bookmarkType.BRANCH)
            {
                logMsgDbLn2("modify| item is", "BRANCH");
            }
            else
            {
                logMsgDbLn2("modify| item is", "INVALID");
                return;
            }

            logMsgDbLn2("modify| bktitle", mi.bookmarkTitle);
        }
Esempio n. 4
0
 private void MergeCore(MergeItem item, MergeItem otherItem)
 {
     item.Children.UnionWith(otherItem.Children);
     item.Platform.UnionWith(otherItem.Platform);
     MergeMinorItems(item, otherItem);
     MergeReferences(item, otherItem);
 }
Esempio n. 5
0
        public void CodeMergeItemWithSpaciliseShallPerformAnAdditionalSubstitutionOnSpacilisedInputAndMergeItems()
        {
            //Setup
            var inputCode          = @"public string somethingElse SomethingElse { get; set; }";
            var expectedOutputCode = @"public string nameMe NameMe { get; set; }";

            var swapValue = "SomethingElse";
            var mergeItem = new MergeItem
            {
                MergeParings = new List <MergePairing>
                {
                    new MergePairing {
                        SwapValue = swapValue, InputValue = "NameMe"
                    }
                }
            };

            //var mergeItem = new MergeItem { SwapValue = "SomethingElse", MergeParings = new List<string> { "NameMe" } };

            var mergeOptions = new MergeOptions {
                CameliseSubstitutionAlso = true
            };

            //Exercise
            var actualCodeOutput = MergeHelper.MergeItem(inputCode, mergeItem, mergeOptions);

            //Verify
            Assert.AreEqual(expectedOutputCode, actualCodeOutput, "The actual code output is not what was expected: " + actualCodeOutput);
        }
Esempio n. 6
0
        private PageViewModel ConvertToVM(MergeItem mergeItem)
        {
            var vm = new PageViewModel
            {
                Items      = new List <ItemViewModel>(),
                References = mergeItem.References?.Values.ToList(),
                Metadata   = mergeItem.Metadata,
            };

            ConvertToVMCore(vm, mergeItem);
            return(vm);
        }
Esempio n. 7
0
 private void MergeReferences(MergeItem item, MergeItem otherItem)
 {
     if (item.References != null)
     {
         if (otherItem.References != null)
         {
             MergeReferencesCore(item.References, otherItem.References);
         }
     }
     else if (otherItem.References != null)
     {
         item.References = otherItem.References;
     }
 }
Esempio n. 8
0
 private void MergeMinorItems(MergeItem item, MergeItem otherItem)
 {
     if (item.MinorItems != null)
     {
         if (otherItem.MinorItems != null)
         {
             MergeMinorItemsCore(item.MinorItems, otherItem.MinorItems);
         }
     }
     else if (otherItem.MinorItems != null)
     {
         item.MinorItems = otherItem.MinorItems;
     }
 }
        public HttpResponseMessage MergeItem(MergeItem mergeItemRequest)
        {
            // Trace Log
            File.AppendAllText(SuiteWrapper.traceLogPath, Environment.NewLine + Environment.NewLine);
            SuiteWrapper.WriteTraceLog("Called 'MergeItem' with request :" + JsonConvert.SerializeObject(mergeItemRequest));
            var    sessionId     = "0";
            string outputMessage = string.Empty;

            if (!SuiteWrapper.ValidateRequest(mergeItemRequest, out outputMessage))
            {
                //Trace Log
                SuiteWrapper.WriteTraceLog("Exception while validating request for " + JsonConvert.SerializeObject(mergeItemRequest) + " is : " + outputMessage);
                return(Request.CreateResponse(HttpStatusCode.NotAcceptable, outputMessage));;
            }
            try
            {
                sessionId = SuiteWrapper.Login().GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                SuiteWrapper.WriteTraceLog("Exception while generating session id is " + ex.ToString());
                return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, ex.Message.ToString()));
            }

            PushResponseforSingleEntry pushResponseforSingleEntry = new PushResponseforSingleEntry();

            try
            {
                var req = new AddUpdateSingleEntryRequest();
                req.SessionId  = sessionId;
                req.ModuleName = "Itm1_Item";
                req.Entity     = mergeItemRequest;
                var response = SuiteWrapper.AddUpdateSingleEntry(req).GetAwaiter().GetResult();
                pushResponseforSingleEntry.Id     = response.Id;
                pushResponseforSingleEntry.Status = "Success";

                SuiteWrapper.WriteTraceLog("Successfully called with response:" + JsonConvert.SerializeObject(pushResponseforSingleEntry));
                return(Request.CreateResponse(HttpStatusCode.OK, pushResponseforSingleEntry));
            }
            catch (Exception ex)
            {
                pushResponseforSingleEntry.Id     = null;
                pushResponseforSingleEntry.Status = ex.Message.ToString();

                SuiteWrapper.WriteTraceLog("Exception while Pushing data is : " + ex.Message.ToString());
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, pushResponseforSingleEntry));
            }
        }
Esempio n. 10
0
        public static string MergeItem(string inputCode, MergeItem mergeItem, MergeOptions mergeOptions)
        {
            var output             = string.Empty;
            var substitutionOutput = string.Empty;

            foreach (var mergeParing in mergeItem.MergeParings)
            {
                var swapValue  = mergeParing.SwapValue;
                var inputValue = mergeParing.InputValue;

                if (inputValue != null && inputValue.Trim().Length > 0)
                {
                    substitutionOutput = inputCode.Replace(swapValue, inputValue);

                    //Perform the camel replacement if needed on the output code
                    if (mergeOptions.CameliseSubstitutionAlso)
                    {
                        //Camilise our text values
                        var swapValueCamelised  = swapValue.CameliseString();
                        var inputValueCamelised = mergeParing.InputValue.CameliseString();

                        if (inputValueCamelised != null && inputValue.Trim().Length > 0)
                        {
                            substitutionOutput = substitutionOutput.Replace(swapValueCamelised, inputValueCamelised);
                        }
                    }

                    //Perform the space replacement if needed on the output code
                    if (mergeOptions.SpaciliseSubstitutionAlso)
                    {
                        //Camilise our text values
                        var swapValueSpacilised  = swapValue.SpaciliseCapitals();
                        var inputValueSpacilised = mergeParing.InputValue.SpaciliseCapitals();

                        if (inputValueSpacilised != null && inputValueSpacilised.Trim().Length > 0)
                        {
                            substitutionOutput = substitutionOutput.Replace(swapValueSpacilised, inputValueSpacilised);
                        }
                    }
                }

                output += substitutionOutput;
            }

            return(output);
        }
Esempio n. 11
0
 private void ConvertToVMCore(PageViewModel vm, MergeItem mergeItem)
 {
     if (mergeItem.Children.Count > 0)
     {
         mergeItem.MajorItem.Children = mergeItem.Children.ToList();
     }
     if (mergeItem.Platform.Count > 0)
     {
         mergeItem.MajorItem.Platform = mergeItem.Platform.ToList();
     }
     vm.Items.Add(mergeItem.MajorItem);
     if (mergeItem.MinorItems != null)
     {
         foreach (var item in mergeItem.MinorItems.Values)
         {
             ConvertToVMCore(vm, item);
         }
     }
 }
Esempio n. 12
0
        public void CodeMergeItemWithDefaultOptionsShallSucceed()
        {
            //Setup
            var inputCode          = @"public string Something { get; set; }

";
            var expectedOutputCode = @"public string Name { get; set; }

public string Code { get; set; }

public string Description { get; set; }

";
            var swapValue          = "Something";
            var mergeItem          = new MergeItem
            {
                MergeParings = new List <MergePairing>
                {
                    new MergePairing {
                        SwapValue = swapValue, InputValue = "Name"
                    },
                    new MergePairing {
                        SwapValue = swapValue, InputValue = "Code"
                    },
                    new MergePairing {
                        SwapValue = swapValue, InputValue = "Description"
                    }
                }
            };


            var mergeOptions = new MergeOptions();//Default

            //Exercise
            var actualCodeOutput = MergeHelper.MergeItem(inputCode, mergeItem, mergeOptions);

            //Verify
            Assert.AreEqual(expectedOutputCode, actualCodeOutput, "The actual code output is not what was expected: " + actualCodeOutput);
        }
Esempio n. 13
0
        private void Merge()
        {
            //Setup
            string inputCode = this.txtInputCode.Text;

            var mergeItem = new MergeItem
            {
                MergeParings =
                    this.GetInputValues()
                    .Select(i => new MergePairing {
                    SwapValue = this.SwapValue, InputValue = i
                })
                    .ToList()
            };

            var mergeOptions = new MergeOptions {
                CameliseSubstitutionAlso = this.cbCamel.Checked, SpaciliseSubstitutionAlso = this.cbAddSpaces.Checked
            };

            //Exercise
            var actualCodeOutput = MergeHelper.MergeItem(inputCode, mergeItem, mergeOptions);

            this.txtOutputCode.Text = actualCodeOutput;
        }
 private void MergeReferences(MergeItem item, MergeItem otherItem)
 {
     if (item.References != null)
     {
         if (otherItem.References != null)
         {
             MergeReferencesCore(item.References, otherItem.References);
         }
     }
     else if (otherItem.References != null)
     {
         item.References = otherItem.References;
     }
 }
 private void ConvertToVMCore(PageViewModel vm, MergeItem mergeItem)
 {
     if (mergeItem.Children.Count > 0)
     {
         mergeItem.MajorItem.Children = mergeItem.Children.ToList();
     }
     if (mergeItem.Platform.Count > 0)
     {
         mergeItem.MajorItem.Platform = mergeItem.Platform.ToList();
     }
     vm.Items.Add(mergeItem.MajorItem);
     if (mergeItem.MinorItems != null)
     {
         foreach (var item in mergeItem.MinorItems.Values)
         {
             ConvertToVMCore(vm, item);
         }
     }
 }
 private PageViewModel ConvertToVM(MergeItem mergeItem)
 {
     var vm = new PageViewModel
     {
         Items = new List<ItemViewModel>(),
         References = mergeItem.References?.Values.ToList(),
         Metadata = mergeItem.Metadata,
     };
     ConvertToVMCore(vm, mergeItem);
     return vm;
 }
 private void MergeMinorItems(MergeItem item, MergeItem otherItem)
 {
     if (item.MinorItems != null)
     {
         if (otherItem.MinorItems != null)
         {
             MergeMinorItemsCore(item.MinorItems, otherItem.MinorItems);
         }
     }
     else if (otherItem.MinorItems != null)
     {
         item.MinorItems = otherItem.MinorItems;
     }
 }
 private void MergeCore(MergeItem item, MergeItem otherItem)
 {
     item.Children.UnionWith(otherItem.Children);
     item.Platform.UnionWith(otherItem.Platform);
     MergeMinorItems(item, otherItem);
     MergeReferences(item, otherItem);
 }