예제 #1
0
        public static void Process <T>(OnProcess <T> process, Logger log)
            where T : GameObject
        {
            foreach (T obj in Sims3.Gameplay.Queries.GetGlobalObjects <T>())
            {
                if (process(obj))
                {
                    if (log != null)
                    {
                        log("  Global Altered");
                    }
                }
            }

            foreach (T obj in Sims3.Gameplay.Queries.GetObjects <T>())
            {
                if (process(obj))
                {
                    if (log != null)
                    {
                        log("  Local Altered");
                    }
                }
            }
        }
예제 #2
0
        private void Dispatch(TcpClient client, CancellationToken token)
        {
            try
            {
                var bytes = new byte[65536];

                using (var stream = client.GetStream())
                    while (true)
                    {
                        token.ThrowIfCancellationRequested();

                        stream.Read(bytes, 0, bytes.Length);
                        _log.Debug("Message recieved");

                        var response = OnProcess?.Invoke(bytes);

                        if (response != null)
                        {
                            stream.Write(response, 0, response.Length);
                        }

                        _log.Debug("Message sent");
                    }
            }
            catch (Exception e)
            {
                _log.Error(e);
            }
            finally
            {
                client.Close();
            }
        }
예제 #3
0
파일: Packet.cs 프로젝트: Wiciaki/SparkTech
        static Packet()
        {
            Fragment = Platform.CoreFragment?.GetPacketFragment() ?? throw Platform.FragmentException();

            Fragment.Process = args => OnProcess.SafeInvoke(args);
            Fragment.Send    = args => OnSend.SafeInvoke(args);
        }
예제 #4
0
        /// <summary>
        /// Process an asset and register it for further reprocessing in the future.
        /// Apply any mod-related changes to the asset based on the existing mod asset meta map.
        /// </summary>
        /// <param name="asset">The asset to process.</param>
        /// <param name="assetNameFull">The "full name" of the asset, preferable the relative asset path.</param>
        /// <returns>The processed asset.</returns>
        public static object Process(object asset, string assetNameFull)
        {
            string assetName = assetNameFull;

            if (string.IsNullOrEmpty(PathContentOrig) && !string.IsNullOrEmpty(ModManager.PathGame))
            {
                PathContentOrig = Path.Combine(ModManager.PathGame, "Content");
            }
            if (!string.IsNullOrEmpty(PathContentOrig) && assetName.StartsWith(PathContentOrig))
            {
                assetName = assetName.Substring(PathContentOrig.Length + 1);
            }

            int loadedIndex = LoadedAssetPaths.IndexOf(assetName);

            if (loadedIndex == -1)
            {
                LoadedAssetPaths.Add(assetName);
                LoadedAssetFullPaths.Add(assetNameFull);
                LoadedAssets.Add(new WeakReference(asset));
            }
            else
            {
                LoadedAssets[loadedIndex] = new WeakReference(asset);
            }

            return(OnProcess?.InvokePassing(asset, assetNameFull) ?? asset);
        }
예제 #5
0
        protected override void OnShown(EventArgs e)
        {
            Task.Run(
                () => OnProcess?.Invoke(this, new EventArgs()),
                cancellationTokenSource.Token)
            .ContinueWith((t) =>
            {
                if (t.Exception != null)
                {
                    foreach (var exception in t.Exception.Flatten().InnerExceptions)
                    {
                        Console.Error.WriteLine(exception);
                    }

                    Console.Error.WriteLine("Search existing issues or create a new one here: https://github.com/SteamDatabase/ValveResourceFormat/issues");

                    SetProgress($"An exception occured, view console tab for more information. ({t.Exception.InnerException.Message})");

                    // TODO: Throwing doesn't actually display the exception ui
                    throw t.Exception;
                }

                if (!t.IsCanceled)
                {
                    Invoke((Action)Close);
                }
            });
        }
예제 #6
0
파일: UdpServer.cs 프로젝트: frostiq/NES
        private void Listen(CancellationToken token)
        {
            try
            {
                while (!token.IsCancellationRequested)
                {
                    IPEndPoint endPoint = null;
                    var        request  = _udp.Receive(ref endPoint);
                    _log.Debug("Message recieved");

                    var response = OnProcess?.Invoke(request);

                    if (response != null)
                    {
                        _udp.Send(response, response.Length, endPoint);
                    }

                    _log.Debug("Message sent");
                }
            }
            catch (Exception e)
            {
                _log.Error(e);
            }
            finally
            {
                _udp.Close();
            }
        }
