Exemplo n.º 1
0
        /// <summary>
        /// Eine for schleife wird parallel auf mehreren Kernen ausgeführt. Zusätzlich wird eine Aggregation auf die einzelnen Ergebnisse
        /// des Schleifenbodys angewendet.
        /// </summary>
        /// <typeparam name="TState">type des state Objekts</typeparam>
        /// <param name="from">von welchem Wert an soll die Schleife laufen</param>
        /// <param name="to">bis zu welchen Wert soll die for Schleife laufen</param>
        /// <param name="state">initalisierung des local States</param>
        /// <param name="action">Der Schleifenkörper der ausgeführt wird.
        /// (mit dem übergebenen Wert kann auf die Schleifenvariable zugegriffen werden)</param>
        /// <param name="aggregation">Die Aggregation die auf die Teilergebnisse der einzelnen Schleifenbodies ausgeführt werden</param>
        public static void For <TState>(int from, int to, Func <TState> state,
                                        Action <ThreadLocalState <TState> > action, InvokeAction <ThreadLocalState <TState> > aggregation)
        {
            For forExecution = new For();

            forExecution.ForExecution <TState>(from, to, 1, state, action, aggregation);
        }
Exemplo n.º 2
0
 public InvokeWaitSet(float _time, InvokeAction _invoke, bool _ignoreTimeScale)
 {
     time            = _time;
     invoke          = _invoke;
     ignoreTimeScale = _ignoreTimeScale;
     active          = true;
 }
Exemplo n.º 3
0
 protected void RegisterFunction(int functionId, InvokeAction action)
 {
     if (functionId >= 0 && functionId < actionSlots.Length)
     {
         actionSlots[functionId] = action;
     }
 }
Exemplo n.º 4
0
        public static Action CreateAction(string desc, string name, object instance, string method)
        {
            Type       clstype    = instance.GetType();
            MethodInfo methodinfo = GetMethod(clstype, method);

            if (methodinfo == null)
            {
                throw new Exception("Method not found: " + desc);
            }

            ParameterInfo[] paraminfo  = methodinfo.GetParameters();
            Type[]          paramtypes = new Type[paraminfo.Length];
            for (int i = 0; i < paraminfo.Length; ++i)
            {
                paramtypes[i] = paraminfo[i].ParameterType;
            }

            Action action = new InvokeAction(name, desc, paramtypes, instance, methodinfo, null);

            if (mgr != null)
            {
                name = action.name.ToLower();
                if (mgr.registered_actions.ContainsKey(name.ToLower()))
                {
                    mgr.registered_actions.Remove(name);
                }
                mgr.registered_actions.Add(name, action);
            }
            return(action);
        }
Exemplo n.º 5
0
 public InvokeWaitSet()
 {
     time            = 0;
     invoke          = null;
     ignoreTimeScale = false;
     active          = false;
 }
Exemplo n.º 6
0
 public Report(InvokeAction action, object argument)
 {
     this = new Report()
     {
         Action   = action,
         Argument = argument
     };
 }
 public RangeEnumeration()
 {
     this.loopVariable = new Variable <int>("LoopVariable");
     this.invokeBody   = new InvokeAction <int>
     {
         Argument = this.loopVariable,
     };
 }
Exemplo n.º 8
0
    static public InvokeAction Create(CallFunc callfunc, object userdata = null)
    {
        InvokeAction obj = new InvokeAction();

        obj.mCallFunc = callfunc;
        obj.mUserdata = userdata;
        return(obj);
    }
Exemplo n.º 9
0
        public void AddTarget(IService t, MethodInfo mi)
        {
            InvokeAction a = new InvokeAction();

            a.target = t;
            a.mi     = mi;

            targets[a] = new Keys[] { Keys.None };
        }
Exemplo n.º 10
0
            public override MetaObject Invoke(InvokeAction action, MetaObject[] args)
            {
                if (ImplementsActions(StandardActionKinds.Invoke))
                {
                    return(CallMethodNAry(action, args, "Invoke"));
                }

                return(base.Invoke(action, args));
            }
