public ActionResult Index()
        {
            List <Restaurant> topThree = MethodCalls.TopThree();

            ViewBag.topThree = topThree;
            return(View());
        }
        public ActionResult DeleteMessage(int id)
        {
            Restaurant rest = MethodCalls.GetRestById(id);

            ViewBag.restaurant = rest;
            return(PartialView("_DeleteMessage", rest));
        }
        public ActionResult Edit(int id)
        {
            Restaurant rest = MethodCalls.GetRestById(id);

            ViewBag.rest = rest;
            return(View("Update"));
        }
Esempio n. 4
0
        public async Task ReceiveMessage(WebSocketMessage msg)
        {
            if (onMessageReceived != null)
            {
                await onMessageReceived(msg);
            }

            if (MethodCalls != null)
            {
                var method = MethodCalls.SingleOrDefault(m => m.GetCustomAttribute <WebSocketCallAttribute>().Name == msg.Method);
                if (method != null)
                {
                    try
                    {
                        var instance = CallInstances.FirstOrDefault(c =>
                        {
                            return(c.GetType() == method.DeclaringType);
                        });
                        await(Task) method.Invoke(instance, new object[] { msg });
                    }
                    catch (Exception e)
                    {
                        if (logger != null)
                        {
                            await logger.LogError(e, $"An error occurated when trying to invoke {method.Name} WebSocketCall");
                        }
                    }
                }
            }
        }
Esempio n. 5
0
 public void UpdateCredentialsInVault(PasswordCredential credential)
 {
     MethodCalls.Add(
         new Tuple <string, IList <object> >("UpdateCredentialsInVault", new List <object> {
         credential
     }));
 }
        public ActionResult SearchBox(FormCollection form)
        {
            List <Restaurant> searchList = MethodCalls.SearchRestName(Request.Form["Search_Info"]);

            TempData["search"] = searchList;
            return(RedirectToAction("All"));
        }
        public override void VisitInvocationExpression(InvocationExpressionSyntax node)
        {
            IEnumerable <IdentifierNameSyntax> objectAndMethod = node.Expression.DescendantNodes()
                                                                 .OfType <IdentifierNameSyntax>()
                                                                 .TakeLast(2);

            if (objectAndMethod.Count() == 2)
            {
                // Assumption: for this analyser, assuming that variables are declared with a type (not var/base class/interface)
                IdentifierNameSyntax classIdentifier = objectAndMethod.First();
                SyntaxNode           declaration     = IdentifierDeclarationFinder.Find(classIdentifier);
                string className = declaration != null
                    ? declaration.ChildNodes().OfType <VariableDeclarationSyntax>().FirstOrDefault()?.Type.ToString()
                                   // no declaration was found, assume static method
                    : classIdentifier.Identifier.Text;

                MethodCalls.Add(new MethodCallHolder(className, node));
            }
            else
            {
                string className = node.Ancestors()
                                   .OfType <ClassDeclarationSyntax>()
                                   .FirstOrDefault()?
                                   .Identifier
                                   .Text;

                MethodCalls.Add(new MethodCallHolder(className, node));
            }

            base.VisitInvocationExpression(node);
        }
        public ActionResult SearchString(string sub)
        {
            List <Restaurant> newList = MethodCalls.SearchRestName(sub);

            ViewBag.restList = newList;
            return(RedirectToAction("All"));
        }
        public ActionResult Create(RestaurantReviews.Library.Reviews rev)
        {
            int restId = Int32.Parse(Request.Form["restId"]);

            rev.RestaurantId = restId;
            MethodCalls.AddReviewToDb(rev);
            return(View("Restaurant/Details"));
        }
        public void PrintRestaurantByNameTest()
        {
            MethodCalls.SetLibRest();
            int expected             = 1;
            List <Restaurant> test1  = MethodCalls.rest;
            List <Restaurant> actual = RestaurantReviews.Library.PrintRestaurant.PrintRestaurantByName(test1, "Shake Shack");

            Assert.AreEqual(expected, actual.Count());
        }
Esempio n. 11
0
 internal void MoveCallsFrom(Method other)
 {
     foreach (var methodCall in other.MethodCalls)
     {
         methodCall.Source = this;
         MethodCalls.Add(methodCall);
     }
     other.MethodCalls.Clear();
 }
        public void AvgRatingSortTest()
        {
            MethodCalls.SetLibRest();
            string            expected = "Martha's Bakery";
            List <Restaurant> test1    = MethodCalls.rest;
            List <Restaurant> actual   = RestaurantReviews.Library.Sort.AvgRatingSort(test1);

            Assert.AreEqual(expected, actual.ElementAt(0).Name);
        }
        public void StringSizeSortTest()
        {
            MethodCalls.SetLibRest();
            string            expected = "Wendy's";
            List <Restaurant> test1    = MethodCalls.rest;
            List <Restaurant> actual   = RestaurantReviews.Library.Sort.StringSizeSort(test1);

            Assert.AreEqual(expected, actual.ElementAt(0).Name);
        }
        public void AlphabeticalSortTest()
        {
            MethodCalls.SetLibRest();
            string            expected = "Applebee's";
            List <Restaurant> test1    = MethodCalls.rest;
            List <Restaurant> actual   = RestaurantReviews.Library.Sort.AlphabeticalSort(test1);

            Assert.AreEqual(expected, actual.ElementAt(0).Name);
        }
        public void PrintReviewsByIdTest()
        {
            MethodCalls.SetLibRest();
            int expected             = 3;
            List <Restaurant> test1  = MethodCalls.rest;
            List <Restaurant> actual = RestaurantReviews.Library.PrintRestaurant.PrintReviewsById(test1, 4);

            Assert.AreEqual(expected, actual.Count());
        }
