public LoadBalancerSuspendMethod GetSuspendModeAsEnum() { switch (SuspendMode.ToLower()) { case "graceful": return(LoadBalancerSuspendMethod.Graceful); case "suspendclearconnections": return(LoadBalancerSuspendMethod.SuspendClearConnections); case "suspend": return(LoadBalancerSuspendMethod.Suspend); default: throw new NotSupportedException(string.Format("Load Balancer Suspend Mode [{0}] is not supported.", SuspendMode)); } }
public static CodeInstruction[] MakeSuspendSnippet(ILGenerator generator, SuspendMode mode) { /* (Stuff in [] is dependent on mode) * * [ldloc.2] * [ldarg.1] * [call void VisualizerWorld::AddWireSegment(Point16,int)] * * [ldsfld SuspendMode SuspendableWireManager::Mode] * [ldc.i4.0] //SuspenMode.perSingle * [beq single] * [ldsfld SuspendMode SuspendableWireManager::Mode] * [ldc.i4.1] //SuspenMode.perWire * [beq single] * * ldsfld SuspendMode SuspendableWireManager::Mode * ldc.i4 <mode> * bne.un skip * call void SuspendableWireManager::SuspendWire() * [single:] [call void VisualizerWorld::ResetSegments()] * * skip: nop */ int len = 5; if (mode == SuspendMode.perSingle) { len += 3; } if (mode == SuspendMode.perSource || mode == SuspendMode.perStage) { len += 1; } if (mode == SuspendMode.perSource) { len += 6; } int i = 0; CodeInstruction[] inst = new CodeInstruction[len]; Label labelSkip = generator.DefineLabel(); Label labelWire = default(Label); if (mode == SuspendMode.perSingle) { //In HitWireSingle we want to exfiltrate the call arguments, so we can visualize the wire we hit. inst[i++] = new CodeInstruction(OpCodes.Ldloc_2); inst[i++] = new CodeInstruction(OpCodes.Ldarg_1); inst[i++] = new CodeInstruction(OpCodes.Call, typeof(VisualizerWorld).GetMethod("AddWireSegment")); } if (mode == SuspendMode.perSource) { //When in perSingle and perWire mode, we still want to clear segments after each source, even though we don't pause there. inst[i++] = new CodeInstruction(OpCodes.Ldsfld, typeof(SuspendableWireManager).GetField("Mode")); inst[i++] = new CodeInstruction(OpCodes.Ldc_I4_0); labelWire = generator.DefineLabel(); inst[i++] = new CodeInstruction(OpCodes.Beq, labelWire); inst[i++] = new CodeInstruction(OpCodes.Ldsfld, typeof(SuspendableWireManager).GetField("Mode")); inst[i++] = new CodeInstruction(OpCodes.Ldc_I4_1); inst[i++] = new CodeInstruction(OpCodes.Beq, labelWire); } inst[i++] = new CodeInstruction(OpCodes.Ldsfld, typeof(SuspendableWireManager).GetField("Mode")); inst[i++] = new CodeInstruction(OpCodes.Ldc_I4, (Int32)mode); inst[i++] = new CodeInstruction(OpCodes.Bne_Un, labelSkip); inst[i++] = new CodeInstruction(OpCodes.Call, typeof(SuspendableWireManager).GetMethod("SuspendWire")); if (mode == SuspendMode.perSource || mode == SuspendMode.perStage) { //We want to clear visuals after we are done with a source or stage inst[i] = new CodeInstruction(OpCodes.Call, typeof(VisualizerWorld).GetMethod("ResetSegments")); if (mode == SuspendMode.perSource) { inst[i].labels.Add(labelWire); } i++; } inst[i] = new CodeInstruction(OpCodes.Nop); inst[i].labels.Add(labelSkip); return(inst); }
} // 0x007F5740-0x007F5810 public void SetSuspend(SuspendMode mode) { } // 0x007FC1E0-0x007FC1F0