Exemplo n.º 11
0
            public override bool Equals(object obj)
            {
                InvokeAction a = obj as InvokeAction;

                if (a == null)
                {
                    return(false);
                }
                return(a.target == target && a.mi == mi && a.State == State);
            }
Exemplo n.º 12
0
    //deprecated
    public void FlipFinal(float delay = 0f, bool withAnimation = true)
    {
        /*
         #region NEW_ADD
         * int sceneIndex = UnityEngine.SceneManagement.SceneManager.GetActiveScene ().buildIndex;
         * if (sceneIndex != (int)EScene.SCENE_Demo) {
         *      return;
         * }
         #endregion
         */
        Vector3 oldPos = transform.position;

        if (withAnimation)
        {
            _flipActionList.Clear();

            FiniteTimeAction delayTime = null;
            if (delay > 0f)
            {
                delayTime = DelayTime.Create(delay);
            }

            //上移
            FiniteTimeAction mby = MoveBy.Create(0.2f, Vector3.up * 10f);
            //翻过来
            FiniteTimeAction mbt1 = RotateBy.Create(0.2f, Vector3.forward, 180f, Space.Self);
            //下移到原来的地方
            FiniteTimeAction mbt2 = MoveTo.Create(0.2f, oldPos);

            FiniteTimeAction mbt3 = MoveTo.Create(0.2f, Vector3.up * 5f);
            FiniteTimeAction mbt4 = RotateTo.Create(0.2f, Vector3.zero);

            FiniteTimeAction mbt5 = InvokeAction.Create(delegate(GameObject target, object userdata) {
                //TableController.Instance.SetCurrentPlayedTile (this);
            });
            if (delayTime != null)
            {
                _flipActionList.Add(delayTime);
            }
            _flipActionList.Add(mby);
            _flipActionList.Add(mbt1);
            _flipActionList.Add(mbt2);
            _flipActionList.Add(mbt3);
            _flipActionList.Add(mbt4);
            _flipActionList.Add(mbt5);
            ActionManager.Instance.RunAction(gameObject, _flipActionList);
        }
        else
        {
            //transform.Rotate (Vector3.forward, 180f, Space.Self);
            transform.rotation = Quaternion.identity;
            transform.position = Vector3.up * 5f;
            //TableController.Instance.SetCurrentPlayedTile (this);
        }
    }
Exemplo n.º 13
0
 private bool Contains(InvokeAction invoke)
 {
     if (this.delList.Contains(invoke))
     {
         return(false);
     }
     if (this.curList.Contains(invoke))
     {
         return(true);
     }
     return(this.addList.Contains(invoke));
 }
Exemplo n.º 14
0
    private void ApplyRemoves()
    {
        InvokeAction[] buffer = this.delList.Values.Buffer;
        int            count  = this.delList.Count;

        for (int i = 0; i < count; i++)
        {
            InvokeAction invokeAction = buffer[i];
            this.curList.Remove(invokeAction);
        }
        this.delList.Clear();
    }
Exemplo n.º 15
0
    private void ApplyAdds()
    {
        InvokeAction[] buffer = this.addList.Values.Buffer;
        int            count  = this.addList.Count;
        float          single = Time.time;

        for (int i = 0; i < count; i++)
        {
            InvokeAction invokeAction = buffer[i];
            this.curList.Remove(invokeAction);
            this.curList.Add(invokeAction, single + invokeAction.initial);
        }
        this.addList.Clear();
    }
Exemplo n.º 16
0
        public void Call()
        {
            var invoker = new InvokeAction();
            var process = new Process();

            var commandBegin = new StartCommand(process);

            invoker.SetCommand(commandBegin);
            invoker.Invoke();

            var commandEnd = new FinishCommand(process);

            invoker.SetCommand(commandEnd);
            invoker.Invoke();
        }
