static void Main() { var actionsNames = new[] { "Add", "Subtract", "Multiply", "Divide", "Save", "Remove", "Remove All", "Calculate", "Exit" }; var actions = new ActionDelegate[] {Add, Subtract, Multiply, Divide, SaveVarInMemory, RemoveVarFromMemory, RemoveAllVarsFromMemory, Calculate, Close}; using (var calculator = new CalculatorServiceClient()) { do { Console.Clear(); var choice = RunMenu(actionsNames); try { actions[choice](calculator); } catch (FaultException fe) { Console.WriteLine("FaultException {0} with reason {1}", fe.Message, fe.Reason); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } Console.Write("\nPress any key to continue... "); Console.ReadKey(true); } while (!_willClose); } }
public DelayAction(int milliseconds, ActionDelegate actionMethod, bool stopAfterOne) { this.actionMethod = actionMethod; actionTimer.Interval = new TimeSpan(0, 0, 0, 0, milliseconds); actionTimer.Tick += new EventHandler(actionTimer_Tick); this.stopAfterOne = stopAfterOne; }
/// <summary>start action</summary> public void StartAction() { IsStoped = false; mStopActionDelegate = null; InitAction(); ProcAction(); }
public void RegisterActionImplementation(string action, ActionDelegate actionDelegate) { Guard.ArgumentNotNullOrEmptyString(action, "action"); Guard.ArgumentNotNull(actionDelegate, "actionDelegate"); _actionImplementations[action] = actionDelegate; }
/// <summary>start action</summary> /// <param name="_func">action 종료 시 실행할 delegate</param> public void StartAction(ActionDelegate _func) { IsStoped = false; mStopActionDelegate = _func; InitAction(); ProcAction(); }
public void Add (String name, String localizedName, string description, ActionDelegate doAction) { foreach (ActionDescription ad in actions) if (ad.name == name) return; actions.Add (new ActionDescription (name, localizedName, description, doAction)); }
/// <summary> /// Signal that the action Unsubscribe is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// Unsubscribe must be overridden if this is called.</remarks> protected void EnableActionUnsubscribe() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("Unsubscribe"); List<String> allowedValues = new List<String>(); action.AddInputParameter(new ParameterString("Sid", allowedValues)); iDelegateUnsubscribe = new ActionDelegate(DoUnsubscribe); EnableAction(action, iDelegateUnsubscribe, GCHandle.ToIntPtr(iGch)); }
public ActionCounter(int fromValue, int toValue, int delta, ActionDelegate binder) : base(binder) { this.fromValue = fromValue; this.toValue = toValue; this.delta = delta; this.current = fromValue; }
/// <summary> /// Signal that the action GetColor is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// GetColor must be overridden if this is called.</remarks> protected void EnableActionGetColor() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("GetColor"); action.AddInputParameter(new ParameterUint("Index")); action.AddOutputParameter(new ParameterUint("Color")); iDelegateGetColor = new ActionDelegate(DoGetColor); EnableAction(action, iDelegateGetColor, GCHandle.ToIntPtr(iGch)); }
public static void Time(string name, int iteration, ActionDelegate action) { if (String.IsNullOrEmpty(name)) { return; } if (action == null) { return; } //1. Print name ConsoleColor currentForeColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(name); // 2. Record the latest GC counts //GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); GC.Collect(GC.MaxGeneration); int[] gcCounts = new int[GC.MaxGeneration + 1]; for (int i = 0; i <= GC.MaxGeneration; i++) { gcCounts[i] = GC.CollectionCount(i); } // 3. Run action Stopwatch watch = new Stopwatch(); watch.Start(); long ticksFst = GetCurrentThreadTimes(); //100 nanosecond one tick for (int i = 0; i < iteration; i++) action(); long ticks = GetCurrentThreadTimes() - ticksFst; watch.Stop(); // 4. Print CPU Console.ForegroundColor = currentForeColor; Console.WriteLine("\tTime Elapsed:\t\t" + watch.ElapsedMilliseconds.ToString("N0") + "ms"); Console.WriteLine("\tTime Elapsed (one time):" + (watch.ElapsedMilliseconds / iteration).ToString("N0") + "ms"); Console.WriteLine("\tCPU time:\t\t" + (ticks * 100).ToString("N0") + "ns"); Console.WriteLine("\tCPU time (one time):\t" + (ticks * 100 / iteration).ToString("N0") + "ns"); // 5. Print GC for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i) - gcCounts[i]; Console.WriteLine("\tGen " + i + ": \t\t\t" + count); } Console.WriteLine(); }
/// <summary> /// Signal that the action GetPropertyUpdates is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// GetPropertyUpdates must be overridden if this is called.</remarks> protected void EnableActionGetPropertyUpdates() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("GetPropertyUpdates"); List<String> allowedValues = new List<String>(); action.AddInputParameter(new ParameterString("ClientId", allowedValues)); action.AddOutputParameter(new ParameterString("Updates", allowedValues)); iDelegateGetPropertyUpdates = new ActionDelegate(DoGetPropertyUpdates); EnableAction(action, iDelegateGetPropertyUpdates, GCHandle.ToIntPtr(iGch)); }
/// <summary> /// Signal that the action Renew is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// Renew must be overridden if this is called.</remarks> protected void EnableActionRenew() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("Renew"); List<String> allowedValues = new List<String>(); action.AddInputParameter(new ParameterString("Sid", allowedValues)); action.AddInputParameter(new ParameterUint("RequestedDuration")); action.AddOutputParameter(new ParameterUint("Duration")); iDelegateRenew = new ActionDelegate(DoRenew); EnableAction(action, iDelegateRenew, GCHandle.ToIntPtr(iGch)); }
public KeyboardAction(Keys key, bool shift, bool control, bool alt, bool allowreadonly, ActionDelegate actionDelegate) { this.Key = key; this.Control = control; this.Alt = alt; this.Shift = shift; this.Action = actionDelegate; this.AllowReadOnly = allowreadonly; }
public KeyboardAction(Keys key, bool shift, bool control, bool alt, bool allowreadonly, ActionDelegate actionDelegate) { Key = key; Control = control; Alt = alt; Shift = shift; Action = actionDelegate; AllowReadOnly = allowreadonly; }
/// <summary> /// Signal that the action GetColorComponents is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// GetColorComponents must be overridden if this is called.</remarks> protected void EnableActionGetColorComponents() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("GetColorComponents"); action.AddInputParameter(new ParameterUint("Color")); action.AddOutputParameter(new ParameterUint("Brightness")); action.AddOutputParameter(new ParameterUint("Red")); action.AddOutputParameter(new ParameterUint("Green")); action.AddOutputParameter(new ParameterUint("Blue")); iDelegateGetColorComponents = new ActionDelegate(DoGetColorComponents); EnableAction(action, iDelegateGetColorComponents, GCHandle.ToIntPtr(iGch)); }
/// <summary>start action</summary> /// <param name="_actionName">실행할 action name</param> /// <param name="_func">action 종료 후 실행할 delegate</param> public void StartAction(string _actionName, ActionDelegate _func) { if (mActionDic[_actionName] != null) { mActionDic[_actionName].StartAction(_func); } else { Debug.LogError("can't find action from " + _actionName); } }
protected Timer setTimer(int interval, ActionDelegate action) { var timer = new Timer(); timer.Elapsed += delegate { action.Invoke(); }; timer.Interval = interval; timer.Start(); return timer; }
protected Timer after(int timeout, ActionDelegate action) { var timer = new Timer(); timer.Elapsed += delegate { action.Invoke(); timer.Stop(); }; timer.Interval = timeout; timer.Start(); return timer; }
public ActionHandler(ControllerFactory owner, MethodInfo methodInfo) { this.owner = owner; this.methodInfo = methodInfo; this.actionDelegate = ActionDelegateFactory.Create(methodInfo); this.useThreadPool = true; var utp = (UseThreadPoolAttribute)methodInfo.GetCustomAttributes(typeof(UseThreadPoolAttribute), false).FirstOrDefault(); if (utp != null) this.useThreadPool = utp.UseThreadPool; else this.useThreadPool = owner.UseThreadPool; }
/// <summary> /// Signal that the action Subscribe is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// Subscribe must be overridden if this is called.</remarks> protected void EnableActionSubscribe() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("Subscribe"); List<String> allowedValues = new List<String>(); action.AddInputParameter(new ParameterString("ClientId", allowedValues)); action.AddInputParameter(new ParameterString("Udn", allowedValues)); action.AddInputParameter(new ParameterString("Service", allowedValues)); action.AddInputParameter(new ParameterUint("RequestedDuration")); action.AddOutputParameter(new ParameterString("Sid", allowedValues)); action.AddOutputParameter(new ParameterUint("Duration")); iDelegateSubscribe = new ActionDelegate(DoSubscribe); EnableAction(action, iDelegateSubscribe, GCHandle.ToIntPtr(iGch)); }
protected override Composite CreateBehavior() { Composite[] children=new Composite[2]; ActionDelegate actionDelegateCast=new ActionDelegate(Funky.FunkyTPBehavior); Sequence sequenceblank=new Sequence( new Zeta.TreeSharp.Action(actionDelegateCast) ); children[0]=new Zeta.TreeSharp.Decorator(new CanRunDecoratorDelegate(Funky.FunkyTPOverlord), sequenceblank); children[1]=new Zeta.TreeSharp.Action(new ActionSucceedDelegate(FlagTagAsCompleted)); return new PrioritySelector(children); }
public StartingPlayer() : base() { this.Stage = ActionStages.OnBoard; if( Properties.Settings.Default.GameVersion == Properties.Resources.FamilyGameVersionString ) { this.ActionDelegate = new ActionDelegate( this.TakeActionFamily ); } else if( Properties.Settings.Default.GameVersion == Properties.Resources.RegularGameVersionString ) { this.ActionDelegate = new ActionDelegate( this.TakeActionRegular ); } }
public int Register(int modifier, Keys key, Form form, ActionDelegate action) { var r = new RegisteredKey() { modifier = modifier, key = (int)key, hWnd = form.Handle, form = form, action = action }; RegisteredKeys.Add(GetHashCode(r),r); if (RegisterHotKey(r.hWnd, r.id, r.modifier, r.key)) return r.id; else return 0; }
public static CodeTimerResult Time(string name, int iteration, ActionDelegate action) { if (String.IsNullOrEmpty(name)) { return null; } if (action == null) { return null; } var result = new CodeTimerResult(); result = result.Reset(); result.Name = name; result.Iteration = iteration; GC.Collect(GC.MaxGeneration); var gcCounts = new int[GC.MaxGeneration + 1]; for (int i = 0; i <= GC.MaxGeneration; i++) { gcCounts[i] = GC.CollectionCount(i); } // 3. Run action var watch = new Stopwatch(); watch.Start(); long ticksFst = GetCurrentThreadTimes(); //100 nanosecond one tick for (int i = 0; i < iteration; i++) action(); long ticks = GetCurrentThreadTimes() - ticksFst; watch.Stop(); // 4. Print CPU result.TimeElapsed = watch.ElapsedMilliseconds; result.CpuCycles = ticks*100; // 5. Print GC for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i) - gcCounts[i]; result.GenerationList[i] = count; } return result; }
public static void TryAction(TimeSpan duration, ActionDelegate action) { DateTime timeout = DateTime.Now + duration; while (DateTime.Now < timeout) { try { action(); return; } catch { // Will retry. } Thread.Sleep(TimeSpan.FromMilliseconds(500)); } action(); }
public Asynchronizer() { m_Lock = new object(); DoAction = new ActionDelegate(ActionWrapper); }
public ActionNode(ActionDelegate action) { _action = action; }
public void SubAction(ActionDelegate newAction) { _action += newAction; }
public DelegatedAction(ActionDelegate action) { this.action = action; }
/// <summary> /// Signal that the action Play is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// Play must be overridden if this is called.</remarks> protected void EnableActionPlay() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("Play"); iDelegatePlay = new ActionDelegate(DoPlay); EnableAction(action, iDelegatePlay, GCHandle.ToIntPtr(iGch)); }
protected Response ProcessConversion(string controllerName, string fileName, string folderName, string outFileExtension, bool createZip, ActionDelegate action, bool isMultiple) { string logMsg = "ControllerName: " + controllerName + " FileName: " + fileName + " OutFileExtension: " + outFileExtension; var watch = System.Diagnostics.Stopwatch.StartNew(); string guid = folderName; string sourceFolder = AppSettings.WorkingDirectory + folderName; fileName = sourceFolder + "/" + fileName; string outfileName = Path.GetFileNameWithoutExtension(fileName) + outFileExtension; string outPath = AppSettings.OutputDirectory + "/" + guid; string zipOutfileName = Path.GetFileNameWithoutExtension(fileName) + ".zip"; string zipOutPath = AppSettings.OutputDirectory + zipOutfileName; string zipOutFolder = AppSettings.OutputDirectory + guid; string statusValue = "OK"; int statusCodeValue = 200; Exception ex = null; try { if (System.IO.File.Exists(zipOutPath)) { System.IO.File.Delete(zipOutPath); } if (!createZip) { if (!Directory.Exists(outPath)) { Directory.CreateDirectory(outPath); } } outPath += "/" + outfileName; action(fileName, outPath, zipOutFolder); // Log information to NLogging database logMsg = "TimeElapsed: " + watch.Elapsed.ToString("mm\\:ss") + ", " + logMsg; } catch (Exception exc) { string statusMessage = "500 " + exc.Message; statusValue = exc.Message; if (exc.Message.Contains("The given key was not present in the dictionary")) { statusValue = "Conversion from '" + Path.GetExtension(fileName).ToUpper() + "' to '" + outFileExtension.ToUpper() + "' is not supported."; } statusCodeValue = 500; // Log error message to NLogging database logMsg = "TimeElapsed: " + watch.Elapsed.ToString("mm\\:ss") + ", " + logMsg; ex = exc; } return(new Response { FileName = (createZip ? outfileName : folderName + "/" + outfileName), Status = statusValue, StatusCode = statusCodeValue, exc = ex }); }
public static void TimeDelegate(string name, int iteration, ActionDelegate action) { if (String.IsNullOrEmpty(name)) { return; } if (action == null) { return; } //1. Print name ConsoleColor currentForeColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(name); // 2. Record the latest GC counts //GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); GC.Collect(GC.MaxGeneration); int[] gcCounts = new int[GC.MaxGeneration + 1]; for (int i = 0; i <= GC.MaxGeneration; i++) { gcCounts[i] = GC.CollectionCount(i); } // 3. Run action Stopwatch watch = new Stopwatch(); watch.Start(); long ticksFst = GetCurrentThreadTimes(); //100 nanosecond one tick for (int i = 0; i < iteration; i++) { action(); } long ticks = GetCurrentThreadTimes() - ticksFst; watch.Stop(); // 4. Print CPU Console.ForegroundColor = currentForeColor; Console.WriteLine("\tTime Elapsed:\t\t" + watch.ElapsedMilliseconds.ToString("N0") + "ms"); Console.WriteLine("\tTime Elapsed (one time):" + (watch.ElapsedMilliseconds / iteration).ToString("N0") + "ms"); Console.WriteLine("\tCPU time:\t\t" + (ticks * 100).ToString("N0") + "ns"); Console.WriteLine("\tCPU time (one time):\t" + (ticks * 100 / iteration).ToString("N0") + "ns"); // 5. Print GC for (int i = 0; i <= GC.MaxGeneration; i++) { int count = GC.CollectionCount(i) - gcCounts[i]; Console.WriteLine("\tGen " + i + ": \t\t\t" + count); } Console.WriteLine(); }
/// <summary> /// Signal that the action GetProtocolInfo is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// GetProtocolInfo must be overridden if this is called.</remarks> protected void EnableActionGetProtocolInfo() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("GetProtocolInfo"); action.AddOutputParameter(new ParameterRelated("Source", iPropertySourceProtocolInfo)); action.AddOutputParameter(new ParameterRelated("Sink", iPropertySinkProtocolInfo)); iDelegateGetProtocolInfo = new ActionDelegate(DoGetProtocolInfo); EnableAction(action, iDelegateGetProtocolInfo, GCHandle.ToIntPtr(iGch)); }
protected override void OnInit() { OnDispose(); _senders = new List <RabbitMQueue>(); _receiver = null; _receiverStopBuffered = ActionDelegate.Create(RemoveReceiverConsumer).CreateBufferedAction(60000); if (Config != null) { if (Config.ClientQueues != null) { _clientQueues = Config.ClientQueues.FirstOf( c => c.EnvironmentName?.SplitAndTrim(",").Contains(Core.EnvironmentName) == true && c.MachineName?.SplitAndTrim(",").Contains(Core.MachineName) == true, c => c.EnvironmentName?.SplitAndTrim(",").Contains(Core.EnvironmentName) == true, c => c.MachineName?.SplitAndTrim(",").Contains(Core.MachineName) == true, c => c.EnvironmentName.IsNullOrWhitespace()); } _senderOptions = Config.RequestOptions?.ClientSenderOptions; _receiverOptions = Config.ResponseOptions?.ClientReceiverOptions; _receiverOptionsTimeout = TimeSpan.FromSeconds(_receiverOptions?.TimeoutInSec ?? 20); UseSingleResponseQueue = _receiverOptions?.Parameters?[ParameterKeys.SingleResponseQueue].ParseTo(true) ?? true; if (_clientQueues != null) { if (_clientQueues.SendQueues?.Any() == true) { foreach (var queue in _clientQueues.SendQueues) { var rabbitQueue = new RabbitMQueue(queue); rabbitQueue.EnsureConnectionAsync(2000, int.MaxValue).WaitAndResults(); rabbitQueue.EnsureExchange(); _senders.Add(rabbitQueue); } } if (_clientQueues.RecvQueue != null && !SendOnly) { _receiver = new RabbitMQueue(_clientQueues.RecvQueue); } } if (_senderOptions is null) { throw new Exception("Client Sender Options is Null."); } _priority = (byte)(_senderOptions.MessagePriority == MQMessagePriority.High ? 9 : _senderOptions.MessagePriority == MQMessagePriority.Low ? 1 : 5); _expiration = (_senderOptions.MessageExpirationInSec * 1000).ToString(); _deliveryMode = (byte)(_senderOptions.Recoverable ? 2 : 1); CreateReceiverConsumerAsync().WaitAsync(); } Core.Status.Attach(collection => { if (_senders != null) { for (var i = 0; i < _senders.Count; i++) { collection.Add("Sender: {0} ".ApplyFormat(i), _senders[i].Route + " - " + _senders[i].Name); } } if (_receiver != null) { collection.Add("Receiver: {0}", _receiver.Route + " - " + _receiver.Name); } }); }
/// <summary> /// Initializes a new instance of the <see cref="ActionNode{T}"/> class. /// </summary> /// <param name="action">The action to execute.</param> public ActionNode(ActionDelegate <T> action) : base(action) { }
public BehaviorTreeBuilder <T> Action(ActionDelegate action = null) { return(this.Leaf(new Action <T>(action))); }
private Response ProcessTask(string fileName, string folderName, string outFileExtension, bool createZip, bool checkNumberofPages, ActionDelegate action) { Aspose.CAD.Live.Demos.UI.Models.License.SetAsposeCADLicense(); return(Process(this.GetType().Name, fileName, folderName, outFileExtension, createZip, checkNumberofPages, this.GetType().Name, action)); }
public Command(string text, ActionDelegate action) { this.text = text; this.action = action; }
protected async Task <Response> Process2(string controllerName, string fileName, string folderName, string outFileExtension, bool createZip, ActionDelegate action) { string logMsg = "ControllerName: " + controllerName + " FileName: " + fileName + " OutFileExtension: " + outFileExtension; string guid = folderName; string sourceFolder = AppSettings.WorkingDirectory + folderName; fileName = sourceFolder + "/" + fileName; string outfileName = Path.GetFileNameWithoutExtension(fileName) + outFileExtension; string outPath = AppSettings.OutputDirectory + "/" + guid; string zipOutfileName = Path.GetFileNameWithoutExtension(fileName) + ".zip"; string zipOutPath = AppSettings.OutputDirectory + zipOutfileName; string zipOutFolder = AppSettings.OutputDirectory + guid; string statusValue = "OK"; int statusCodeValue = 200; try { if (System.IO.File.Exists(zipOutPath)) { System.IO.File.Delete(zipOutPath); } if (!createZip) { if (!Directory.Exists(outPath)) { Directory.CreateDirectory(outPath); } } outPath += "/" + outfileName; action(fileName, outPath, zipOutFolder); if (createZip) { outfileName = Path.GetFileNameWithoutExtension(fileName) + outFileExtension; outPath = zipOutFolder + "/" + outfileName; Directory.CreateDirectory(zipOutFolder); } if (createZip) { ZipFile.CreateFromDirectory(zipOutFolder, zipOutPath); Directory.Delete(zipOutFolder, true); outfileName = zipOutfileName; } try { Directory.Delete(sourceFolder, true); } catch { } } catch (Exception exc) { statusValue = "500 " + exc.Message; statusCodeValue = 500; } return(await Task.FromResult(new Response { FileName = (createZip ? outfileName : folderName + "/" + outfileName), Status = statusValue, StatusCode = statusCodeValue })); }
private static IEnumerator wait(float _duration, ActionDelegate _onFinish) { yield return(new WaitForSeconds(_duration)); _onFinish(); }
protected async Task <Response> Process(string controllerName, string fileName, string folderName, string outFileExtension, bool createZip, ActionDelegate action) { string logMsg = "ControllerName: " + controllerName + " FileName: " + fileName + " OutFileExtension: " + outFileExtension; var watch = System.Diagnostics.Stopwatch.StartNew(); string guid = folderName; string sourceFolder = AppSettings.WorkingDirectory + folderName; fileName = sourceFolder + "/" + fileName; string outfileName = Path.GetFileNameWithoutExtension(fileName) + outFileExtension; string outPath = AppSettings.OutputDirectory + "/" + guid; string zipOutfileName = Path.GetFileNameWithoutExtension(fileName) + ".zip"; string zipOutPath = AppSettings.OutputDirectory + zipOutfileName; string zipOutFolder = AppSettings.OutputDirectory + guid; string statusValue = "OK"; int statusCodeValue = 200; Exception ex = null; try { if (System.IO.File.Exists(zipOutPath)) { System.IO.File.Delete(zipOutPath); } if (!createZip) { if (!Directory.Exists(outPath)) { Directory.CreateDirectory(outPath); } } outPath += "/" + outfileName; action(fileName, outPath, zipOutFolder); if (Directory.GetFiles(AppSettings.OutputDirectory + "/" + guid + "/").Length > 1) { createZip = true; } else { createZip = false; } if (createZip) { outfileName = Path.GetFileNameWithoutExtension(fileName) + outFileExtension; outPath = zipOutFolder + "/" + outfileName; Directory.CreateDirectory(zipOutFolder); } if (createZip) { ZipFile.CreateFromDirectory(zipOutFolder, zipOutPath); Directory.Delete(zipOutFolder, true); outfileName = zipOutfileName; } try { //Directory.Delete(sourceFolder, true); } catch { } } catch (Exception exc) { string statusMessage = "500 " + exc.Message; statusValue = exc.Message; if (exc.Message.Contains("The given key was not present in the dictionary")) { statusValue = "Conversion from '" + Path.GetExtension(fileName).ToUpper() + "' to '" + outFileExtension.ToUpper() + "' is not supported."; } statusCodeValue = 500; ex = exc; } return(await Task.FromResult(new Response { FileName = (createZip ? outfileName : folderName + "/" + outfileName), Status = statusValue, StatusCode = statusCodeValue, exc = ex })); }
public static void Execute(Dictionary <string, string> _params, ActionDelegate _onFinish) { string targetGameObject = ""; if (!_params.TryGetValue("targetgameobject", out targetGameObject)) { Log.Error("RotateFrom", "need params targetgameobject"); return; } string x = ""; if (!_params.TryGetValue("x", out x)) { Log.Error("RotateFrom", "need params x"); return; } string y = ""; if (!_params.TryGetValue("y", out y)) { Log.Error("RotateFrom", "need params y"); return; } string z = ""; if (!_params.TryGetValue("z", out z)) { Log.Error("RotateFrom", "need params z"); return; } string duration = ""; if (!_params.TryGetValue("duration", out duration)) { Log.Error("RotateFrom", "need params duration"); return; } Vector3 vector = new Vector3(float.Parse(x), float.Parse(y), float.Parse(z)); float time = float.Parse(duration); try { GameObject go = null; if (targetGameObject.Equals("camera")) { go = CameraMgr.GetMainCamera(); } else { go = ResourceMgr.FindGameObject(targetGameObject); } if (go != null) { rotateFrom(go, vector, time, () => { _onFinish(); return; }); } else { Log.Error("RotateFrom", "[{0}] GameObject is not exist...", targetGameObject); } } catch (System.Exception e) { Log.Error("RotateFrom", "Parse json has error: " + e.Message); } }
/// <summary> /// Signal that the action Stop is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// Stop must be overridden if this is called.</remarks> protected void EnableActionStop() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("Stop"); iDelegateStop = new ActionDelegate(DoStop); EnableAction(action, iDelegateStop, GCHandle.ToIntPtr(iGch)); }
private Response ProcessTask(string fileName, string folderName, string outFileExtension, bool createZip, bool checkNumberofPages, ActionDelegate action) { License.SetAsposeGisLicense(); return(Process(this.GetType().Name, fileName, folderName, outFileExtension, createZip, checkNumberofPages, (new StackTrace()).GetFrame(5).GetMethod().Name, action)); }
private static void rotateFrom(GameObject _go, Vector3 _rotation, float _duration, ActionDelegate _onFinish) { Hashtable hash = new Hashtable(); hash.Add("easeType", iTween.EaseType.linear); hash.Add("rotation", _rotation); hash.Add("time", _duration); iTween.RotateFrom(_go, hash); CoroutineMgr.Start(wait(_duration, () => { _onFinish(); })); }
public ContextMenuTreeView() { ActionHandler = new ActionDelegate(this); ActionHandler.PerformShowMenu += PerformShowMenu; }
public void SetAction(Action.eActionType actionType) { startActionHandler = actions[(int)actionType].StartAction; stopActionHandler = actions[(int)actionType].StopAction; }
public MoveCursorCallback(ActionDelegate action = null, AudioClip sound = null) { this.Action = action; this.Sound = sound; }
public UseHotkeyAction(KeyboardHelper helper, ActionDelegate action, HotkeyDelegate hotkey) : base(action) { KeyboardHelper = helper; Hotkey = hotkey; }
public QueueEntry(ActionDelegate action, TimeSpan timeout) { Action = action; Timeout = timeout; CreatedAt = DateTime.Now; }
public Action(float duration, ActionDelegate actionDelegate) { this.duration = duration; this.actionDelegate = actionDelegate; }
//---------------------------- // STATUS //---------------------------- // lock movement for specified number of frames // sets an action to continue under movement lock public void LockMovement(float amt, ActionDelegate tmp) { timer = amt; act = tmp; }
/// <summary> /// Signal that the action GetCurrentConnectionIDs is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// GetCurrentConnectionIDs must be overridden if this is called.</remarks> protected void EnableActionGetCurrentConnectionIDs() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("GetCurrentConnectionIDs"); action.AddOutputParameter(new ParameterRelated("ConnectionIDs", iPropertyCurrentConnectionIDs)); iDelegateGetCurrentConnectionIDs = new ActionDelegate(DoGetCurrentConnectionIDs); EnableAction(action, iDelegateGetCurrentConnectionIDs, GCHandle.ToIntPtr(iGch)); }
public void RegisterActionImplementation(string action, ActionDelegate actionDelegate) { ActionNames.Add(action); }
/// <summary> /// Signal that the action ConnectionComplete is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// ConnectionComplete must be overridden if this is called.</remarks> protected void EnableActionConnectionComplete() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("ConnectionComplete"); action.AddInputParameter(new ParameterInt("ConnectionID")); iDelegateConnectionComplete = new ActionDelegate(DoConnectionComplete); EnableAction(action, iDelegateConnectionComplete, GCHandle.ToIntPtr(iGch)); }
protected Response Process(string modelName, string fileName, string folderName, string outFileExtension, bool createZip, bool checkNumberofPages, string methodName, ActionDelegate action, bool deleteSourceFolder = true, string zipFileName = null) { string guid = Guid.NewGuid().ToString(); string outFolder = ""; string sourceFolder = Config.Configuration.WorkingDirectory + folderName; fileName = sourceFolder + "\\" + fileName; string fileExtension = Path.GetExtension(fileName).ToLower(); string outfileName = Path.GetFileNameWithoutExtension(fileName) + outFileExtension; string outPath = ""; string zipOutFolder = Config.Configuration.OutputDirectory + guid; string zipOutfileName, zipOutPath; if (string.IsNullOrEmpty(zipFileName)) { zipOutfileName = guid + ".zip"; zipOutPath = Config.Configuration.OutputDirectory + zipOutfileName; } else { var guid2 = Guid.NewGuid().ToString(); outFolder = guid2; zipOutfileName = zipFileName + ".zip"; zipOutPath = Config.Configuration.OutputDirectory + guid2; Directory.CreateDirectory(zipOutPath); zipOutPath += "/" + zipOutfileName; } if (createZip) { outfileName = Path.GetFileNameWithoutExtension(fileName) + outFileExtension; outPath = zipOutFolder + "/" + outfileName; Directory.CreateDirectory(zipOutFolder); } else { outFolder = guid; outPath = Config.Configuration.OutputDirectory + outFolder; Directory.CreateDirectory(outPath); outPath += "/" + outfileName; } string statusValue = "OK"; int statusCodeValue = 200; try { action(fileName, outPath, zipOutFolder); if (createZip) { ZipFile.CreateFromDirectory(zipOutFolder, zipOutPath); Directory.Delete(zipOutFolder, true); outfileName = zipOutfileName; } if (deleteSourceFolder) { System.GC.Collect(); System.GC.WaitForPendingFinalizers(); Directory.Delete(sourceFolder, true); } } catch (Exception ex) { statusCodeValue = 500; statusValue = "500 " + ex.Message; } return(new Response { FileName = outfileName, FolderName = outFolder, Status = statusValue, StatusCode = statusCodeValue, }); }
/// <summary> /// Signal that the action GetCurrentConnectionInfo is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// GetCurrentConnectionInfo must be overridden if this is called.</remarks> protected void EnableActionGetCurrentConnectionInfo() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("GetCurrentConnectionInfo"); List<String> allowedValues = new List<String>(); action.AddInputParameter(new ParameterInt("ConnectionID")); action.AddOutputParameter(new ParameterInt("RcsID")); action.AddOutputParameter(new ParameterInt("AVTransportID")); action.AddOutputParameter(new ParameterString("ProtocolInfo", allowedValues)); action.AddOutputParameter(new ParameterString("PeerConnectionManager", allowedValues)); action.AddOutputParameter(new ParameterInt("PeerConnectionID")); allowedValues.Add("Input"); allowedValues.Add("Output"); action.AddOutputParameter(new ParameterString("Direction", allowedValues)); allowedValues.Clear(); allowedValues.Add("OK"); allowedValues.Add("ContentFormatMismatch"); allowedValues.Add("InsufficientBandwidth"); allowedValues.Add("UnreliableChannel"); allowedValues.Add("Unknown"); action.AddOutputParameter(new ParameterString("Status", allowedValues)); allowedValues.Clear(); iDelegateGetCurrentConnectionInfo = new ActionDelegate(DoGetCurrentConnectionInfo); EnableAction(action, iDelegateGetCurrentConnectionInfo, GCHandle.ToIntPtr(iGch)); }
/* * Wrapper for calling an action internally. */ public bool action_internal(ActionDelegate action, params object[] args) { return(action(args)); }
/// <summary> /// Signal that the action PrepareForConnection is supported. /// </summary> /// <remarks>The action's availability will be published in the device's service.xml. /// PrepareForConnection must be overridden if this is called.</remarks> protected void EnableActionPrepareForConnection() { OpenHome.Net.Core.Action action = new OpenHome.Net.Core.Action("PrepareForConnection"); List<String> allowedValues = new List<String>(); action.AddInputParameter(new ParameterString("RemoteProtocolInfo", allowedValues)); action.AddInputParameter(new ParameterString("PeerConnectionManager", allowedValues)); action.AddInputParameter(new ParameterInt("PeerConnectionID")); allowedValues.Add("Input"); allowedValues.Add("Output"); action.AddInputParameter(new ParameterString("Direction", allowedValues)); allowedValues.Clear(); action.AddOutputParameter(new ParameterInt("ConnectionID")); action.AddOutputParameter(new ParameterInt("AVTransportID")); action.AddOutputParameter(new ParameterInt("RcsID")); iDelegatePrepareForConnection = new ActionDelegate(DoPrepareForConnection); EnableAction(action, iDelegatePrepareForConnection, GCHandle.ToIntPtr(iGch)); }
public XtActionRec(string name, bool CausesSubmit, ActionDelegate fn) { this.CausesSubmit = CausesSubmit; this.proc = fn; this.name = name.ToLower(); }