/// <summary> /// 执行委托方法 /// </summary> /// <param name="session">数据会话</param> /// <param name="context">上下文</param> /// <param name="item">事件</param> /// <returns>执行结果</returns> private static Boolean Execute(IDbSession session, DelegateContext context, KeyValuePair <EventFireTypeEnum, Func <DelegateContext, IDelegateService, Boolean> > item) { var result = false; if (item.Key == EventFireTypeEnum.OnProcessStarted || item.Key == EventFireTypeEnum.OnProcessRunning || item.Key == EventFireTypeEnum.OnProcessCompleted) { var delegateService = DelegateServiceFactory.CreateDelegateService(DelegateScopeTypeEnum.Process, session, context); delegateService.SetActivityResource(context.ActivityResource); result = item.Value(context, delegateService as IDelegateService); } else if (item.Key == EventFireTypeEnum.OnActivityCreated || item.Key == EventFireTypeEnum.OnActivityExecuting || item.Key == EventFireTypeEnum.OnActivityExecuted || item.Key == EventFireTypeEnum.OnActivityCompleted) { var delegateService = DelegateServiceFactory.CreateDelegateService(DelegateScopeTypeEnum.Activity, session, context); delegateService.SetActivityResource(context.ActivityResource); result = item.Value(context, delegateService as IDelegateService); } return(result); }
protected override void CheckForButtonInput(KeyValuePair <ButtonGesture, Action> binding) { switch (binding.Key.ButtonAction) { case ButtonAction.OnPressDown: if (Input.GetKeyDown(m_buttonBindings[binding.Key])) { binding.Value(); } break; case ButtonAction.OnPress: if (Input.GetKey(m_buttonBindings[binding.Key])) { binding.Value(); } break; case ButtonAction.OnPressUp: if (Input.GetKeyUp(m_buttonBindings[binding.Key])) { binding.Value(); } break; } }
private void ReadAttribute(Type targetType, KeyValuePair <Type, GameAttriHandler> attributedata, RegisterType registerTp) { if (registerTp == RegisterType.ClassAttr) { object[] att = targetType.GetCustomAttributes(attributedata.Key, false); if (att != null && att.Length == 1) { attributedata.Value(att[0], targetType); } } else if (registerTp == RegisterType.MethodAtt) { MethodInfo[] methods = targetType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly); for (int j = 0; j < methods.Length; ++j) { object[] att = methods[j].GetCustomAttributes(attributedata.Key, false); if (att != null && att.Length > 0 && methods[j].IsStatic) { attributedata.Value(att[0], methods[j]); } else if (att != null && att.Length > 0 && !methods[j].IsStatic) { LogMgr.LogError("虽然注册了,但是不是静态函数 =>" + methods[j].Name); } } } else if (registerTp == RegisterType.InstacenMethodAttr) { MethodInfo[] methods = targetType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly); for (int j = 0; j < methods.Length; ++j) { object[] att = methods[j].GetCustomAttributes(attributedata.Key, false); if (att != null && att.Length > 0) { attributedata.Value(att[0], methods[j]); } } } else if (registerTp == RegisterType.Register) { MethodInfo[] methods = targetType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly); for (int j = 0; j < methods.Length; ++j) { object[] att = methods[j].GetCustomAttributes(attributedata.Key, false); if (att != null && att.Length > 0) { attributedata.Value(att[0], new KeyValuePair <BaseAttributeRegister, MethodInfo>(this, methods[j])); } } } }
static void PerformRun(Line line, Match match, KeyValuePair <Regex, Action <string> > variant) { if (match.Groups.Count > 1) { // TODO eliminate SPECIAL SYMBOL!! variant.Value(match.Groups.OfType <Group>().Skip(1).Select(x => x.Value).Join("|")); } else { var rest = variant.Key.Replace(line.String, ""); variant.Value(rest); } }
protected override void CheckForAxisInput(KeyValuePair <AxisGesture, Action <float> > binding) { switch (binding.Key.AxisAction) { case AxisAction.GetAxis: binding.Value(Input.GetAxis(m_axisBindings[binding.Key])); break; case AxisAction.GetAxisRaw: binding.Value(Input.GetAxisRaw(m_axisBindings[binding.Key])); break; } }
private static void AddMenuItem(KeyValuePair <string, ModMenuItemClickedCallback> modMenuItem, MenuItem modsGroup) { var item = new MenuItem(modMenuItem.Key); item.Click += (sender, args) => modMenuItem.Value(); modsGroup.Items.Add(item); }
/// <summary> /// Function to load a single dependency for a file. /// </summary> /// <param name="dependency">Dependency to load.</param> /// <param name="childDependencies">The dependencies for this dependency.</param> /// <returns>The loaded dependency object.</returns> private object LoadDependency(GorgonEditorDependency dependency, IReadOnlyDictionary <GorgonEditorDependency, object> childDependencies) { GorgonFileSystemFileEntry dependencyFile = FileSystem.GetFile(dependency.Path); if (dependencyFile == null) { throw new IOException(string.Format(Resources.GORFS_ERR_DEPENDENCY_NOT_FOUND, dependency.Path)); } // Find a handler for this file. KeyValuePair <Type, Func <Stream, IReadOnlyDictionary <GorgonEditorDependency, object>, object> > handler = _fileHandlers.FirstOrDefault(item => string.Equals(item.Key.FullName, dependency.Type, StringComparison.OrdinalIgnoreCase)); if (handler.Key == null) { throw new IOException(string.Format(Resources.GORFS_ERR_FILE_NO_HANDLER, dependency.Path)); } using (Stream dependencyStream = dependencyFile.OpenStream(false)) { return(handler.Value(dependencyStream, childDependencies)); } }
private IntPtr _WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { IntPtr value; WM wM = (WM)msg; List <KeyValuePair <WM, MessageHandler> > .Enumerator enumerator = this._messageTable.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyValuePair <WM, MessageHandler> current = enumerator.Current; if (current.Key != wM) { continue; } value = current.Value(wM, wParam, lParam, out handled); return(value); } return(IntPtr.Zero); } finally { ((IDisposable)enumerator).Dispose(); } return(value); }
public string ProcessInlineBackgroundGraphic(IDrawGraphic zDrawGraphic, Graphics zGraphics, ProjectLayoutElement zElement, string sInput) { var kvpMatchedProcessor = new KeyValuePair <Regex, Action <Match, ProjectLayoutElement, ProjectLayoutElement, PointOffset> >(); Match zMatch = null; foreach (var kvpGraphicProcessor in listGraphicProcessingPairs) { zMatch = kvpGraphicProcessor.Key.Match(sInput); if (zMatch.Success) { kvpMatchedProcessor = kvpGraphicProcessor; break; } } if (kvpMatchedProcessor.Key == null || zMatch == null || !zMatch.Success) { return(sInput); } var sToReplace = zMatch.Groups[0].Value; var pointOffset = new PointOffset(); var zBgGraphicElement = new ProjectLayoutElement(Guid.NewGuid().ToString()); zBgGraphicElement.opacity = -1; kvpMatchedProcessor.Value(zMatch, zBgGraphicElement, zElement, pointOffset); zDrawGraphic.DrawGraphicFile(zGraphics, zBgGraphicElement.variable, zBgGraphicElement, pointOffset.X, pointOffset.Y); return(sInput.Replace(sToReplace, string.Empty)); }
public void NavigateTo(int index) { KeyValuePair <ISelectable, Action> element = NavButtons.ElementAt(index); SelectButton = element.Key; SelectButton.SetSelectStatus(true); element.Value(); }
public HTTPResponse(ByteReader br, TextReader tr, String fileName) : this() { KeyValuePair <string, ContentReader> reader = contentTypes[ fileName.Substring(fileName.LastIndexOf('.')).ToLower()]; attributes.Add("Content-Type", reader.Key); reader.Value(br, tr, fileName, ref attributes, this); }
public T Deserialize(MessageReader reader, T target, UnknownFieldCollection missing) { MessageTag tag = new MessageTag(); while (reader.TryReadMessageTag(ref tag)) { if (TryGetFieldReader(tag)) { if (tag.WireType == WireType.String) { _current.Value(target, reader.CreateSubReader()); } else { try { _current.Value(target, reader); } catch (UnknownEnumException e) { missing.Add(new UnknownFieldVarint(tag, e.Value)); } } } else if (tag.WireType == WireType.EndGroup) { break; } else if (tag.WireType < WireType.MaxValid) { missing.Add(tag, reader); } else { throw new NotSupportedException(); } } return(target); }
static object ForceEval(Env env, object exp) { KeyValuePair <object, Continue> p = Eval(env, exp, null); while (p.Value != null) { p = p.Value(p.Key); } return(p.Key); }
private static void addMenuItem(KeyValuePair <string, ModMenuItemClickedCallback> mod_kvp, Game.GUI.Controls.MenuItem modsGroup) { var item = new Game.GUI.Controls.MenuItem(mod_kvp.Key); item.Click += new Game.GUI.Controls.EventHandler((sender, args) => { mod_kvp.Value(); }); modsGroup.Items.Add(item); }
public IOperator Create(string operationString) { KeyValuePair <string, Func <string, IOperator> > operationToCreate = operationDictionary.FirstOrDefault(d => operationString.Contains(d.Key)); if (operationToCreate.Value == null) { throw new ArgumentException("The Input Parameter does not contain a valid operator"); } return(operationToCreate.Value(operationString)); }
private string RunWatchpoint(KeyValuePair <string, Func <string> > watch) { try { return(watch.Value()); } catch (Exception e) { return($"Watchpoint {watch.Key} threw exception: {e.Message}"); } }
protected override void CheckForDoubleAxisInput(KeyValuePair <AxisGesture, Action <Vector2> > binding) { SteamVR_Controller.Device device = SteamVR_Controller.Input(m_controllerNumber); switch (binding.Key.AxisAction) { case AxisAction.GetAxis: binding.Value(device.GetAxis(m_doubleAxisBindings[binding.Key])); break; } }
private void RunQuestionnaire(KeyValuePair <IIQuestionnaire, Action <string> > p, Message message, PalBot bot) { p.Key.Message = message; p.Key.Bot = bot; if (!string.IsNullOrEmpty(p.Key.AttributeInstance.CancelWord) && message.Content.ToLower().Trim() == p.Key.AttributeInstance.CancelWord) { QuestionnaireCanceled(p.Key); p.Key.Finish(); return; } p.Value(message.Content); }
// Update is called once per frame protected void FixedUpdate() { if (m_Run && m_Queue.Count > 0) { if (m_Queue.Peek().Key <= m_audioManager.TimeNow()) { KeyValuePair <double, Attack> value = m_Queue.Dequeue(); double StartTIme = value.Key; value.Value(); } } }
public HandlerPanel(Core.Teams team, KeyValuePair <string, Func <Core.TeamHandlerBase> > pair) { Pair = pair; TeamHandler = pair.Value(); Margin = new Thickness(10, 10, 0, 0); RadioButton.GroupName = team + "HandlerPanel"; RadioButton.Content = pair.Key; Children.Add(RadioButton); RadioButton.Checked += RadioButton_Checked; RadioButton.Unchecked += RadioButton_Unchecked; }
private SprotoTypeBase _gen(KeyValuePair <Type, typeFunc> field, int tag, byte[] buffer, int offset = 0) { if (field.Value != null) { SprotoTypeBase obj = field.Value(buffer, offset); if (obj.GetType() != field.Key) { throw new Exception("sproto type: " + obj.GetType().ToString() + "not is expected. [" + field.Key.ToString() + "]"); } return(obj); } return(null); }
//================================================================= static object ForceEval(Env env, object exp) { IASTNode node = Compile(null, TransformLibraryForm(exp)); GlobalEnv.Instance().ExtendTo(GlobalSymbolTable.Instance().GetSymbolCount()); KeyValuePair <object, Continue> p = node.Eval(env, (v => new KeyValuePair <object, Continue>(v, null)));; while (p.Value != null) { p = p.Value(p.Key); } return(p.Key); }
public override unsafe void Flush() { IntPtr commandListHandleMem = RenderCommandTempMemPool.GetLocalPool().Reserve((uint)IntPtr.Size); QueueCommand(new RenderCommand(RenderCommandInstruction.FinishCommandList, (IntPtr)(&commandListHandleMem))); uint offset = 0U; bool success; for (int i = 0; i < DeferredActions.Count; i++) { KeyValuePair <uint, Action> curAction = DeferredActions[i]; char *failReason = stackalloc char[InteropUtils.MAX_INTEROP_FAIL_REASON_STRING_LENGTH + 1]; success = NativeMethods.RenderPassManager_FlushInstructions( (IntPtr)failReason, RenderingModule.DeviceContext, RenderCommandList.AlignedPointer + (int)offset * sizeof(RenderCommand), curAction.Key - offset ); if (!success) { throw new NativeOperationFailedException(Marshal.PtrToStringUni((IntPtr)failReason)); } offset = curAction.Key; curAction.Value(); } char *failReason2 = stackalloc char[InteropUtils.MAX_INTEROP_FAIL_REASON_STRING_LENGTH + 1]; success = NativeMethods.RenderPassManager_FlushInstructions( (IntPtr)failReason2, RenderingModule.DeviceContext, RenderCommandList.AlignedPointer + (int)offset * sizeof(RenderCommand), CurListIndex - offset ); if (!success) { throw new NativeOperationFailedException(Marshal.PtrToStringUni((IntPtr)failReason2)); } lastCommandListHandle = commandListHandleMem; LosgapSystem.InvokeOnMaster(invokeOnMasterAction); CurListIndex = 0U; DeferredActions.Clear(); RenderCommandTempMemPool.GetLocalPool().FreeAll(); }
private RadioButton CreateRadioButton(KeyValuePair <string, Func <Map> > sample) { var radioButton = new RadioButton { AutoSize = true, Name = "radioButton1", Size = new System.Drawing.Size(85, 17), TabIndex = 4, TabStop = true, UseVisualStyleBackColor = true, Text = sample.Key }; radioButton.Click += (s, e) => mapControl1.Map = sample.Value(); return(radioButton); }
public static object Deserialize(Type returnType, string data) { if (data == null) { return(null); } if (handlers.ContainsKey(returnType)) { KeyValuePair <TypeSerializeHandler, TypeDeserializeHandler> pair = handlers[returnType]; return(pair.Value(data)); } StringReader textReader = new StringReader(data); object obj2 = new XmlSerializer(returnType).Deserialize(textReader); textReader.Close(); return(obj2); }
private UIElement CreateRadioButton(KeyValuePair <string, Func <Map> > sample) { var radioButton = new RadioButton { FontSize = 16, Content = sample.Key, Margin = new Thickness(4) }; radioButton.Click += (s, a) => { MapControl.Map.Layers.Clear(); MapControl.Map = sample.Value(); LayerList.Initialize(MapControl.Map.Layers); MapControl.Refresh(); }; return(radioButton); }
/// <summary> /// 执行委托方法 /// </summary> /// <param name="session">数据会话</param> /// <param name="id">实例主键ID</param> /// <param name="code">实例代码</param> /// <param name="item">事件</param> /// <param name="activityResource">活动资源</param> /// <returns>执行结果</returns> private static Boolean Execute(IDbSession session, int id, string code, KeyValuePair <EventFireTypeEnum, Func <int, string, IDelegateService, Boolean> > item, ActivityResource activityResource = null) { var result = false; if (item.Key == EventFireTypeEnum.OnProcessStarted || item.Key == EventFireTypeEnum.OnProcessRunning || item.Key == EventFireTypeEnum.OnProcessCompleted) { var delegateService = new ProcessDelegateService(session, id); delegateService.SetActivityResource(activityResource); result = item.Value(id, code, delegateService); } return(result); }
private string ProcessAction(string source, KeyValuePair <string, Func <string, string> > action) { var macroStart = MacroStart + action.Key; if (!source.Contains(macroStart)) { return(source); } var startIdx = source.IndexOf(macroStart); var endIdx = source.LastIndexOf(MacroEnd); var macroString = source.Substring(startIdx, endIdx - startIdx + 1); var macroResult = source.Replace(macroString, action.Value(macroString)); // рекурсивно проверяем все ли поменяли return(ProcessAction(macroResult, action)); }
private UIElement CreateRadioButton(KeyValuePair<string, Func<Map>> sample) { var radioButton = new RadioButton { FontSize = 16, Content = sample.Key, Margin = new Thickness(4) }; radioButton.Click += (s, a) => { MapControl.Map.Layers.Clear(); MapControl.Map = sample.Value(); LayerList.Initialize(MapControl.Map.Layers); MapControl.Refresh(); }; return radioButton; }
void Update() { if (SpritesToLoad.Count > 0) { KeyValuePair <string, LoadSprite> kvp = SpritesToLoad[0]; if (LoadedSprites.ContainsKey(kvp.Key)) { kvp.Value(LoadedSprites[kvp.Key]); SpritesToLoad.Remove(kvp); } else if (DownloadingNow == false) { DownloadingNow = true; StartCoroutine(LoadFromUrl(kvp.Key, kvp.Value)); SpritesToLoad.Remove(kvp); } } }
public static IEnumerable <Gate> LoadGates(string path) { Dictionary <Regex, Func <Match, Gate> > parseOptions = new Dictionary <Regex, Func <Match, Gate> >() { { new Regex(@"^(\w+|\d+) -> (\w+)$"), match => new Move(new Signal(match.Groups[1].Value), new Signal(match.Groups[2].Value)) }, { new Regex(@"^(\w+|\d+) AND (\w+|\d+) -> (\w+)$"), match => new And(new Signal(match.Groups[1].Value), new Signal(match.Groups[2].Value), new Signal(match.Groups[3].Value)) }, { new Regex(@"^(\w+|\d+) OR (\w+|\d+) -> (\w+)$"), match => new Or(new Signal(match.Groups[1].Value), new Signal(match.Groups[2].Value), new Signal(match.Groups[3].Value)) }, { new Regex(@"^NOT (\w+|\d+) -> (\w+)"), match => new Not(new Signal(match.Groups[1].Value), new Signal(match.Groups[2].Value)) }, { new Regex(@"^(\w+|\d+) LSHIFT (\w+|\d+) -> (\w+)$"), match => new LeftShift(new Signal(match.Groups[1].Value), ushort.Parse(match.Groups[2].Value), new Signal(match.Groups[3].Value)) }, { new Regex(@"^(\w+|\d+) RSHIFT (\w+|\d+) -> (\w+)$"), match => new RightShift(new Signal(match.Groups[1].Value), ushort.Parse(match.Groups[2].Value), new Signal(match.Groups[3].Value)) }, }; return(File.ReadLines(path).Select(x => { KeyValuePair <Regex, Func <Match, Gate> > kvp = parseOptions.Single(y => y.Key.Match(x).Success); return kvp.Value(kvp.Key.Match(x)); })); }
BootstrapResult ExecuteEntrypoint(KeyValuePair<Type, Func<IDictionary<string, object>, int>> entryPoint, IEnumerable<Assembly> assemblies, IEnumerable<string> consumedArgs) { var info = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase) { { "openwrap.syspath", _systemRootPath }, { "openwrap.cd", Environment.CurrentDirectory }, { "openwrap.shell.commandline", GetCommandLine() }, { "openwrap.shell.assemblies", assemblies.Select(x=>x.Location).ToList() }, { "openwrap.shell.version", _shellVersion}, { "openwrap.shell.args", consumedArgs.ToList() } }; return (BootstrapResult)entryPoint.Value(info); }
BootstrapResult ExecuteEntrypoint(string[] args, KeyValuePair<Type, Func<string[], int>> entryPoint) { return (BootstrapResult)entryPoint.Value(args); }
private IList<TestCaseData> BuildTestCasesForThens(IList<Context> parentContexts) { var testCases = new List<TestCaseData>(); if (!thens.Any()) return testCases; var setupText = new StringBuilder(); setupText.AppendLine(parentContexts.First().Description + ":"); // start with the spec method's name var first = true; foreach (var context in parentContexts.Skip(1).Where(c => c.IsNamedContext)) { setupText.AppendLine(context.Conjunction(first) + context.Description); first = false; } setupText.AppendLine("when " + when.Key); const string thenText = "then "; foreach (var spec in thens) { var parentContextsCapture = new List<Context>(parentContexts); var whenCapture = new KeyValuePair<string, Func<Task>>(when.Key, when.Value); Func<Task> executeTest = async () => { BeforeIfNotAlreadyRun(); try { var exceptionThrownAndAsserted = false; await InitializeContext(parentContextsCapture).ConfigureAwait(false); try { thrownException = null; await whenCapture.Value().ConfigureAwait(false); } catch (Exception ex) { thrownException = ex; } try { exceptionAsserted = false; await spec.Value().ConfigureAwait(false); } catch (Exception) { if (thrownException == null || exceptionAsserted) throw; } if (thrownException != null) { throw thrownException; } exceptionThrownAndAsserted = true; if (!exceptionThrownAndAsserted) { await spec.Value().ConfigureAwait(false); } } finally { After(); } }; var description = setupText + thenText + spec.Key + Environment.NewLine; testCases.Add(new TestCaseData(executeTest).SetName(description)); } return testCases; }
private static void AddMenuItem(KeyValuePair<string, ModMenuItemClickedCallback> modMenuItem, MenuItem modsGroup) { var item = new MenuItem(modMenuItem.Key); item.Click += (sender, args) => modMenuItem.Value(); modsGroup.Items.Add(item); }
private static void addMenuItem(KeyValuePair<string, ModMenuItemClickedCallback> mod_kvp, Game.GUI.Controls.MenuItem modsGroup) { var item = new Game.GUI.Controls.MenuItem(mod_kvp.Key); item.Click += new Game.GUI.Controls.EventHandler((sender, args) => { mod_kvp.Value(); }); modsGroup.Items.Add(item); }