예제 #7
0
        public async Task ProcessMessage(TestDelayOutboxCommand message, CancellationToken cancellationToken)
        {
            Console.WriteLine($"TestCommandHandler - Processed command at {DateTime.Now}, Args: {message.Args}");

            await Task.Delay(message.DelayMsec, cancellationToken);

            OnProcess?.Invoke(this, message);
        }
        public void ProcessTurn()
        {
            OnProcess?.Invoke();
            if (actionAgentList.Count > 0)
            {
                if (actionAgentList[0] == Player)
                {
                    OnPlayerActionRequest?.Invoke();
                    actionAgentList.Remove(Player);
                }
                else
                {
                    int enemyIndex = (int)actionAgentList[0];

                    BattleFactors monsterBF = MonsterBattleFactors[enemyIndex];
                    BattleFactors playerBF  = Player.BattleFactors;
                    PlayerSkillEffectStatuses.ForEach(x => x.effector.Use(playerBF, null));
                    if (HitCheck(monsterBF, playerBF))
                    {
                        Skill skill = Monsters[enemyIndex].Action();
                        if (skill == null)
                        {
                            Player.AbilityFactors.HP -= Math.Max(monsterBF.physicalAttackPoint - playerBF.physicalDefencePoint, 1);
                        }
                        else
                        {
                            skill.Use(monsterBF, new List <BattleFactors> {
                                playerBF
                            });
                            skill.SkillEffectors.OfType <SustainSkillEffector>().ToList().ForEach(x =>
                            {
                                SkillEffectStatus status = new SkillEffectStatus {
                                    effector = x, remainedRound = x.SustainRound
                                };
                                if (x is TargetSpeedPointSkillEffector || x is TargetStopActionSkillEffector)
                                {
                                    PlayerSkillEffectStatuses.Add(status);
                                }
                                else
                                {
                                    MonstersSkillEffectStatuses[enemyIndex].Add(status);
                                }
                            });
                        }
                    }
                    else
                    {
                        OnMiss?.Invoke(true, enemyIndex);
                    }
                    ProcessTurn();
                }
            }
            else
            {
                EndTurn();
            }
        }
예제 #9
0
        public WBIResultsDialogSwizzler(OnTransmit transmitMethod, OnDiscard discardMethod, OnProcess processMethod, OnKeep keepMethod)
        {
            onTransmit = transmitMethod;
            onDiscard  = discardMethod;
            onProcess  = processMethod;
            onKeep     = keepMethod;

            SwizzleResultsDialog();
        }
예제 #10
0
        public async Task ProcessMessage(TestOutboxCommand message, CancellationToken cancellationToken)
        {
            //Console.WriteLine($"TestCommandHandler - Processing command at {DateTime.Now}, Args: {message.Args}");

            await Task.Delay(2_000, cancellationToken);

            Console.WriteLine($"TestCommandHandler - Processed command at {DateTime.Now}, Args: {message.Args}");

            OnProcess?.Invoke(this, EventArgs.Empty);
        }
예제 #11
0
 private void ProcessInvoke(TransmissionPayload payload)
 {
     try
     {
         OnProcess?.Invoke(this, payload);
     }
     catch (Exception ex)
     {
         Collector?.LogException("ManualChannelSender/ProcessInvoke", ex);
     }
 }
예제 #12
0
 public void Unsubscribe(FileCheckerProcess handler)
 {
     try
     {
         if (OnProcess.GetInvocationList().Contains(handler))
         {
             OnProcess -= handler;
         }
     }
     catch (NullReferenceException) { }
 }
 public void Listen()
 {
     while (_listener.IsListening)
     {
         var result = _listener.BeginGetContext(ar =>
         {
             var listener = ar.AsyncState as HttpListener;
             var context  = listener?.EndGetContext(ar);
             OnProcess?.Invoke(context);
         }, _listener);
         result.AsyncWaitHandle.WaitOne();
     }
 }
예제 #14
0
 protected override void OnShown(EventArgs e)
 {
     Task.Run(
         () => OnProcess?.Invoke(this, new EventArgs()),
         cancellationTokenSource.Token)
     .ContinueWith((t) =>
     {
         if (!t.IsCanceled)
         {
             Invoke((Action)Close);
         }
     });
 }