Exemplo n.º 17
0
        public void ForExecution <TState, T>(int from, int to, int step,
                                             Func <T, TState> state, Action <T, ThreadLocalState <TState> > function,
                                             InvokeAction <T, ThreadLocalState <TState> > aggregation, T value)
        {
            TState initialState = state(value);
            List <ForPartAggregation <TState, T> > forParts = new List <ForPartAggregation <TState, T> >();

            chunk = (to - from) / processorCount;
            int start = from;
            int end   = chunk;

            for (int i = 1; i <= processorCount; i++)
            {
                int x = i - 1;
                waitHandles[x] = new ManualResetEvent(false);
                ForPartAggregation <TState, T> forPartAggregation = new ForPartAggregation <TState, T>(start, end, step);
                forPartAggregation.ExecutionPart = function;
                forPartAggregation.Statevalue    = new ThreadLocalState <TState>(initialState);
                forPartAggregation.Value1        = value;
                forParts.Add(forPartAggregation);
                ConstantForAggregationSynchronisationContainer <TState, T> forSynchronisationContainer =
                    new ConstantForAggregationSynchronisationContainer <TState, T>((ManualResetEvent)waitHandles[x], forPartAggregation);
                ThreadPool.QueueUserWorkItem(
                    delegate(object localstate)
                {
                    ConstantForAggregationSynchronisationContainer <TState, T> localforSynchronisationContainer = (ConstantForAggregationSynchronisationContainer <TState, T>)localstate;
                    ForPartAggregation <TState, T> localforPart = localforSynchronisationContainer.ForPart_;
                    try
                    {
                        for (int ii = localforPart.From; ii <= localforPart.To; ii = ii + localforPart.Step)
                        {
                            localforPart.ExecutionPart.Invoke(ref ii, localforPart.Value1, localforPart.Statevalue);
                        }
                    }
                    finally
                    {
                        localforSynchronisationContainer.ManualResetEvent_.Set();
                    }
                }, forSynchronisationContainer);
                start = end + 1;
                end   = end + chunk;
            }
            WaitHandle.WaitAll(waitHandles);
            foreach (ForPartAggregation <TState, T> localforPart in forParts)
            {
                aggregation(localforPart.Value1, localforPart.Statevalue);
            }
        }
Exemplo n.º 18
0
    public void AddCommand(float duration, InvokeAction InvokeAction, bool ignoreTimeScale)
    {
        for (int index = 0; index < invokeWaitSetList.Length; index++)
        {
            if (!invokeWaitSetList[index].active)
            {
                invokeWaitSetList[index].time            = duration;
                invokeWaitSetList[index].invoke          = InvokeAction;
                invokeWaitSetList[index].ignoreTimeScale = ignoreTimeScale;
                invokeWaitSetList[index].active          = true;
                return;
            }
        }

        Debug.LogError("Invoke Buffer Over : Look WaitActionController And Please Modify Invoke buffer count.");
    }
Exemplo n.º 19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="method"></param>
        /// <returns></returns>
        public void Invoke(Delegate method)
        {
            lock (m_invoke_lock)
            {
                if (m_callbacks == null)
                {
                    m_callbacks = new System.Collections.Generic.List <Delegate>();
                }
                m_callbacks.Add(method);
            }

            if (m_OnInvokeCallback == null)
            {
                m_OnInvokeCallback = InvokeCallback;
            }
            UnsafeNativeMethods.CRhMainFrame_Invoke(m_OnInvokeCallback);
        }
Exemplo n.º 20
0
    public static void FindInvokes(Behaviour sender, List <InvokeAction> list)
    {
        if (!SingletonComponent <InvokeHandler> .Instance)
        {
            return;
        }
        InvokeAction[] buffer = SingletonComponent <InvokeHandler> .Instance.curList.Keys.Buffer;
        int            count  = SingletonComponent <InvokeHandler> .Instance.curList.Count;

        for (int i = 0; i < count; i++)
        {
            InvokeAction invokeAction = buffer[i];
            if (invokeAction.sender == sender)
            {
                list.Add(invokeAction);
            }
        }
    }
