Example #1
0
        public void OnApplicationStart()
        {
            Settings.Load();

            Type songLoaderType = Type.GetType("SongLoaderPlugin.SongLoader," +
                                               "SongLoaderPlugin," +
                                               "Version=1.0.0.0," +
                                               "Culture=neutral," +
                                               "PublicKeyToken=null");

            if (songLoaderType == null)
            {
                return;
            }

            MethodInfo getCustomSongInfoInfo = songLoaderType.GetMethod("GetCustomSongInfo",
                                                                        BindingFlags.NonPublic |
                                                                        BindingFlags.Instance);

            MethodInfo replacementInfo = typeof(Plugin).GetMethod(nameof(GetCustomSongInfoReplacement),
                                                                  BindingFlags.NonPublic |
                                                                  BindingFlags.Static);


            GetCustomSongInfoRedirection = new Redirection(getCustomSongInfoInfo, replacementInfo, true);

            SceneManager.activeSceneChanged += OnActiveSceneChanged;
        }
Example #2
0
        public static void DeleteRedirection(CMSDatabase db, int?itemID, HttpContext context, out bool successfullyCompleted)
        {
            if (itemID.HasValue)
            {
                Redirection redirection = db.Redirections.FirstOrDefault(r => r.ID == itemID);
                if (redirection == null)
                {
                    successfullyCompleted = false;
                    return;
                }
                db.Remove(redirection);
                db.SaveChanges();
                successfullyCompleted = true;

                LogManagementFunctions.AddAdminPanelLog(
                    db: db,
                    context: context,
                    info: $"{redirection.RequestPath} -> {redirection.RedirectionPath}: {(context.Items["LogLocalization"] as IAdminPanelLogLocalization)?.RedirectionDeleted}"
                    );
            }
            else
            {
                successfullyCompleted = false;
            }
        }
Example #3
0
        public void TestInstanceMethods()
        {
            MethodTests tests1 = new MethodTests {
                Value = 10
            };
            MethodTests tests2 = new MethodTests {
                Value = 10
            };

            tests1.Value.ShouldBe(tests2.Value);

            tests1.IncrementValue();

            using (Redirection redirection = Redirection.Redirect <Action>(IncrementValue, DecrementValue))
            {
                tests2.IncrementValue();

                tests1.Value.ShouldNotBe(tests2.Value);
                tests1.Value.ShouldBe(11);
                tests2.Value.ShouldBe(9);

                redirection.Stop();

                tests1.Value = tests2.Value = 0;

                tests1.IncrementValue();
                tests2.IncrementValue();

                tests1.Value.ShouldBe(tests2.Value);
                tests1.Value.ShouldBe(1);
                tests2.Value.ShouldBe(1);
            }
        }
        public void RedirectionController_Save_ValidRedirection_With_Rules()
        {
            var redirection = new Redirection {
                Name = "Test R", PortalId = Portal0, SortOrder = 1, SourceTabId = -1, IncludeChildTabs = true, Type = RedirectionType.Other, TargetType = TargetType.Portal, TargetValue = Portal1
            };

            redirection.MatchRules.Add(new MatchRule {
                Capability = "Platform", Expression = "IOS"
            });
            redirection.MatchRules.Add(new MatchRule {
                Capability = "Version", Expression = "5"
            });
            _redirectionController.Save(redirection);

            var dataReader    = _dataProvider.Object.GetRedirections(Portal0);
            var affectedCount = 0;

            while (dataReader.Read())
            {
                affectedCount++;
            }
            Assert.AreEqual(1, affectedCount);

            var getRe = _redirectionController.GetRedirectionsByPortal(Portal0)[0];

            Assert.AreEqual(2, getRe.MatchRules.Count);
        }
Example #5
0
        public ActionResult Index(string appName)
        {
            IEntityTypeManager typeManager = DependencyResolver.Current.GetService <IEntityTypeManager>();
            DbContext          context     = DependencyResolver.Current.GetService <DbContext>();
            IEnumerable <Type> typesInApp  = typeManager.GetTypesInNamespace(appName);
            //var a = context.GetType().GetProperties().Select(pi => pi.PropertyType);
            //var b = a.Where(t => t.IsGenericType && t.GetGenericTypeDefinition()==typeof(DbSet<>));
            //var c = b.Select(t => t.GetGenericArguments().Single());
            IEnumerable <Type> typesInContext = context.GetType().GetProperties().Select(pi => pi.PropertyType)
                                                .Where(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(DbSet <>)).Select(t => t.GetGenericArguments().Single());
            List <string> typeNames = typesInApp.Intersect(typesInContext).Select(t => t.Name).ToList();

            if (typeNames == null || !typeNames.Any())
            {
                Redirection redirection = Redirection.OpenRedirection(HttpContext, "ApplicationNotFound", "Error", new RouteValueDictionary()
                {
                    { "appName", appName }
                });
                return(redirection.GetResult());
            }
            TextInfo             ti      = CultureInfo.CurrentCulture.TextInfo;
            ApplicationDetailsVM details = new ApplicationDetailsVM
            {
                AppName   = ti.ToTitleCase(appName),
                TypeNames = typeNames
            };

            return(View(details));
        }