예제 #15
0
            /// <summary>
            /// Process an asset and register it for further reprocessing in the future.
            /// Apply any mod-related changes to the asset based on the existing mod asset meta map.
            /// </summary>
            /// <param name="asset">The asset to process.</param>
            /// <param name="assetNameFull">The "full name" of the asset, preferable the relative asset path.</param>
            /// <returns>The processed asset.</returns>
            public static object Process(object asset, string assetNameFull)
            {
                if (DumpOnLoad)
                {
                    Dump(assetNameFull, asset);
                }

                string assetName = assetNameFull;

                if (assetName.StartsWith(PathContentOrig))
                {
                    assetName = assetName.Substring(PathContentOrig.Length + 1);
                }

                int loadedIndex = LoadedAssetPaths.IndexOf(assetName);

                if (loadedIndex == -1)
                {
                    LoadedAssetPaths.Add(assetName);
                    LoadedAssetFullPaths.Add(assetNameFull);
                    LoadedAssets.Add(new WeakReference(asset));
                }
                else
                {
                    LoadedAssets[loadedIndex] = new WeakReference(asset);
                }

                if (asset is Atlas)
                {
                    Atlas    atlas = asset as Atlas;
                    ModAsset mapping;

                    mapping = Get(assetName + "LQ", true);
                    if (mapping != null && mapping.AssetType == typeof(AssetTypeDirectory))
                    {
                        atlas.Ingest(mapping);
                    }

                    mapping = Get(assetName, true);
                    if (mapping != null && mapping.AssetType == typeof(AssetTypeDirectory))
                    {
                        atlas.Ingest(mapping);
                    }

                    return(asset);
                }

                return(OnProcess?.InvokePassing(asset, assetNameFull) ?? asset);
            }
예제 #16
0
        public async Task <IEnumerable <string> > ProcessMultipleMessages(int numOfTasksToRun = 1)
        {
            // Console.WriteLine(messageQueue.Count);

            OnProcess?.Invoke(messageQueue.Count.ToString());
            List <Task <string> > listTask = new List <Task <string> >();

            for (int i = 0; i < numOfTasksToRun; i++)
            {
                listTask.Add(Task.Run(ProcessOneMessage));
            }

            var results = await Task.WhenAll(listTask.ToArray());

            return(results);
        }
예제 #17
0
        public Task ProcessMessage(TestErrorOutboxCommand message, CancellationToken cancellationToken)
        {
            _count++;

            Console.WriteLine($"Try processed command at {DateTime.Now}, Count: {message.CountDown}");

            if (message.CountDown > _count)
            {
                throw new InvalidDataException();
            }

            Console.WriteLine($"Processed command at {DateTime.Now}, Count: {message.CountDown}");

            OnProcess?.Invoke(this, EventArgs.Empty);
            return(Task.CompletedTask);
        }
예제 #18
0
        public static void CallProcess(string message, Server.Connection connection)
        {
            OnProcess?.Invoke(message, connection);
            PacketBase pkt = StringToPacket(message);

            if (pkt == null)
            {
                return;
            }
            if (tcpProcessors.ContainsKey(pkt.t))
            {
                tcpProcessors[pkt.t]?.Invoke(pkt, connection);
            }
            if (tcpIdProcessors.ContainsKey(connection.NetId))
            {
                tcpIdProcessors[connection.NetId]?.Invoke(pkt, connection);
            }
        }
예제 #19
0
        public async Task <Device> GetDevice(string address)
        {
            OVERRIDE_ONPROCESSEVENT = true;
            OnProcess?.Invoke(true);

            var name = await GetProp(address, "ro.product.model");

            if (string.IsNullOrWhiteSpace(name))
            {
                name = await GetProp(address, "ro.product.brand");
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                name = await GetProp(address, "ro.product.device");
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                name = "Unknown";
            }

            var android = await GetProp(address, "ro.build.version.release");

            if (string.IsNullOrWhiteSpace(android))
            {
                android = "Unknown";
            }

            var sdk = await GetProp(address, "ro.build.version.sdk");

            int.TryParse(sdk, out int _sdk);

            var _abi = await GetProp(address, "ro.product.cpu.abi");

            OnProcess?.Invoke(false);
            OVERRIDE_ONPROCESSEVENT = false;

            return(new Device()
            {
                Name = name,
                Android = android,
                Sdk = _sdk,
                Abi = _abi
            });
        }