Exemplo n.º 21
0
 public static void InvokeSafe(this MulticastDelegate e, InvokeAction invoke, params object[] args)
 {
     if ((object)e != null)
     {
         Delegate[] invocationList = e.GetInvocationList();
         int        num            = invocationList.Length;
         for (int i = 0; i < num; i++)
         {
             try
             {
                 invoke(invocationList[i], args);
             }
             catch (Exception ex)
             {
                 Log.LogErrorFormatted(e.Target, "The event handler for delegate '{0}' threw an exception. Execution will continue but the game may be in a broken state.", e.Method);
                 Log.LogException(e.Target, ex);
             }
         }
     }
 }
Exemplo n.º 22
0
    private void RemoveExpired()
    {
        InvokeAction[] buffer = this.curList.Keys.Buffer;
        int            count  = this.curList.Count;

        if (this.nullIndex >= count)
        {
            this.nullIndex = 0;
        }
        int num = Mathf.Min(this.nullIndex + 50, count);

        while (this.nullIndex < num)
        {
            InvokeAction invokeAction = buffer[this.nullIndex];
            if (!invokeAction.sender)
            {
                this.QueueRemove(invokeAction);
            }
            this.nullIndex++;
        }
    }
Exemplo n.º 23
0
    public string InvokeString()
    {
        StringBuilder       stringBuilder = new StringBuilder();
        List <InvokeAction> list          = (List <InvokeAction>)Pool.GetList <InvokeAction>();

        InvokeHandler.FindInvokes((Behaviour)this, list);
        using (List <InvokeAction> .Enumerator enumerator = list.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                InvokeAction current = enumerator.Current;
                if (stringBuilder.Length > 0)
                {
                    stringBuilder.Append(", ");
                }
                stringBuilder.Append(((Delegate)current.action).Method.Name);
            }
        }
        // ISSUE: cast to a reference type
        Pool.FreeList <InvokeAction>((List <M0>&) ref list);
        return(stringBuilder.ToString());
    }
Exemplo n.º 24
0
 public void DoUI(InvokeAction call)
 {
     if (IsDisposed)
     {
         return;
     }
     if (InvokeRequired)
     {
         try
         {
             Invoke(call);
         }
         catch (InvalidOperationException)
         {
             //Handle error
         }
     }
     else
     {
         call();
     }
 }
 private void DoUI(InvokeAction call)
 {
     if (IsDisposed)
     {
         return;
     }
     if (InvokeRequired)
     {
         try
         {
             Invoke(call);
         }
         catch (InvalidOperationException)
         {
             // Handle error
         }
     }
     else
     {
         call();
     }
 }
Exemplo n.º 26
0
    private void DoTick()
    {
        float[]        buffer            = this.curList.Values.Buffer;
        InvokeAction[] invokeActionArray = this.curList.Keys.Buffer;
        int            count             = this.curList.Count;
        float          single            = Time.time;

        for (int i = 0; i < count; i++)
        {
            if (single >= buffer[i])
            {
                InvokeAction invokeAction = invokeActionArray[i];
                if (!invokeAction.sender || this.delList.Contains(invokeAction))
                {
                    this.QueueRemove(invokeAction);
                }
                else
                {
                    if (invokeAction.repeat < 0f)
                    {
                        this.QueueRemove(invokeAction);
                    }
                    else
                    {
                        float single1 = single + invokeAction.repeat;
                        if (invokeAction.random > 0f)
                        {
                            single1 += UnityEngine.Random.Range(-invokeAction.random, invokeAction.random);
                        }
                        buffer[i] = single1;
                    }
                    TimeWarning.BeginSample(invokeAction.action.Method.Name);
                    invokeAction.action();
                    TimeWarning.EndSample();
                }
            }
        }
    }
Exemplo n.º 27
0
 public static void InvokeAfterSeconds(float duration, InvokeAction action)
 {
     WaitTimeCount.Instance.AddCommand(duration, action, false);
 }
