public RpcDeserializer(MethodInfo method, object target, SerializationManager serializer, Type[] paramTypes, IRpcFilter <T>[] filters = null, DynamicMethodDelegate @delegate = null) { if (@delegate == null) { _delegate = DynamicMethodDelegateFactory.Create(method); } else { _delegate = @delegate; } _target = target; _serializer = serializer; _paramTypes = paramTypes; if (filters != null) { _filters = filters; } else { _filters = new IRpcFilter <T> [0]; } var parms = method.GetParameters(); _parmOptionals = new bool[parms.Length]; _parmOptionDefaults = new object[parms.Length]; for (int i = 0; i < parms.Length; i++) { var isOptional = parms[i].IsOptional; _parmOptionals[i] = isOptional; if (isOptional) { _parmOptionDefaults[i] = parms[i].DefaultValue; } } }
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; }