Example #6
0
        public void TestReactiveMethod()
        {
            MethodInfo method = typeof(DateTime)
                                .GetProperty(nameof(DateTime.Now), BindingFlags.Static | BindingFlags.Public)
                                .GetGetMethod();

            int      count = 0;
            DateTime bday  = new DateTime(1955, 10, 28);

            // Note: Observing this test through the debugger will call DateTime.Now,
            //       thus incrementing 'count', and breaking the test. Watch out.
            using (Redirection.Observe(method)
                   .Where(_ => count++ % 2 == 0)
                   .Subscribe(ctx => ctx.ReturnValue = bday))
            {
                DateTime.Now.ShouldBe(bday);
                DateTime.Now.ShouldNotBe(bday);
                DateTime.Now.ShouldBe(bday);
                DateTime.Now.ShouldNotBe(bday);
            }

            DateTime.Now.ShouldNotBe(bday);
            DateTime.Now.ShouldNotBe(bday);

            count.ShouldBe(4);
        }
Example #7
0
        public void TestInstanceMethodsWithParameters()
        {
            MethodTests tests1 = new MethodTests {
                Value = 10
            };
            MethodTests tests2 = new MethodTests {
                Value = 10
            };

            tests1.Value.ShouldBe(tests2.Value);

            tests1.IncrementValueBy(5);

            using (Redirection redirection = Redirection.Redirect <Action <int> >(IncrementValueBy, DecrementValueBy))
            {
                tests2.IncrementValueBy(5);

                tests1.Value.ShouldNotBe(tests2.Value);
                tests1.Value.ShouldBe(15);
                tests2.Value.ShouldBe(5);

                redirection.Stop();

                tests1.Value = tests2.Value = 0;

                tests1.IncrementValueBy(3);
                tests2.IncrementValueBy(3);

                tests1.Value.ShouldBe(tests2.Value);
                tests1.Value.ShouldBe(3);
                tests2.Value.ShouldBe(3);
            }
        }
Example #8
0
        private void MsgHandler_ClientJoin(Client client, ClientPacket msg)
        {
            byte seed = msg.ReadByte();

            byte[] key  = msg.Read(msg.ReadByte());
            string name = msg.ReadString(msg.ReadByte());
            uint   id   = msg.ReadUInt32();

            Encryption.Parameters encryptionParameters = new Encryption.Parameters(key, seed);

            if (ExpectedRedirects.ContainsKey(id) && (ExpectedRedirects[id] != null))
            {
                Redirection r = ExpectedRedirects[id];
                if ((r.Name == name) && r.EncryptionParameters.Matches(encryptionParameters))
                {
                    if (r.SourceServer == Program.LobbyServer || r.SourceServer is LoginServer)
                    {
                        var p = new ServerPacket(0x60);
                        p.WriteByte(0x00);
                        p.WriteUInt32(Notification.Checksum);
                        client.Enqueue(p);

                        var packet = new ServerPacket(0x6F);
                        packet.WriteByte(1);
                        packet.WriteUInt16((ushort)GameServer.MetafileDatabase.Count);
                        foreach (var kvp in GameServer.MetafileDatabase)
                        {
                            packet.WriteString8(kvp.Value.Name);
                            packet.WriteUInt32(kvp.Value.Checksum);
                        }
                        client.Enqueue(packet);
                    }
                }
            }
        }
