public bool IzOk(DynamicAction action) { var result = _Checks.OrderBy(c => c.GetLevel()).Select(c => c.Check(action)).Where(r => r != SakurityResult.NotApplicable) .FirstOrDefault(); return result == SakurityResult.Allow; }
public void SakuritySakurity(DynamicAction action) { if(IzOk(action)) { return; } // Todo this might need to come from ISecurityCheck, format the exception message to be more or less helpful depending on what build type we have? throw new ThisDudeNeedTaGo("Access not allowed"); }
public override SakurityResult Check(DynamicAction action) { if (action.Method != _Method) { return SakurityResult.NotApplicable; } if (_Everyone) { return _Allow ? SakurityResult.Allow : SakurityResult.Deny; } //todo implement other checks return SakurityResult.Deny; }
public IList<DynamicParameter> GetParameters(DynamicAction action) { var parameters = (from p in action.Method.GetParameters() select new DynamicParameter { Name = p.Name, Type = p.ParameterType }).ToList(); if (action is EntityAction) { parameters.Add(new DynamicParameter {Name = "id", Type = typeof (object)}); } return parameters; }
public object Invoke(DynamicAction action, IDictionary<string, object> parameters) { object instance; if (action is EntityAction) { instance = GetEntity(action as EntityAction, parameters); parameters = parameters.Where(p => p.Key.ToLowerInvariant() != "id").ToDictionary(x => x.Key, x => x.Value); } else { instance = _Locator.GetInstance(action.Type); } return action.Method.Invoke(instance, parameters.Select(p => p.Value).ToArray()); }
public override SakurityResult Check(DynamicAction action) { if (action.Method.ReflectedType != Type) { return SakurityResult.NotApplicable; } if(action.IsCommand() && _OnAllCommands) { return _Allow && _Everyone ? SakurityResult.Allow : SakurityResult.Deny; } if (action.IsQuery() && _OnAllQueries) { return _Allow && _Everyone ? SakurityResult.Allow : SakurityResult.Deny; } return SakurityResult.NotApplicable; }
private MenuItem BuildMenuItem(DynamicAction s, DynamicService service) { if (s is EntityAction || (!s.IsCollectionQuery() && s.IsQuery())|| !_Offica.IzOk(s)) { return null; } var action = s.Method.Name; if (s.IsCollectionQuery()) { action = action + ".jqgrid"; } return new MenuItem { Title = s.Method.Name, ActionUrl = VirtualPathUtility.ToAbsolute(string.Format("~/{0}/{1}", service.Name, action)) , AnchorClass = "parent", }; }
void UpdateCard() { //If we're updating, set the flags so we don't update multiple times in a row lastKnownAction = editor.currentAction; lastKnownFrame = editor.currentFrame; lastKnownGroup = editor.subactionGroup; //Get rid of our old list foreach (GameObject child in children) { child.SendMessage("UnregisterListeners"); NGUITools.Destroy(child); } children.Clear(); //Empty the list for future use //Create all the new buttons DynamicAction action = LegacyEditorData.instance.currentAction; string subGroup = LegacyEditorData.instance.subactionGroup; if (subGroup == "Current Frame") { subGroup = SubactionGroup.ONFRAME(LegacyEditorData.instance.currentFrame); } if (action != null) { int index = 0; //Create all the new buttons foreach (SubactionData subData in action.subactionCategories.GetIfKeyExists(subGroup)) { instantiateButton(subData, index); index++; } //Realign the grid grid.Reposition(); dragPanel.ResetPosition(); } }
// More proper would be to make this a virtual method on Action private static string FormatAction(DynamicAction action) { DoOperationAction doa; GetMemberAction gma; SetMemberAction sma; InvokeMemberAction ima; ConvertToAction cta; CallAction cla; if ((doa = action as DoOperationAction) != null) { return("Do " + doa.Operation.ToString()); } else if ((gma = action as GetMemberAction) != null) { return("GetMember " + SymbolTable.IdToString(gma.Name)); } else if ((sma = action as SetMemberAction) != null) { return("SetMember " + SymbolTable.IdToString(sma.Name)); } else if ((ima = action as InvokeMemberAction) != null) { return("InvokeMember " + ima.Name); } else if ((cta = action as ConvertToAction) != null) { return("ConvertTo " + cta.ToType.ToString()); } else if ((cla = action as CallAction) != null) { return("Call"); } else { return("UnknownAction (" + action.Kind.ToString() + ")"); } }
public void init(DynamicAction action) { actionToDelete = action; }
public virtual void AddParameters(IDynamicStage invoker, DynamicAction action) { invoker.GetParameters(action).ToList() .ForEach(AddParameter); }
static JSIMechJeb() { try { var loadedMechJebAssy = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name == "MechJeb2"); if (loadedMechJebAssy == null) { mjFound = false; //JUtil.LogMessage(this, "A supported version of MechJeb is {0}", (mjFound) ? "present" : "not available"); return; } //--- Process all the reflection info // MechJebCore mjMechJebCore_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.MechJebCore"); if (mjMechJebCore_t == null) { return; } MethodInfo mjGetComputerModule = mjMechJebCore_t.GetMethod("GetComputerModule", new Type[] { typeof(string) }); if (mjGetComputerModule == null) { throw new NotImplementedException("mjGetComputerModule"); } getComputerModule = DynamicMethodDelegateFactory.Create(mjGetComputerModule); mjCoreTarget = mjMechJebCore_t.GetField("target", BindingFlags.Instance | BindingFlags.Public); if (mjCoreTarget == null) { throw new NotImplementedException("mjCoreTarget"); } mjCoreNode = mjMechJebCore_t.GetField("node", BindingFlags.Instance | BindingFlags.Public); if (mjCoreNode == null) { throw new NotImplementedException("mjCoreNode"); } mjCoreAttitude = mjMechJebCore_t.GetField("attitude", BindingFlags.Instance | BindingFlags.Public); if (mjCoreAttitude == null) { throw new NotImplementedException("mjCoreAttitude"); } mjCoreVesselState = mjMechJebCore_t.GetField("vesselState", BindingFlags.Instance | BindingFlags.Public); if (mjCoreVesselState == null) { throw new NotImplementedException("mjCoreVesselState"); } // VesselExtensions Type mjVesselExtensions_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.VesselExtensions"); if (mjVesselExtensions_t == null) { throw new NotImplementedException("mjVesselExtensions_t"); } MethodInfo mjGetMasterMechJeb = mjVesselExtensions_t.GetMethod("GetMasterMechJeb", BindingFlags.Static | BindingFlags.Public); if (mjGetMasterMechJeb == null) { throw new NotImplementedException("mjGetMasterMechJeb"); } getMasterMechJeb = DynamicMethodDelegateFactory.Create(mjGetMasterMechJeb); MethodInfo mjPlaceManeuverNode = mjVesselExtensions_t.GetMethod("PlaceManeuverNode", BindingFlags.Static | BindingFlags.Public); if (mjPlaceManeuverNode == null) { throw new NotImplementedException("mjPlaceManeuverNode"); } placeManeuverNode = DynamicMethodDelegateFactory.Create(mjPlaceManeuverNode); // VesselState Type mjVesselState_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.VesselState"); if (mjVesselState_t == null) { throw new NotImplementedException("mjVesselState_t"); } MethodInfo mjTerminalVelocity = mjVesselState_t.GetMethod("TerminalVelocity", BindingFlags.Instance | BindingFlags.Public); if (mjTerminalVelocity == null) { throw new NotImplementedException("mjTerminalVelocity"); } terminalVelocity = DynamicMethodDelegateFactory.CreateFuncDouble(mjTerminalVelocity); // SmartASS Type mjSmartass_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleSmartASS"); mjSmartassTarget = mjSmartass_t.GetField("target", BindingFlags.Instance | BindingFlags.Public); if (mjSmartassTarget == null) { throw new NotImplementedException("mjSmartassTarget"); } MethodInfo mjSmartassEngage = mjSmartass_t.GetMethod("Engage", BindingFlags.Instance | BindingFlags.Public); if (mjSmartassEngage == null) { throw new NotImplementedException("mjSmartassEngage"); } engageSmartass = DynamicMethodDelegateFactory.Create(mjSmartassEngage); mjSmartassForceRol = mjSmartass_t.GetField("forceRol", BindingFlags.Instance | BindingFlags.Public); if (mjSmartassForceRol == null) { throw new NotImplementedException("mjSmartassForceRol"); } mjSmartassRol = mjSmartass_t.GetField("rol", BindingFlags.Instance | BindingFlags.Public); if (mjSmartassRol == null) { throw new NotImplementedException("mjSmartassRol"); } FieldInfo TargetTextsInfo = mjSmartass_t.GetField("TargetTexts", BindingFlags.Static | BindingFlags.Public); TargetTexts = (string[])TargetTextsInfo.GetValue(null); if (TargetTexts == null) { throw new NotImplementedException("TargetTexts"); } FieldInfo ModeTextsInfo = mjSmartass_t.GetField("ModeTexts", BindingFlags.Static | BindingFlags.Public); ModeTexts = (string[])ModeTextsInfo.GetValue(null); if (ModeTexts == null) { throw new NotImplementedException("ModeTexts"); } // Landing Predictions Type mjModuleLandingPredictions_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleLandingPredictions"); if (mjModuleLandingPredictions_t == null) { throw new NotImplementedException("mjModuleLandingPredictions_t"); } MethodInfo mjPredictionsGetResult = mjModuleLandingPredictions_t.GetMethod("GetResult", BindingFlags.Instance | BindingFlags.Public); if (mjPredictionsGetResult == null) { throw new NotImplementedException("mjPredictionsGetResult"); } getPredictionsResult = DynamicMethodDelegateFactory.Create(mjPredictionsGetResult); // AbsoluteVector Type mjAbsoluteVector_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.AbsoluteVector"); if (mjAbsoluteVector_t == null) { throw new NotImplementedException("mjAbsoluteVector_t"); } mjAbsoluteVectorLat = mjAbsoluteVector_t.GetField("latitude", BindingFlags.Instance | BindingFlags.Public); if (mjAbsoluteVectorLat == null) { throw new NotImplementedException("mjAbsoluteVectorLat"); } mjAbsoluteVectorLon = mjAbsoluteVector_t.GetField("longitude", BindingFlags.Instance | BindingFlags.Public); if (mjAbsoluteVectorLon == null) { throw new NotImplementedException("mjAbsoluteVectorLon"); } // MechJebModuleAscentAutopilot Type mjMechJebModuleAscentAutopilot_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleAscentAutopilot"); if (mjMechJebModuleAscentAutopilot_t == null) { throw new NotImplementedException("mjMechJebModuleAscentAutopilot_t"); } launchOrbitAltitude = mjMechJebModuleAscentAutopilot_t.GetField("desiredOrbitAltitude"); if (launchOrbitAltitude == null) { throw new NotImplementedException("launchOrbitAltitude"); } Type mjEditableDoubleMult_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.EditableDoubleMult"); if (mjEditableDoubleMult_t == null) { throw new NotImplementedException("mjEditableDoubleMult_t"); } getEditableDoubleMultMultiplier = mjEditableDoubleMult_t.GetField("multiplier"); if (getEditableDoubleMultMultiplier == null) { throw new NotImplementedException("getEditableDoubleMultMultiplier"); } PropertyInfo edmVal = mjEditableDoubleMult_t.GetProperty("val"); if (edmVal == null) { throw new NotImplementedException("edmVal"); } // getEditableDoubleMult MethodInfo mjGetEDM = edmVal.GetGetMethod(); if (mjGetEDM != null) { getEditableDoubleMult = DynamicMethodDelegateFactory.CreateFuncDouble(mjGetEDM); } // setEditableDoubleMult MethodInfo mjSetEDM = edmVal.GetSetMethod(); if (mjSetEDM != null) { setEditableDoubleMult = DynamicMethodDelegateFactory.Create(mjSetEDM); } // EditableAngle Type mjEditableAngle_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.EditableAngle"); if (mjEditableAngle_t == null) { throw new NotImplementedException("mjEditableAngle_t"); } MethodInfo mjAbsoluteVectorToDouble = null; foreach (MethodInfo method in mjEditableAngle_t.GetMethods(BindingFlags.Static | BindingFlags.Public)) { // The method name reports as "op_Implicit", but there are two if (method.ReturnType == typeof(System.Double)) { mjAbsoluteVectorToDouble = method; break; } } if (mjAbsoluteVectorToDouble == null) { throw new NotImplementedException("mjAbsoluteVectorToDouble"); } absoluteVectorToDouble = DynamicMethodDelegateFactory.Create(mjAbsoluteVectorToDouble); // MechJebModuleTargetController Type mjModuleTargetController_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleTargetController"); if (mjModuleTargetController_t == null) { throw new NotImplementedException("mjModuleTargetController_t"); } mjTargetLongitude = mjModuleTargetController_t.GetField("targetLongitude", BindingFlags.Instance | BindingFlags.Public); if (mjTargetLongitude == null) { throw new NotImplementedException("mjTargetLongitude"); } mjTargetLatitude = mjModuleTargetController_t.GetField("targetLatitude", BindingFlags.Instance | BindingFlags.Public); if (mjTargetLatitude == null) { throw new NotImplementedException("mjTargetLatitude"); } PropertyInfo mjPositionTargetExists = mjModuleTargetController_t.GetProperty("PositionTargetExists", BindingFlags.Instance | BindingFlags.Public); MethodInfo mjGetPositionTargetExists = null; if (mjPositionTargetExists != null) { mjGetPositionTargetExists = mjPositionTargetExists.GetGetMethod(); } if (mjGetPositionTargetExists == null) { throw new NotImplementedException("mjGetPositionTargetExists"); } getPositionTargetExists = DynamicMethodDelegateFactory.CreateFuncBool(mjGetPositionTargetExists); PropertyInfo mjNormalTargetExists = mjModuleTargetController_t.GetProperty("NormalTargetExists", BindingFlags.Instance | BindingFlags.Public); MethodInfo mjGetNormalTargetExists = null; if (mjNormalTargetExists != null) { mjGetNormalTargetExists = mjNormalTargetExists.GetGetMethod(); } if (mjGetNormalTargetExists == null) { throw new NotImplementedException("mjGetNormalTargetExists"); } getNormalTargetExists = DynamicMethodDelegateFactory.CreateFuncBool(mjGetNormalTargetExists); PropertyInfo mjTargetOrbit = mjModuleTargetController_t.GetProperty("TargetOrbit", BindingFlags.Instance | BindingFlags.Public); ; MethodInfo mjGetTargetOrbit = null; if (mjTargetOrbit != null) { mjGetTargetOrbit = mjTargetOrbit.GetGetMethod(); } if (mjGetTargetOrbit == null) { throw new NotImplementedException("mjGetTargetOrbit"); } getTargetOrbit = DynamicMethodDelegateFactory.CreateFuncObject(mjGetTargetOrbit); // MuMech.FuelFlowSimulation Type mjFuelFlowSimulation_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.FuelFlowSimulation"); if (mjFuelFlowSimulation_t == null) { throw new NotImplementedException("mjFuelFlowSimulation_t"); } // MuMech.FuelFlowSimulation.Stats Type mjFuelFlowSimulationStats_t = mjFuelFlowSimulation_t.GetNestedType("Stats"); if (mjFuelFlowSimulationStats_t == null) { throw new NotImplementedException("mjFuelFlowSimulationStats_t"); } mjStageDv = mjFuelFlowSimulationStats_t.GetField("deltaV", BindingFlags.Instance | BindingFlags.Public); if (mjStageDv == null) { throw new NotImplementedException("mjStageDv"); } // MuMech.ReentrySimulation.Result Type mjReentrySim_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.ReentrySimulation"); if (mjReentrySim_t == null) { throw new NotImplementedException("mjReentrySim_t"); } Type mjReentryResult_t = mjReentrySim_t.GetNestedType("Result"); if (mjReentryResult_t == null) { throw new NotImplementedException("mjReentryResult_t"); } mjReentryOutcome = mjReentryResult_t.GetField("outcome", BindingFlags.Instance | BindingFlags.Public); if (mjReentryOutcome == null) { throw new NotImplementedException("mjReentryOutcome"); } mjReentryEndPosition = mjReentryResult_t.GetField("endPosition", BindingFlags.Instance | BindingFlags.Public); if (mjReentryEndPosition == null) { throw new NotImplementedException("mjReentryEndPosition"); } mjReentryTime = mjReentryResult_t.GetField("endUT", BindingFlags.Instance | BindingFlags.Public); if (mjReentryTime == null) { throw new NotImplementedException("mjReentryTime"); } // UserPool Type mjUserPool_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.UserPool"); MethodInfo mjAddUser = mjUserPool_t.GetMethod("Add", BindingFlags.Instance | BindingFlags.Public); if (mjAddUser == null) { throw new NotImplementedException("mjAddUser"); } addUser = DynamicMethodDelegateFactory.Create(mjAddUser); MethodInfo mjRemoveUser = mjUserPool_t.GetMethod("Remove", BindingFlags.Instance | BindingFlags.Public); if (mjRemoveUser == null) { throw new NotImplementedException("mjRemoveUser"); } removeUser = DynamicMethodDelegateFactory.Create(mjRemoveUser); MethodInfo mjContainsUser = mjUserPool_t.GetMethod("Contains", BindingFlags.Instance | BindingFlags.Public); if (mjContainsUser == null) { throw new NotImplementedException("mjContainsUser"); } containsUser = DynamicMethodDelegateFactory.Create(mjContainsUser); // MechJebModuleLandingAutopilot Type mjLandingAutopilot_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleLandingAutopilot"); MethodInfo mjLandAtPositionTarget = mjLandingAutopilot_t.GetMethod("LandAtPositionTarget", BindingFlags.Instance | BindingFlags.Public); if (mjLandAtPositionTarget == null) { throw new NotImplementedException("mjLandAtPositionTarget"); } landAtPositionTarget = DynamicMethodDelegateFactory.Create(mjLandAtPositionTarget); MethodInfo mjLandUntargeted = mjLandingAutopilot_t.GetMethod("LandUntargeted", BindingFlags.Instance | BindingFlags.Public); if (mjLandUntargeted == null) { throw new NotImplementedException("mjLandUntargeted"); } landUntargeted = DynamicMethodDelegateFactory.Create(mjLandUntargeted); MethodInfo mjStopLanding = mjLandingAutopilot_t.GetMethod("StopLanding", BindingFlags.Instance | BindingFlags.Public); if (mjStopLanding == null) { throw new NotImplementedException("mjStopLanding"); } stopLanding = DynamicMethodDelegateFactory.CreateAction(mjStopLanding); Type mjSpaceplaneAutopilot_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleSpaceplaneAutopilot"); MethodInfo mjSPAutoland = mjSpaceplaneAutopilot_t.GetMethod("Autoland", BindingFlags.Instance | BindingFlags.Public); if (mjSPAutoland == null) { throw new NotImplementedException("mjSPAutoland"); } spaceplaneAutoland = DynamicMethodDelegateFactory.Create(mjSPAutoland); MethodInfo mjSPHoldHeadingAndAltitude = mjSpaceplaneAutopilot_t.GetMethod("HoldHeadingAndAltitude", BindingFlags.Instance | BindingFlags.Public); if (mjSPHoldHeadingAndAltitude == null) { throw new NotImplementedException("mjSPHoldHeadingAndAltitude"); } spaceplaneHoldHeading = DynamicMethodDelegateFactory.Create(mjSPHoldHeadingAndAltitude); MethodInfo mjSPAutopilotOff = mjSpaceplaneAutopilot_t.GetMethod("AutopilotOff", BindingFlags.Instance | BindingFlags.Public); if (mjSPAutopilotOff == null) { throw new NotImplementedException("mjSPAutopilotOff"); } spaceplaneAPOff = DynamicMethodDelegateFactory.CreateAction(mjSPAutopilotOff); spaceplaneAPMode = mjSpaceplaneAutopilot_t.GetField("mode", BindingFlags.Instance | BindingFlags.Public); if (spaceplaneAPMode == null) { throw new NotImplementedException("spaceplaneAPMode"); } spaceplaneAltitude = mjSpaceplaneAutopilot_t.GetField("targetAltitude", BindingFlags.Instance | BindingFlags.Public); if (spaceplaneAltitude == null) { throw new NotImplementedException("spaceplaneAltitude"); } spaceplaneHeading = mjSpaceplaneAutopilot_t.GetField("targetHeading", BindingFlags.Instance | BindingFlags.Public); if (spaceplaneHeading == null) { throw new NotImplementedException("spaceplaneHeading"); } spaceplaneGlideslope = mjSpaceplaneAutopilot_t.GetField("glideslope", BindingFlags.Instance | BindingFlags.Public); if (spaceplaneGlideslope == null) { throw new NotImplementedException("spaceplaneGlideslope"); } // EditableDouble Type mjEditableDouble_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.EditableDouble"); PropertyInfo mjEditableDoubleVal = mjEditableDouble_t.GetProperty("val", BindingFlags.Instance | BindingFlags.Public); MethodInfo mjGetEditableDouble = null, mjSetEditableDouble = null; if (mjEditableDoubleVal != null) { mjGetEditableDouble = mjEditableDoubleVal.GetGetMethod(); mjSetEditableDouble = mjEditableDoubleVal.GetSetMethod(); } if (mjGetEditableDouble == null) { throw new NotImplementedException("mjGetEditableDouble"); } getEditableDouble = DynamicMethodDelegateFactory.CreateFuncDouble(mjGetEditableDouble); if (mjSetEditableDouble == null) { throw new NotImplementedException("mjSetEditableDouble"); } setEditableDouble = DynamicMethodDelegateFactory.Create(mjSetEditableDouble); // OrbitalManeuverCalculator Type mjOrbitalManeuverCalculator_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.OrbitalManeuverCalculator"); mjDeltaVAndTimeForHohmannTransfer = mjOrbitalManeuverCalculator_t.GetMethod("DeltaVAndTimeForHohmannTransfer", BindingFlags.Static | BindingFlags.Public); if (mjDeltaVAndTimeForHohmannTransfer == null) { throw new NotImplementedException("mjDeltaVAndTimeForHohmannTransfer"); } //deltaVAndTimeForHohmannTransfer = DynamicMethodDelegateFactory.Create(mjDeltaVAndTimeForHohmannTransfer); mjDeltaVAndTimeForInterplanetaryTransferEjection = mjOrbitalManeuverCalculator_t.GetMethod("DeltaVAndTimeForInterplanetaryTransferEjection", BindingFlags.Static | BindingFlags.Public); if (mjDeltaVAndTimeForInterplanetaryTransferEjection == null) { throw new NotImplementedException("mjDeltaVAndTimeForInterplanetaryTransferEjection"); } //deltaVAndTimeForInterplanetaryTransferEjection = DynamicMethodDelegateFactory.Create(mjDeltaVAndTimeForInterplanetaryTransferEjection); MethodInfo mjDeltaVToCircularize = mjOrbitalManeuverCalculator_t.GetMethod("DeltaVToCircularize", BindingFlags.Static | BindingFlags.Public); if (mjDeltaVToCircularize == null) { throw new NotImplementedException("mjDeltaVToCircularize"); } deltaVToCircularize = DynamicMethodDelegateFactory.Create(mjDeltaVToCircularize); // MechJebModuleStageStats Type mjModuleStageStats_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleStageStats"); if (mjModuleStageStats_t == null) { throw new NotImplementedException("mjModuleStageStats_t"); } MethodInfo mjRequestUpdate = mjModuleStageStats_t.GetMethod("RequestUpdate", BindingFlags.Instance | BindingFlags.Public); if (mjRequestUpdate == null) { throw new NotImplementedException("mjRequestUpdate"); } requestUpdate = DynamicMethodDelegateFactory.Create(mjRequestUpdate); mjVacStageStats = mjModuleStageStats_t.GetField("vacStats", BindingFlags.Instance | BindingFlags.Public); if (mjVacStageStats == null) { throw new NotImplementedException("mjVacStageStats"); } // Updated MechJeb (post 2.5.1) switched from using KER back to // its internal FuelFlowSimulation. This sim uses an array of // structs, which entails a couple of extra hoops to jump through // when reading via reflection. mjAtmStageStats = mjModuleStageStats_t.GetField("atmoStats", BindingFlags.Instance | BindingFlags.Public); if (mjAtmStageStats == null) { throw new NotImplementedException("mjAtmStageStats"); } PropertyInfo mjStageStatsLength = mjVacStageStats.FieldType.GetProperty("Length"); if (mjStageStatsLength == null) { throw new NotImplementedException("mjStageStatsLength"); } MethodInfo mjStageStatsGetLength = mjStageStatsLength.GetGetMethod(); if (mjStageStatsGetLength == null) { throw new NotImplementedException("mjStageStatsGetLength"); } stageStatsGetLength = DynamicMethodDelegateFactory.CreateFuncInt(mjStageStatsGetLength); MethodInfo mjStageStatsGetIndex = mjVacStageStats.FieldType.GetMethod("Get"); if (mjStageStatsGetIndex == null) { throw new NotImplementedException("mjStageStatsGetIndex"); } stageStatsGetIndex = DynamicMethodDelegateFactory.Create(mjStageStatsGetIndex); // MechJebModuleNodeExecutor Type mjNodeExecutor_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.MechJebModuleNodeExecutor"); MethodInfo mjExecuteOneNode = mjNodeExecutor_t.GetMethod("ExecuteOneNode", BindingFlags.Instance | BindingFlags.Public); if (mjExecuteOneNode == null) { throw new NotImplementedException("mjExecuteOneNode"); } executeOneNode = DynamicMethodDelegateFactory.Create(mjExecuteOneNode); MethodInfo mjAbortNode = mjNodeExecutor_t.GetMethod("Abort", BindingFlags.Instance | BindingFlags.Public); if (mjAbortNode == null) { throw new NotImplementedException("mjAbortNode"); } abortNode = DynamicMethodDelegateFactory.CreateAction(mjAbortNode); // Computer Module Type mjComputerModule_t = loadedMechJebAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "MuMech.ComputerModule"); PropertyInfo mjModuleEnabledProperty = mjComputerModule_t.GetProperty("enabled", BindingFlags.Instance | BindingFlags.Public); MethodInfo mjModuleEnabled = null; if (mjModuleEnabledProperty != null) { mjModuleEnabled = mjModuleEnabledProperty.GetGetMethod(); } if (mjModuleEnabled == null) { throw new NotImplementedException("mjModuleEnabled"); } moduleEnabled = DynamicMethodDelegateFactory.CreateFuncBool(mjModuleEnabled); mjModuleUsers = mjComputerModule_t.GetField("users", BindingFlags.Instance | BindingFlags.Public); if (mjModuleUsers == null) { throw new NotImplementedException("mjModuleUsers"); } } catch (Exception e) { mjMechJebCore_t = null; JUtil.LogMessage(null, "Exception initializing JSIMechJeb: {0}", e); } if (mjMechJebCore_t != null && getMasterMechJeb != null) { mjFound = true; } else { mjFound = false; } }
/// <summary> /// Using the dynamic action's positional information and state, find the correct dynamic action info /// </summary> /// <param name="dynamicAction">Find information for this action</param> /// <returns>Information for the dynamic action</returns> public IDynamicActionInfo GetInfoForAction(DynamicAction dynamicAction) { return((dynamicAction.ButtonMode == ButtonMode.Pool) ? GetInfoForPoolAction(dynamicAction) : GetZoneInfoForZoneAction(dynamicAction)); }
private void setActionVar(object valueToSet) { DynamicAction action = LegacyEditorData.instance.currentAction; action.GetType().GetField(actionVar).SetValue(action, valueToSet); }
public void SetAction(DynamicAction action) { Action = action; Parameters.Clear(); AddParameters(Stage, action); }
public abstract SakurityResult Check(DynamicAction action);
static JSIChatterer() { try { var loadedChattererAssy = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name == "Chatterer"); if (loadedChattererAssy == null) { chattererFound = false; return; } //--- Process all the reflection info // MechJebCore chatterer_t = loadedChattererAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "Chatterer.chatterer"); if (chatterer_t == null) { JUtil.LogErrorMessage(null, "Did not find Chatterer.chatterer"); return; } MethodInfo txMethod = chatterer_t.GetMethod("VesselIsTransmitting", BindingFlags.Instance | BindingFlags.Public); if (txMethod == null) { throw new NotImplementedException("txMethod"); } chattererTx = DynamicMethodDelegateFactory.CreateFuncBool(txMethod); MethodInfo rxMethod = chatterer_t.GetMethod("VesselIsReceiving", BindingFlags.Instance | BindingFlags.Public); if (rxMethod == null) { throw new NotImplementedException("rxMethod"); } chattererRx = DynamicMethodDelegateFactory.CreateFuncBool(rxMethod); MethodInfo chatterMethod = chatterer_t.GetMethod("InitiateChatter", BindingFlags.Instance | BindingFlags.Public); if (chatterMethod == null) { throw new NotImplementedException("chatterMethod"); } chattererStartTalking = DynamicMethodDelegateFactory.CreateAction(chatterMethod); } catch (Exception e) { chatterer_t = null; JUtil.LogMessage(null, "Exception initializing JSIChatterer: {0}", e); } if (chatterer_t != null && chattererStartTalking != null) { chattererFound = true; } else { chattererFound = false; } }
void OnActionChanged(DynamicAction action) { UpdateCount(); }
public void init(DynamicAction action) { actionToAdd = action; }
static JSIPilotAssistant() { try { var loadedPAAssy = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name == "PilotAssistant"); if (loadedPAAssy == null) { //JUtil.LogMessage(null, "Did not load PilotAssistant"); //var list = AssemblyLoader.loadedAssemblies; //foreach(var a in list) //{ // JUtil.LogMessage(null, "-- {0}", a.name); //} return; } //else //{ // JUtil.LogMessage(null, "Did find PilotAssistant"); //} Type paAsstVesselModule_t = loadedPAAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "PilotAssistant.FlightModules.AsstVesselModule"); if (paAsstVesselModule_t == null) { throw new NotImplementedException("paAsstVesselModule_t"); } vesselAsst_t = paAsstVesselModule_t.GetField("vesselAsst", BindingFlags.Instance | BindingFlags.Public); if (vesselAsst_t == null) { throw new NotImplementedException("vesselAsst_t"); } Type paPilotAssistant_t = loadedPAAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "PilotAssistant.FlightModules.PilotAssistant"); if (paPilotAssistant_t == null) { throw new NotImplementedException("paPilotAssistant_t"); } vertMode_t = paPilotAssistant_t.GetField("CurrentVertMode", BindingFlags.Instance | BindingFlags.Public); if (vertMode_t == null) { throw new NotImplementedException("currentVertMode_t"); } vertActive_t = paPilotAssistant_t.GetField("VertActive", BindingFlags.Instance | BindingFlags.Public); if (vertActive_t == null) { throw new NotImplementedException("vertActive_t"); } MethodInfo vertSetting_t = paPilotAssistant_t.GetMethod("GetCurrentVert", BindingFlags.Instance | BindingFlags.Public); if (vertSetting_t == null) { throw new NotImplementedException("vertSetting_t"); } GetCurrentVert = DynamicMethodDelegateFactory.CreateFuncDouble(vertSetting_t); MethodInfo setVert_t = paPilotAssistant_t.GetMethod("SetVert", BindingFlags.Instance | BindingFlags.Public); if (setVert_t == null) { throw new NotImplementedException("setVert_t"); } SetVert = DynamicMethodDelegateFactory.Create(setVert_t); horzMode_t = paPilotAssistant_t.GetField("CurrentHrztMode", BindingFlags.Instance | BindingFlags.Public); if (horzMode_t == null) { throw new NotImplementedException("horzMode_t"); } horzActive_t = paPilotAssistant_t.GetField("HrztActive", BindingFlags.Instance | BindingFlags.Public); if (horzActive_t == null) { throw new NotImplementedException("horzActive_t"); } MethodInfo horzSetting_t = paPilotAssistant_t.GetMethod("GetCurrentHrzt", BindingFlags.Instance | BindingFlags.Public); if (horzSetting_t == null) { throw new NotImplementedException("horzSetting_t"); } GetCurrentHorz = DynamicMethodDelegateFactory.CreateFuncDouble(horzSetting_t); MethodInfo setHorz_t = paPilotAssistant_t.GetMethod("SetHrzt", BindingFlags.Instance | BindingFlags.Public); if (setHorz_t == null) { throw new NotImplementedException("setHorz_t"); } SetHorz = DynamicMethodDelegateFactory.Create(setHorz_t); throttleMode_t = paPilotAssistant_t.GetField("CurrentThrottleMode", BindingFlags.Instance | BindingFlags.Public); if (throttleMode_t == null) { throw new NotImplementedException("throttleMode_t"); } throttleActive_t = paPilotAssistant_t.GetField("ThrtActive", BindingFlags.Instance | BindingFlags.Public); if (throttleActive_t == null) { throw new NotImplementedException("throttleActive_t"); } MethodInfo throttleSetting_t = paPilotAssistant_t.GetMethod("GetCurrentThrottle", BindingFlags.Instance | BindingFlags.Public); if (throttleSetting_t == null) { throw new NotImplementedException("throttleSetting_t"); } GetCurrentThrottle = DynamicMethodDelegateFactory.CreateFuncDouble(throttleSetting_t); MethodInfo setThrottle_t = paPilotAssistant_t.GetMethod("SetThrottle", BindingFlags.Instance | BindingFlags.Public); if (setThrottle_t == null) { throw new NotImplementedException("setThrottle_t"); } SetThrottle = DynamicMethodDelegateFactory.Create(setThrottle_t); speedRef_t = paPilotAssistant_t.GetField("speedRef", BindingFlags.Instance | BindingFlags.NonPublic); if (speedRef_t == null) { throw new NotImplementedException("PA speedRef_t"); } MethodInfo changeSpeedRef_t = paPilotAssistant_t.GetMethod("ChangeSpeedRef", BindingFlags.Instance | BindingFlags.Public); if (changeSpeedRef_t == null) { throw new NotImplementedException("PA changeSpeedRef_t"); } SetSpeedRef = DynamicMethodDelegateFactory.Create(changeSpeedRef_t); speedUnits_t = paPilotAssistant_t.GetField("units", BindingFlags.Instance | BindingFlags.NonPublic); if (speedUnits_t == null) { throw new NotImplementedException("PA speedUnits_t"); } MethodInfo changeSpeedUnits_t = paPilotAssistant_t.GetMethod("ChangeSpeedUnit", BindingFlags.Instance | BindingFlags.Public); if (changeSpeedUnits_t == null) { throw new NotImplementedException("PA changeSpeedUnits_t"); } SetSpeedUnits = DynamicMethodDelegateFactory.Create(changeSpeedUnits_t); pauseState_t = paPilotAssistant_t.GetField("bPause", BindingFlags.Instance | BindingFlags.Public); if (pauseState_t == null) { throw new NotImplementedException("PA pauseState_t"); } MethodInfo TogglePause_t = paPilotAssistant_t.GetMethod("TogglePauseCtrlState", BindingFlags.Instance | BindingFlags.Public); if (TogglePause_t == null) { throw new NotImplementedException("PA TogglePause_t"); } TogglePause = DynamicMethodDelegateFactory.CreateAction(TogglePause_t); } catch (Exception e) { JUtil.LogMessage(null, "Exception tripped: {0}", e); paFound = false; return; } paFound = true; }
public DynamicHttpActionDescriptor(RestService service, DynamicControllerInfo controller, DynamicAction objMethod, ReflectedHttpActionDescriptor originalDescriptor) : base(originalDescriptor.ControllerDescriptor, originalDescriptor.MethodInfo) { _Service = service; _Controller = controller; _DynamicMethod = objMethod; _OriginalDescriptor = originalDescriptor; _Parameters = InitializeParameterDescriptors(); }
private object getActionVar() { DynamicAction action = LegacyEditorData.instance.currentAction; return(action.GetType().GetField(actionVar).GetValue(action)); }
public object Invoke(DynamicAction action, IDictionary<string, object> parameters) { _Offica.SakuritySakurity(action); return _Invoker.Invoke(action, parameters); }
/// <summary> /// Stop tracking and updating an action's index /// </summary> /// <param name="dynamicAction">A Dynamic Action to track</param> /// <remarks>will not add if it already is being tracked</remarks> public void UnregisterAction(DynamicAction dynamicAction) { lock (_dynamicActionsLock) { _dynamicActions.Remove(dynamicAction); } }
public IList<DynamicParameter> GetParameters(DynamicAction action) { return _Invoker.GetParameters(action); }
void OnActionChanged(DynamicAction action) { //We only want to fire the update if the action actually changed, in case we fired an event earlier for the group or frame //if (action != lastKnownAction) UpdateCard(); }
void OnActionChange(DynamicAction act) { UpdateFighterAction(); }
public void Delete(DynamicAction action) { actions.Remove(action); }
public object Invoke(DynamicAction action, IDictionary <string, object> parameters) { _Offica.SakuritySakurity(action); return(_Invoker.Invoke(action, parameters)); }
static JSIParachute() { try { rcModuleRealChute = AssemblyLoader.loadedAssemblies.SelectMany( a => a.assembly.GetExportedTypes()) .SingleOrDefault(t => t.FullName == "RealChute.RealChuteModule"); if (rcModuleRealChute == null) { rcFound = false; JUtil.LogMessage(null, "rcModuleRealChute is null"); return; } PropertyInfo rcAnyDeployed = rcModuleRealChute.GetProperty("AnyDeployed", BindingFlags.Instance | BindingFlags.Public); if (rcAnyDeployed == null) { JUtil.LogMessage(null, "rcAnyDeployed is null"); } MethodInfo rcGetAnyDeployed = rcAnyDeployed.GetGetMethod(); getAnyDeployed = DynamicMethodDelegateFactory.CreateFuncBool(rcGetAnyDeployed); if (getAnyDeployed == null) { JUtil.LogMessage(null, "getAnyDeployed is null"); } MethodInfo rcArmChute = rcModuleRealChute.GetMethod("GUIArm", BindingFlags.Instance | BindingFlags.Public); armChute = DynamicMethodDelegateFactory.CreateAction(rcArmChute); if (armChute == null) { JUtil.LogMessage(null, "armChute is null"); } MethodInfo rcDisarmChute = rcModuleRealChute.GetMethod("GUIDisarm", BindingFlags.Instance | BindingFlags.Public); disarmChute = DynamicMethodDelegateFactory.CreateAction(rcDisarmChute); if (disarmChute == null) { JUtil.LogMessage(null, "disarmChute is null"); } MethodInfo rcDeployChute = rcModuleRealChute.GetMethod("GUIDeploy", BindingFlags.Instance | BindingFlags.Public); deployChute = DynamicMethodDelegateFactory.CreateAction(rcDeployChute); if (deployChute == null) { JUtil.LogMessage(null, "deployChute is null"); } MethodInfo rcCutChute = rcModuleRealChute.GetMethod("GUICut", BindingFlags.Instance | BindingFlags.Public); cutChute = DynamicMethodDelegateFactory.CreateAction(rcCutChute); if (cutChute == null) { JUtil.LogMessage(null, "cutChute is null"); } rcArmed = rcModuleRealChute.GetField("armed", BindingFlags.Instance | BindingFlags.Public); if (rcArmed == null) { JUtil.LogMessage(null, "rcArmed is null"); } rcSafeState = rcModuleRealChute.GetField("safeState", BindingFlags.Instance | BindingFlags.Public); if (rcSafeState == null) { JUtil.LogMessage(null, "rcSafeState is null"); } } catch (Exception e) { JUtil.LogMessage(null, "static JSIParachute exception {0}", e); rcModuleRealChute = null; getAnyDeployed = null; armChute = null; disarmChute = null; deployChute = null; cutChute = null; rcArmed = null; rcSafeState = null; } if (rcModuleRealChute != null && armChute != null && getAnyDeployed != null && disarmChute != null && deployChute != null && cutChute != null && rcArmed != null && rcSafeState != null ) { rcFound = true; } else { rcFound = false; } }
public IList <DynamicParameter> GetParameters(DynamicAction action) { return(_Invoker.GetParameters(action)); }
void OnCurrentActionChanged(DynamicAction _) { OnDataChanged(); }
void OnActionChanged(DynamicAction action) { //TODO add variables to action actionList = new List <string>(); }
static JSIParachute() { try { rcModuleRealChute = AssemblyLoader.loadedAssemblies.SelectMany( a => a.assembly.GetExportedTypes()) .SingleOrDefault(t => t.FullName == "RealChute.RealChuteModule"); if (rcModuleRealChute == null) { rcFound = false; JUtil.LogMessage(null, "rcModuleRealChute is null"); return; } PropertyInfo rcAnyDeployed = rcModuleRealChute.GetProperty("anyDeployed", BindingFlags.Instance | BindingFlags.Public); MethodInfo rcGetAnyDeployed = rcAnyDeployed.GetGetMethod(); getAnyDeployed = DynamicMethodDelegateFactory.CreateFuncBool(rcGetAnyDeployed); if (getAnyDeployed == null) { JUtil.LogMessage(null, "getAnyDeployed is null"); } MethodInfo rcArmChute = rcModuleRealChute.GetMethod("GUIArm", BindingFlags.Instance | BindingFlags.Public); armChute = DynamicMethodDelegateFactory.CreateAction(rcArmChute); if(armChute == null) { JUtil.LogMessage(null, "armChute is null"); } MethodInfo rcDisarmChute = rcModuleRealChute.GetMethod("GUIDisarm", BindingFlags.Instance | BindingFlags.Public); disarmChute = DynamicMethodDelegateFactory.CreateAction(rcDisarmChute); if (disarmChute == null) { JUtil.LogMessage(null, "disarmChute is null"); } MethodInfo rcDeployChute = rcModuleRealChute.GetMethod("GUIDeploy", BindingFlags.Instance | BindingFlags.Public); deployChute = DynamicMethodDelegateFactory.CreateAction(rcDeployChute); if (deployChute == null) { JUtil.LogMessage(null, "deployChute is null"); } MethodInfo rcCutChute = rcModuleRealChute.GetMethod("GUICut", BindingFlags.Instance | BindingFlags.Public); cutChute = DynamicMethodDelegateFactory.CreateAction(rcCutChute); if (cutChute == null) { JUtil.LogMessage(null, "cutChute is null"); } rcArmed = rcModuleRealChute.GetField("armed", BindingFlags.Instance | BindingFlags.Public); if (rcArmed == null) { JUtil.LogMessage(null, "rcArmed is null"); } } catch(Exception e) { JUtil.LogMessage(null, "static JSIParachute exception {0}", e); rcModuleRealChute = null; getAnyDeployed = null; armChute = null; disarmChute = null; deployChute = null; cutChute = null; rcArmed = null; } if (rcModuleRealChute != null && armChute != null && getAnyDeployed != null && disarmChute != null && deployChute != null && cutChute != null && rcArmed != null ) { rcFound = true; } else { rcFound = false; } }