Exemplo n.º 28
0
        static void Invoke(InvokeAction action, object args)
        {
            const string PipeType = "controller";

            var user = WindowsIdentity.GetCurrent();

            if (!new WindowsPrincipal(user).IsInRole(WindowsBuiltInRole.Administrator))
            {
                ProcessStartInfo si = new ProcessStartInfo();
                si.WindowStyle      = ProcessWindowStyle.Hidden;
                si.UseShellExecute  = true;
                si.FileName         = typeof(ServiceManager).Assembly.Location;
                si.WorkingDirectory = Environment.CurrentDirectory;
                si.Arguments        = Environment.CommandLine.Substring(Environment.CommandLine.IndexOf(' ') + 1);
                si.Verb             = "runas";

                using (var server = ControlPipeFactory.CreateServer(PipeType))
                {
                    server.BeginWaitForConnection(OnPipeConnected, server);

                    try
                    {
                        Process.Start(si).WaitForExit();
                    }
                    catch
                    {
                        Console.WriteLine("Install/Uninstall service requires administrator priviledge.");
                        Environment.Exit(1);
                    }
                }
            }
            else
            {
                var        pipe = ControlPipeFactory.CreateClient(PipeType);
                TextWriter writer;
                try
                {
                    pipe.Connect(1);
                    writer = new StreamWriter(pipe)
                    {
                        AutoFlush = true
                    };
                }
                catch (System.TimeoutException)
                {
                    writer = Console.Out;
                }

                var state = new Hashtable();

                using (var installer = new ServiceProcessInstaller())
                    using (var serviceInstaller = new ServiceInstaller())
                    {
                        try
                        {
                            installer.Account = ServiceAccount.LocalSystem;
                            installer.Installers.Add(serviceInstaller);
                            action(writer, state, installer, serviceInstaller, args);
                            if (state.Count > 0)
                            {
                                installer.Commit(state);
                            }
                            writer.Write("Success.");
                        }
                        catch (Exception e)
                        {
                            if (state.Count > 0)
                            {
                                installer.Rollback(state);
                            }
                            writer.WriteLine("Error: " + e.Message);
                            Environment.Exit(1);
                        }
                    }
            }
            Environment.Exit(0);
        }
Exemplo n.º 29
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="method"></param>
    /// <returns></returns>
    public void Invoke(Delegate method)
    {
      lock (m_invoke_lock)
      {
        if (m_callbacks == null)
          m_callbacks = new System.Collections.Generic.List<Delegate>();
        m_callbacks.Add(method);
      }

      if (m_OnInvokeCallback == null)
        m_OnInvokeCallback = InvokeCallback;
      UnsafeNativeMethods.CRhMainFrame_Invoke(m_OnInvokeCallback);
    }
Exemplo n.º 30
0
 public static void InvokeAfterSecondsIgnoreTimeScale(float duration, InvokeAction action)
 {
     WaitTimeCount.Instance.AddCommand(duration, action, true);
 }