Example #9
0
        private void SaveRedirection()
        {
            var redirection           = new Redirection();
            var redirectionController = new RedirectionController();

            redirection.Name        = (HomePageRedirectExists()) ? txtRedirectName.Text : Localization.GetString("DefaultRedirectName.Text", LocalResourceFile);
            redirection.Enabled     = true;
            redirection.PortalId    = ModuleContext.PortalId;
            redirection.SourceTabId = (cboSourcePage.Visible) ? cboSourcePage.SelectedItemValueAsInt : ModuleContext.PortalSettings.HomeTabId;

            redirection.Type       = RedirectionType.MobilePhone;
            redirection.TargetType = (TargetType)Enum.Parse(typeof(TargetType), optRedirectTarget.SelectedValue);

            switch (redirection.TargetType)
            {
            case TargetType.Portal:
                redirection.TargetValue = cboPortal.SelectedItem.Value;
                break;

            case TargetType.Tab:
                redirection.TargetValue = cboTargetPage.SelectedItemValueAsInt;
                break;

            case TargetType.Url:
                redirection.TargetValue = txtTargetUrl.Text;
                break;
            }

            // Save the redirect
            redirectionController.Save(redirection);
        }
 public static EventHandlerResponse Redirect(Redirection redirection)
 {
     return(new EventHandlerResponse
     {
         Action = EventHandlerResponseAction.Redirect,
         Redirection = redirection
     });
 }
        public static void PatchMethods()
        {
            MethodInfo didActivateInfo =
                typeof(MenuMasterViewController).GetMethod("DidActivate", BindingFlags.NonPublic | BindingFlags.Instance);
            MethodInfo didActivatePatch =
                typeof(MenuMasterViewControllerPatches).GetMethod(nameof(DidActivatePatch), BindingFlags.NonPublic | BindingFlags.Static);

            didActivateRedirection = new Redirection(didActivateInfo, didActivatePatch, true);
        }
Example #12
0
    public static void PatchMethods()
    {
        MethodInfo addEnergyInfo =
            typeof(GameEnergyCounter).GetMethod("AddEnergy", BindingFlags.Public | BindingFlags.Instance);
        MethodInfo addEnergyPatch =
            typeof(GameEnergyPatches).GetMethod(nameof(AddEnergyPatch), BindingFlags.NonPublic | BindingFlags.Static);

        addEnergyRedirection = new Redirection(addEnergyInfo, addEnergyPatch, true);
    }
        public void RedirectionUri(string uriPath, string rootParameter, string expectedUri)
        {
            var redirection = new Redirection {
                Uri = new Uri(BaseUriString + uriPath), Root = rootParameter
            };

            var uri = redirection.GetCalculatedUri();

            uri.ToString().Should().Be(BaseUriString + expectedUri);
        }
    //public bool xr, yr, zr; //use for debug

    void Awake()
    {
        shift       = new Vector3(0, 0, 0);
        preShift    = new Vector3(0, 0, 0);
        depth       = new Vector3(0, 0, 0);
        period      = new Vector3(0, 0, 0);
        posStart    = transform.localPosition;
        prePos      = transform.localPosition;
        redirection = new Redirection();
    }
Example #15
0
        public static void PatchMethods()
        {
            MethodInfo didActivateInfo = typeof(ResultsViewController).GetMethod("DidActivate", BindingFlags.NonPublic | BindingFlags.Instance);

            //Custom (Jumpman): I made it better by adding more patches yay

            MethodInfo didActivatePatch = typeof(ResultsViewControllerPatches).GetMethod(nameof(DidActivatePatch), BindingFlags.NonPublic | BindingFlags.Static);

            didActivateRedirection = new Redirection(didActivateInfo, didActivatePatch, true);
        }
Example #16
0
        public void TestStaticMethods()
        {
            Original().ShouldNotBe(Replacement());

            using (Redirection.Redirect <Func <bool> >(Original, Replacement))
            {
                Original().ShouldBe(Replacement());
            }

            Original().ShouldNotBe(Replacement());
        }
 public static void Init()
 {
     if (PassengerTrainAIMod._isDeployed)
     {
         return;
     }
     PassengerTrainAIMod._redirectionLoadPassengers   = new Redirection <PassengerTrainAI, PassengerTrainAIMod>("LoadPassengers");
     PassengerTrainAIMod._redirectionUnloadPassengers = new Redirection <PassengerTrainAI, PassengerTrainAIMod>("UnloadPassengers");
     PassengerTrainAIMod._redirectionCanLeave         = new Redirection <PassengerTrainAI, BusAIMod>("CanLeave");
     PassengerTrainAIMod._isDeployed = true;
 }
Example #18
0
        public void TestStaticMethodsWithParameters()
        {
            PlusOne(1).ShouldNotBe(PlusTwo(1));

            using (Redirection.Redirect <Func <int, int> >(PlusOne, PlusTwo))
            {
                PlusOne(1).ShouldBe(PlusTwo(1));
            }

            PlusOne(1).ShouldNotBe(PlusTwo(1));
        }