Esempio n. 16
0
        public void LookupTest()
        {
            MethodCalls.SetLibRest();
            int expected             = 2;
            List <Restaurant> test1  = MethodCalls.rest;
            List <Restaurant> actual = RestaurantReviews.Library.Search.Lookup(test1, "ch");

            Assert.AreEqual(expected, actual.Count());
        }
Esempio n. 17
0
 public void Reset()
 {
     count = 0;
     MethodCalls.Clear();
     CreateObjectFail   = false;
     ActivateObjectFail = false;
     ValidateObjectFail = false;
     SuspendObjectFail  = false;
     DestroyObjectFail  = false;
 }
Esempio n. 18
0
        public void SetLibRestTest()
        {
            //Arrange
            int expected = 10;

            //Act
            MethodCalls.SetLibRest();
            List <Restaurant> actual = MethodCalls.rest;

            //Assert
            Assert.AreEqual(expected, actual.Count());
        }
Esempio n. 19
0
        public MethodCall GetMethodCall(string typeName, string targetName, string signature)
        {
            List <MethodCall> candidates = MethodCalls.Where(m => m.Target.TypeName == typeName && m.Target.Name == targetName).ToList();

            if (candidates.Count == 0)
            {
                return(null);
            }

            if (candidates.Count == 1)
            {
                return(candidates[0]);
            }

            return(candidates.FirstOrDefault(m => signature == null || m.Target.Signature == signature));
        }
Esempio n. 20
0
 public void LoadPlaylist(PlaylistItemCollection playlistItemCollection)
 {
     LoadPlaylistCallCount++;
     MethodCalls.Add("LoadPlaylist", playlistItemCollection);
 }
Esempio n. 21
0
        public void Analyse()
        {
            if (IsEmpty)
            {
                return;
            }
            if (Il2CppMethod != null)
            {
                if (!Il2CppMethod.VirtualAddress.HasValue)
                {
                    return;
                }

                X86DisassembleMode      mode         = Owner.AppModel.Image.Arch == "x64" ? X86DisassembleMode.Bit64 : X86DisassembleMode.Bit32;
                CapstoneX86Disassembler disassembler = CapstoneDisassembler.CreateX86Disassembler(mode);
                disassembler.EnableInstructionDetails = true;

                var asm = disassembler.Disassemble(Il2CppMethod.GetMethodBody(), (long)Il2CppMethod.VirtualAddress.Value.Start);
                foreach (X86Instruction ins in asm)
                {
                    if (Dissasembler.ShouldCheckInstruction(ins.Id))
                    {
                        UnitorMethod m = Dissasembler.GetMethodFromInstruction(ins, Owner);
                        if (m != null)
                        {
                            MethodCalls.Add(m);
                            Owner.MethodReferences.AddOrUpdate(m, new List <UnitorMethod>(), (key, references) => { references.Add(this); return(references); });
                        }
                        var s = Dissasembler.GetStringFromInstruction(ins, Owner.StringTable);
                        if (!string.IsNullOrEmpty(s.Item2))
                        {
                            Strings.Add(new KeyValuePair <ulong, string>(s.Item1, s.Item2));
                        }
                    }
                }
                disassembler.Dispose();
            }
            else
            {
                if (!MonoMethod.HasBody)
                {
                    return;
                }

                foreach (Instruction ins in MonoMethod.Body.Instructions)
                {
                    if ((ins.OpCode.Code == Code.Call || ins.OpCode.Code == Code.Calli || ins.OpCode.Code == Code.Callvirt) && ins.Operand is MethodDef calledMethod)
                    {
                        if (Owner.MonoTypeMatches.TryGetValue(calledMethod.DeclaringType, out UnitorType type))
                        {
                            if (type.Methods == null)
                            {
                                continue;
                            }
                            UnitorMethod method = type.Methods.FirstOrDefault(m => calledMethod.Name == m.Name);
                            MethodCalls.Add(method);
                            Owner.MethodReferences.AddOrUpdate(method, new List <UnitorMethod>(), (key, references) => { references.Add(this); return(references); });
                        }
                    }
                    if (ins.OpCode.Code == Code.Ldstr && ins.Operand is string s)
                    {
                        Strings.Add(new KeyValuePair <ulong, string>((ulong)(MonoMethod.RVA + ins.Offset), s));
                    }
                }
            }
        }