예제 #20
0
        protected void Perform(OnProcess process)
        {
            //using (Common.TestSpan span = new Common.TestSpan(ErrorTrap.TimeSpanLogger.Bin, mType.ToString(), Common.DebugLevel.Stats))
            {
                foreach (Pair <Type, List <ObjectLookup.Item> > pair in mList)
                {
                    Dictionary <ReferenceWrapper, bool> performed = new Dictionary <ReferenceWrapper, bool>();

                    foreach (ObjectLookup.Item item in pair.Second)
                    {
                        try
                        {
                            T obj = item.mChild as T;
                            if (obj == null)
                            {
                                continue;
                            }

                            SubPerform(obj, item.mParent, item.mField, performed, process);

                            if (DereferenceManager.Logger.OnWorldQuit)
                            {
                                return;
                            }
                        }
                        catch (Exception e)
                        {
                            if (item.mChild is SimDescription)
                            {
                                Common.Exception(item.mChild as SimDescription, e);
                            }
                            else
                            {
                                Common.Exception(item.mChild as GameObject, e);
                            }
                        }
                    }
                }
            }
        }
        protected override void OnShown(EventArgs e)
        {
            Task.Run(
                () => OnProcess?.Invoke(this, new EventArgs()),
                cancellationTokenSource.Token)
            .ContinueWith((t) =>
            {
                if (t.Exception != null)
                {
                    Console.Error.WriteLine(t.Exception);
                    SetProgress(t.Exception.Message);

                    // TODO: Throwing doesn't actually display the exception ui
                    throw t.Exception;
                }

                if (!t.IsCanceled)
                {
                    Invoke((Action)Close);
                }
            });
        }
예제 #22
0
 /// <summary>
 /// Lanza el evento de procesado
 /// </summary>
 /// <param name="state">Estado</param>
 protected void RaiseOnProcess(EProcessState state)
 {
     OnProcess?.Invoke(this, state);
 }
예제 #23
0
 public void Invoke()
 {
     OnProcess?.Invoke();
 }
예제 #24
0
 protected void OnProcessAction(ProcessEventArgs e)
 {
     OnProcess?.Invoke(this, e);
 }
예제 #25
0
 public override void Process(TRow row)
 {
     InvokeBeforeTargetAdapterProcessRowEvent(row);
     OnProcess?.Invoke(this, row);
     InvokeAfterTargetAdapterProcessRowEvent(row);
 }
예제 #26
0
 public Task ProcessMessage(TestOutboxCommand message, CancellationToken cancellationToken)
 {
     Console.WriteLine($"TestCommandHandler - Processed command at {DateTime.Now}, Args: {message.Args}");
     OnProcess?.Invoke(this, message);
     return(Task.CompletedTask);
 }
예제 #27
0
 public override void Process()
 {
     OnProcess?.Invoke(Manager);
 }
예제 #28
0
 public void SeOnProcess(int percent, string itemDescription, bool showProgress = true)
 {
     OnProcess?.Invoke(this, new ProcessArgs(percent, "", itemDescription, showProgress));
 }
예제 #29
0
        private async Task <string> RunAsync(string command, params object[] args)
        {
            using (var p = new Process())
            {
                var OutputMessage = string.Empty;
                p.OutputDataReceived += (s, e) => {
                    if (string.IsNullOrWhiteSpace(e.Data))
                    {
                        return;
                    }
                    OutputMessage += e.Data + Environment.NewLine;
                    if (!OVERRIDE_ONREPORTEVENT)
                    {
                        OutputDataReceived?.Invoke(e.Data);
                    }
                };

                var ErrorMessage = string.Empty;
                p.ErrorDataReceived += (s, e) => {
                    if (string.IsNullOrWhiteSpace(e.Data))
                    {
                        return;
                    }
                    ErrorMessage += e.Data + Environment.NewLine;
                    if (!OVERRIDE_ONREPORTEVENT)
                    {
                        ErrorDataReceived?.Invoke(e.Data);
                    }
                };

                p.StartInfo = new ProcessStartInfo()
                {
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    WindowStyle            = ProcessWindowStyle.Hidden,
                    FileName  = Path.Combine("Lib", "adb.exe"),
                    Arguments = string.Format(command, args)
                };

                p.Start();

                Debug.Print("Adb.Command: adb {0}", string.Format(command, args));

                if (!OVERRIDE_ONPROCESSEVENT)
                {
                    OnProcess?.Invoke(true);
                }

                p.BeginOutputReadLine();
                p.BeginErrorReadLine();

                await Task.Run(() => p.WaitForExit());

                if (!OVERRIDE_ONPROCESSEVENT)
                {
                    OnProcess?.Invoke(false);
                }

                if (p.ExitCode != 0)
                {
                    throw new Exception(ErrorMessage);
                }

                Debug.Print("Adb.Output: {0}", OutputMessage);
                return(OutputMessage);
            };
        }
예제 #30
0
 public override void _Process(float delta) => OnProcess?.Invoke(this, delta);
        public WBIResultsDialogSwizzler(OnTransmit transmitMethod, OnDiscard discardMethod, OnProcess processMethod, OnKeep keepMethod)
        {
            onTransmit = transmitMethod;
            onDiscard = discardMethod;
            onProcess = processMethod;
            onKeep = keepMethod;

            SwizzleResultsDialog();
        }