public object Invoke(object owner, params object[] parameters) { if (method != null) { OnMethodInvoked?.Invoke(); return(method.Invoke(owner, parameters)); } else if (property != null) { if (parameters == null || parameters.Length == 0) { //if no parameters were passed, then get if (get != null) { return(get.Invoke(owner, parameters)); } } else if (parameters != null && parameters.Length == 1) { //if 1 parameter was passed, then set if (set != null) { property.SetValue(owner, parameters[0]); } } } else if (field != null) { if (parameters == null || parameters.Length == 0) { return(field.GetValue(owner)); } else if (parameters != null && parameters.Length == 1) { field.SetValue(owner, parameters[0]); } } return(null); }
public async void Start(string args, bool hold = false, bool ami = false, ACMHeartbeatFlag heartbeat = ACMHeartbeatFlag.HeartbeatOff) { Hold = hold; amiEnabled = ami; acmHeartbeat = heartbeat; if (communicator == null || communicator.isShutdown()) { Status = BundleStatus.Starting; try { const int SIZE_MB = 128; const int SIZE_MAX = SIZE_MB * 1024 * 1024; if (contentSizeMB < 0 || contentSizeMB > SIZE_MB) { contentSizeMB = 1; } var initData = new InitializationData(); initData.properties = Util.createProperties(); initData.properties.setProperty("Ice.MessageSizeMax", $"{SIZE_MAX}"); initData.properties.setProperty("Filesystem.MaxFileSize", $"{SIZE_MAX}"); initData.properties.setProperty("Ice.ACM.Heartbeat", $"{(int)acmHeartbeat}"); communicator = Util.initialize(initData); WorkerPrx workerPrx = WorkerPrxHelper.checkedCast(communicator.stringToProxy(args)); if (workerPrx == null) { throw new ApplicationException("Invalid Proxy"); } isRunning = true; Status = BundleStatus.Running; while (isRunning && communicator != null) { if (Hold) { Thread.Sleep(100); continue; } var operation = operations[counter % operations.Count]; ++counter; OnMethodInvoked?.Invoke(operation, amiEnabled); if (amiEnabled) { try { var result = workerPrx?.PerformActionEx(operation, contentSizeMB); } catch (OperationException ex) { OnExceptionOccured?.Invoke(ex); } Thread.Sleep(rand.Next(200, 1000)); } else { try { var result = workerPrx?.PerformAction(operation, contentSizeMB); } catch (OperationException ex) { OnExceptionOccured?.Invoke(ex); } Thread.Sleep(500); } } Status = BundleStatus.Idle; } catch (System.Exception ex) { Status = BundleStatus.Exception; OnExceptionOccured?.Invoke(ex); } } else { isRunning = false; Status = BundleStatus.Unknown; } }