Esempio n. 22
0
        public PasswordCredential GetCredentialsFromVault()
        {
            MethodCalls.Add(new Tuple <string, IList <object> >("GetCredentialsFromVault", new List <object>()));

            return(OnGetCredentialsFromVault != null?OnGetCredentialsFromVault() : new PasswordCredential());
        }
 public ActionResult Delete(int id)
 {
     MethodCalls.DeleteRev(id);
     return(RedirectToAction("All"));
 }
 public ActionResult Edit(Reviews rev)
 {
     MethodCalls.UpdateRev(rev);
     return(View());
 }
Esempio n. 25
0
        static void Main(string[] args)
        {
            int    x;
            bool   execute = true;
            string restName;

            MethodCalls.SetLibRest();
            Logger log = LogManager.GetCurrentClassLogger();

            log.Info("Starting application");
            while (execute)
            {
                Console.WriteLine("Press the number corresponding to the option you want:");
                Console.WriteLine("1. Display the top 3 restaurants by average rating.");
                Console.WriteLine("2. Display all restaurants.");
                Console.WriteLine("3. Display details of a restaurant.");
                Console.WriteLine("4. Display all the reviews of a restaurant");
                Console.WriteLine("5. Search for a restaurant.");
                Console.WriteLine("6. Quit Application");
                x = Convert.ToInt32(Console.ReadLine());
                while (x > 6 || x < 1)
                {
                    Console.WriteLine("That is an invalid input. Please try again: ");
                    x = Convert.ToInt32(Console.ReadKey());
                }
                switch (x)
                {
                case 1:
                {
                    MethodCalls.Topthree();
                    break;
                }

                case 2:
                {
                    Console.WriteLine("Press the number corresponding to the method of sorting the restaurants");
                    Console.WriteLine("1. Sort Alphabetically");
                    Console.WriteLine("2. Sort Reverse Alphabetically");
                    Console.WriteLine("3. Sort by size of restaurant name");
                    Console.WriteLine("4. Sort by Average Rating Descending");
                    x = Convert.ToInt32(Console.ReadLine());
                    while (x > 5 || x < 1)
                    {
                        Console.WriteLine("That is an invalid input. Please try again: ");
                        x = Convert.ToInt32(Console.ReadLine());
                    }
                    MethodCalls.chooseSort(x);
                    break;
                }

                case 3:
                {
                    Console.WriteLine("Choose the method of selecting a restaurant");
                    Console.WriteLine("1. By Name");
                    Console.WriteLine("2. By ID");
                    x = Convert.ToInt32(Console.ReadLine());
                    while (x > 2 || x < 1)
                    {
                        Console.WriteLine("That is an invalid input. Please try again: ");
                        x = Convert.ToInt32(Console.ReadLine());
                    }
                    if (x == 1)
                    {
                        Console.WriteLine("Enter the name of the restaurant");
                        restName = Console.ReadLine();
                        MethodCalls.returnRestByName(restName);
                    }
                    if (x == 2)
                    {
                        Console.WriteLine("Enter the ID of the restaurant");
                        x = Convert.ToInt32(Console.ReadLine());
                        MethodCalls.returnRestById(x);
                    }
                    break;
                }

                case 4:
                {
                    Console.WriteLine("Choose the method of selecting a restaurant");
                    Console.WriteLine("1. By Name");
                    Console.WriteLine("2. By ID");
                    x = Convert.ToInt32(Console.ReadLine());
                    while (x > 2 || x < 1)
                    {
                        Console.WriteLine("That is an invalid input. Please try again: ");
                        x = Convert.ToInt32(Console.ReadLine());
                    }
                    if (x == 1)
                    {
                        Console.WriteLine("Enter the name of the restaurant");
                        restName = Console.ReadLine();
                        MethodCalls.getReviewsByName(restName);
                    }
                    if (x == 2)
                    {
                        Console.WriteLine("Enter the ID of the restaurant");
                        x = Convert.ToInt32(Console.ReadLine());
                        MethodCalls.MCReviewsById(x);
                    }
                    break;
                }

                case 5:
                {
                    Console.WriteLine("Enter the string to search");
                    restName = Console.ReadLine();
                    MethodCalls.searchRestName(restName);
                    break;
                }

                case 6:
                {
                    log.Info(x);
                    execute = false;
                    break;
                }
                }
            }
        }
 public ActionResult Edit(Restaurant rest)
 {
     // TODO: Add update logic here
     MethodCalls.UpdateRest(rest);
     return(RedirectToAction("All"));
 }
 public RestaurantController()
 {
     MethodCalls.SetLibRest();
     restaurants = MethodCalls.rest;
     log         = LogManager.GetCurrentClassLogger();
 }