Exemplo n.º 31
0
        private static void replaceWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string           str;
            string           str1;
            string           str2;
            string           str3;
            string           str4;
            string           str5;
            string           argument         = (string)((object[])e.Argument)[0];
            string           argument1        = (string)((object[])e.Argument)[1];
            string           argument2        = (string)((object[])e.Argument)[2];
            string           argument3        = (string)((object[])e.Argument)[3];
            string           argument4        = (string)((object[])e.Argument)[4];
            bool             flag             = (bool)((object[])e.Argument)[5];
            BackgroundWorker backgroundWorker = ReplaceClass.replaceWorker;
            InvokeAction     invokeAction     = (object x) => {
                LogClass.AppendLine(string.Concat("Start to model transformation", DateTime.Now.ToString()), true);
                LogClass.AppendLine((string)x, false);
            };

            string[] fileNameWithoutExtension = new string[] { "Start", Path.GetFileNameWithoutExtension(argument), "to", Path.GetFileNameWithoutExtension(argument1), "Model Transformation" };
            backgroundWorker.ReportProgress(0, new Report(invokeAction, string.Concat(fileNameWithoutExtension)));
            if (!ReplaceClass.userCancelReplace)
            {
                string str6 = Path.Combine(argument3, "ModsOutput");
                string str7 = Path.Combine(str6, string.Concat(Path.GetFileNameWithoutExtension(argument), " to ", Path.GetFileNameWithoutExtension(argument1)));
                str6 = str7;
                ReplaceClass.exportCompletedReportDir = str7;
                string str8 = Path.Combine(str6, "Backup source model");
                if (!ReplaceClass.userCancelReplace)
                {
                    if (Directory.Exists(str6))
                    {
                        try
                        {
                            Directory.Delete(str6, true);
                        }
                        catch
                        {
                        }
                    }
                    if (!Directory.Exists(str6))
                    {
                        Directory.CreateDirectory(str6);
                    }
                    if (!Directory.Exists(str8))
                    {
                        Directory.CreateDirectory(str8);
                    }
                    string str9 = Path.Combine(str6, "Source");
                    if (!Directory.Exists(str9))
                    {
                        Directory.CreateDirectory(str9);
                    }
                    string str10 = Path.Combine(str6, "Target");
                    if (!Directory.Exists(str10))
                    {
                        Directory.CreateDirectory(str10);
                    }
                    if (!ReplaceClass.userCancelReplace)
                    {
                        string modelFileName  = ReplaceClass.GetModelFileName(argument, argument4, flag, out str, out str1);
                        string modelFileName1 = ReplaceClass.GetModelFileName(argument1, argument4, flag, out str2, out str3);
                        if (!ReplaceClass.userCancelReplace)
                        {
                            UEViewer uEViewer = new UEViewer(modelFileName, str9, Path.GetDirectoryName(argument2));
                            if (!ReplaceClass.userCancelReplace)
                            {
                                UEViewer uEViewer1 = new UEViewer(modelFileName1, str10, Path.GetDirectoryName(argument2));
                                if (!ReplaceClass.userCancelReplace && !ReplaceClass.userCancelReplace)
                                {
                                    bool flag1 = uEViewer.Unpack(out str4, argument4, flag);
                                    ReplaceClass.replaceWorker.ReportProgress(0, new Report((object x) => LogClass.AppendLine((string)x, false), str4));
                                    if (!ReplaceClass.userCancelReplace)
                                    {
                                        bool flag2 = uEViewer1.Unpack(out str5, argument4, flag);
                                        ReplaceClass.replaceWorker.ReportProgress(0, new Report((object x) => LogClass.AppendLine((string)x, false), str5));
                                        if (!ReplaceClass.userCancelReplace)
                                        {
                                            if (!flag1)
                                            {
                                                throw new Exception(string.Concat("error_source\\", str6));
                                            }
                                            if (!flag2)
                                            {
                                                throw new Exception(string.Concat("error_target\\", str6));
                                            }
                                            if (!ReplaceClass.userCancelReplace)
                                            {
                                                ReplaceClass.replaceWorker.ReportProgress(0, new Report((object x) => LogClass.AppendLine((string)x, false), "Official convert Start"));
                                                ReplaceClass.DoReplace(str9, str10, str, str2, str1, str3, argument4, flag, str6);
                                                ReplaceClass.replaceWorker.ReportProgress(0, new Report((object x) => LogClass.AppendLine((string)x, false), "Concluded an official convert"));
                                                e.Result = str6;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 32
0
 /// <summary>
 /// When overridden in a derived class provides the non-Meta implementation of invoking the
 /// Dynamic object.
 /// 
 /// When not overridden the call site requesting the action determines the behavior.
 /// </summary>
 protected virtual object Invoke(InvokeAction action, params object[] args)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 33
0
            public override MetaObject Invoke(InvokeAction action, MetaObject[] args)
            {
                if (ImplementsActions(StandardActionKinds.Invoke)) {
                    return CallMethodNAry(action, args, "Invoke");
                }

                return base.Invoke(action, args);
            }
Exemplo n.º 34
0
 public TestInvokeAction()
 {
     _productInvokeAction = new InvokeAction();
     this.ProductActivity = _productInvokeAction;
     this.DisplayName     = typeof(InvokeAction).Name;
 }
Exemplo n.º 35
0
 protected override object Invoke(InvokeAction action, params object[] args)
 {
     return PerformOperation(String.Empty, args);
 }