Example #19
0
        public static void PatchMethods()
        {
            MethodInfo MenuButtonPressedInfo = typeof(PauseMenuManager).GetMethod("MenuButtonPressed", BindingFlags.Public | BindingFlags.Instance);
            MethodInfo dualPatchInfo         = typeof(PauseMenuManagerPatches).GetMethod(nameof(MenuButtonPressedPatch), BindingFlags.Public | BindingFlags.Static);

            didMenuButtonRedirection = new Redirection(MenuButtonPressedInfo, dualPatchInfo, true);

            MethodInfo RestartButtonPressedInfo = typeof(PauseMenuManager).GetMethod("RestartButtonPressed", BindingFlags.Public | BindingFlags.Instance);
            MethodInfo RestartPatchInfo         = typeof(PauseMenuManagerPatches).GetMethod(nameof(RestartButtonPressedPatch), BindingFlags.Public | BindingFlags.Static);

            didRestartButtonRedirection = new Redirection(RestartButtonPressedInfo, RestartPatchInfo, true);
        }
Example #20
0
 public static void Init()
 {
     if (BusAIMod._isDeployed)
     {
         return;
     }
     BusAIMod.LoadPassengers             = (BusAIMod.LoadPassengersCallback)Utils.CreateDelegate <BusAI, BusAIMod.LoadPassengersCallback>("LoadPassengers", (object)null);
     BusAIMod.UnloadPassengers           = (BusAIMod.UnloadPassengersCallback)Utils.CreateDelegate <BusAI, BusAIMod.UnloadPassengersCallback>("UnloadPassengers", (object)null);
     BusAIMod._redirectionArriveAtTarget = new Redirection <BusAI, BusAIMod>("ArriveAtTarget");
     BusAIMod._redirectionCanLeave       = new Redirection <BusAI, BusAIMod>("CanLeave");
     BusAIMod._isDeployed = true;
 }
Example #21
0
    //public bool xr, yr, zr; //use for debug

    void Awake()
    {
        freqText    = GameObject.Find("InformationGUI").transform.Find("InformationGUI/FreqText").gameObject.GetComponent <Text>();
        depthText   = GameObject.Find("InformationGUI").transform.Find("InformationGUI/DepthText").gameObject.GetComponent <Text>();
        timeText    = GameObject.Find("InformationGUI").transform.Find("InformationGUI/TimeText").gameObject.GetComponent <Text>();
        shift       = new Vector3(0, 0, 0);
        preShift    = new Vector3(0, 0, 0);
        depth       = new Vector3(0, 0, 0);
        period      = new Vector3(0, 0, 0);
        posStart    = transform.localPosition;
        prePos      = transform.localPosition;
        redirection = new Redirection();
    }
 public static void Deinit()
 {
     if (!VehicleManagerMod._isDeployed)
     {
         return;
     }
     VehicleManagerMod.m_cachedVehicleData = (VehicleData[])null;
     VehicleManagerMod._redirection.Revert();
     VehicleManagerMod._redirection = (Redirection <VehicleManager, VehicleManagerMod>)null;
     VehicleManagerMod.ReleaseVehicleImplementation    = (VehicleManagerMod.ReleaseVehicleImplementationCallback)null;
     SerializableDataExtension.instance.EventSaveData -= new SerializableDataExtension.SaveDataEventHandler(VehicleManagerMod.OnSaveData);
     VehicleManagerMod._isDeployed = false;
 }
Example #23
0
        public void TestInvokeOriginal()
        {
            Original().ShouldNotBe(Replacement());

            using (var redirection = Redirection.Redirect <Func <bool> >(Original, Replacement))
            {
                Original().ShouldBe(Replacement());
                Original().ShouldNotBe(redirection.InvokeOriginal(null));

                redirection.Stop();

                Original().ShouldBe(redirection.InvokeOriginal(null));
            }
        }
 public static void Deinit()
 {
     if (!NetManagerMod._isDeployed)
     {
         return;
     }
     NetManagerMod.m_cachedNodeData = (NodeData[])null;
     NetManagerMod._redirection.Revert();
     NetManagerMod._redirection = (Redirection <NetManager, NetManagerMod>)null;
     NetManagerMod.PreReleaseNodeImplementation        = (NetManagerMod.PreReleaseNodeImplementationCallback)null;
     NetManagerMod.ReleaseNodeImplementation           = (NetManagerMod.ReleaseNodeImplementationCallback)null;
     SerializableDataExtension.instance.EventSaveData -= new SerializableDataExtension.SaveDataEventHandler(NetManagerMod.OnSaveData);
     NetManagerMod._isDeployed = false;
 }
Example #25
0
 public static void Deinit()
 {
     if (!BusAIMod._isDeployed)
     {
         return;
     }
     BusAIMod.LoadPassengers   = (BusAIMod.LoadPassengersCallback)null;
     BusAIMod.UnloadPassengers = (BusAIMod.UnloadPassengersCallback)null;
     BusAIMod._redirectionArriveAtTarget.Revert();
     BusAIMod._redirectionArriveAtTarget = (Redirection <BusAI, BusAIMod>)null;
     BusAIMod._redirectionCanLeave.Revert();
     BusAIMod._redirectionCanLeave = (Redirection <BusAI, BusAIMod>)null;
     BusAIMod._isDeployed          = false;
 }
 public static void Deinit()
 {
     if (!PassengerTrainAIMod._isDeployed)
     {
         return;
     }
     PassengerTrainAIMod._redirectionCanLeave.Revert();
     PassengerTrainAIMod._redirectionCanLeave = (Redirection <PassengerTrainAI, BusAIMod>)null;
     PassengerTrainAIMod._redirectionLoadPassengers.Revert();
     PassengerTrainAIMod._redirectionLoadPassengers = (Redirection <PassengerTrainAI, PassengerTrainAIMod>)null;
     PassengerTrainAIMod._redirectionUnloadPassengers.Revert();
     PassengerTrainAIMod._redirectionUnloadPassengers = (Redirection <PassengerTrainAI, PassengerTrainAIMod>)null;
     PassengerTrainAIMod._isDeployed = false;
 }
 public static void Init()
 {
     if (VehicleManagerMod._isDeployed)
     {
         return;
     }
     if (!VehicleManagerMod.TryLoadData(out VehicleManagerMod.m_cachedVehicleData))
     {
         Utils.Log((object)"Loading default vehicle data.");
     }
     VehicleManagerMod.ReleaseVehicleImplementation = (VehicleManagerMod.ReleaseVehicleImplementationCallback)Utils.CreateDelegate <VehicleManager, VehicleManagerMod.ReleaseVehicleImplementationCallback>("ReleaseVehicleImplementation", (object)Singleton <VehicleManager> .instance);
     VehicleManagerMod._redirection = new Redirection <VehicleManager, VehicleManagerMod>("ReleaseVehicle");
     SerializableDataExtension.instance.EventSaveData += new SerializableDataExtension.SaveDataEventHandler(VehicleManagerMod.OnSaveData);
     VehicleManagerMod._isDeployed = true;
 }
Example #28
0
        protected HttpResponseMessage GenerateRedirectionUnavailableResponse()
        {
            var redirection = new Redirection
            {
                Uri = null
            };

            redirection.MetadataUrl = "https://newhost.sharefile.com/sf/v3/$metadata#ShareFile.Api.Models.Redirection@Element";

            return(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(redirection), Encoding.UTF8, "application/json"),
                RequestMessage = new HttpRequestMessage(HttpMethod.Get, new Uri("https://secure.sf-api.com/sf/v3/Items(" + GetId() + ")"))
            });
        }
        public static Uri GetCalculatedUri(this Redirection redirection)
        {
            var uri = redirection.Uri;

            if (!string.IsNullOrEmpty(redirection.Root))
            {
                if (!uri.Query.Contains("root="))
                {
                    var bridgeChar = string.IsNullOrEmpty(uri.Query) ? '?' : '&';
                    uri = new Uri(redirection.Uri.ToString().TrimEnd(bridgeChar) + bridgeChar + "root=" + redirection.Root);
                }
            }

            return(uri);
        }
Example #30
0
        static RxApp()
        {
            var methodInfos = typeof(XafApplication).Methods();

            CreateControllersOptimized = methodInfos.Where(info => info.Name == nameof(CreateControllers) && info.Parameters().Count == 4).Select(info => info.DelegateForCallMethod()).First();
            CreateControllers          = methodInfos.Where(info => info.Name == nameof(CreateControllers) && info.Parameters().Count == 3).Select(info => info.DelegateForCallMethod()).First();
            CreateWindowCore           = methodInfos.First(info => info.Name == nameof(CreateWindowCore)).DelegateForCallMethod();

            OnPopupWindowCreated = Redirection.Observe(methodInfos.First(info => info.Name == nameof(OnPopupWindowCreated)))
                                   .Publish().RefCount();

            var createNestedFrame = methodInfos.First(info => info.Name == nameof(XafApplication.CreateNestedFrame));

            NestedFrameRedirection = Redirection.Observe(createNestedFrame)
                                     .Publish().RefCount();
        }
Example #31
0
 public Redirection(Redirection redirection)
 {
     automatic = redirection.automatic;
     output = new Output(redirection.output);
 }