Esempio n. 1
0
        //修复客户端
        public void UF_FixClient()
        {
            DelegateMethod _callback = delegate(object e) {
                try{
                    string file_res_version = GlobalPath.ResPersistentPath + "res_version.txt";
                    //删除全部代码文件
#if !UNITY_EDITOR
                    string dir_runtime = GlobalPath.ScriptPath;
                    if (Directory.Exists(dir_runtime))
                    {
                        Directory.Delete(dir_runtime, true);
                    }
#endif
                    //删除version
                    if (File.Exists(file_res_version))
                    {
                        File.Delete(file_res_version);
                    }
                    UF_ShowMessageBox(GlobalText.LAN_ERROR_MANUAL_FIX_CONFURE, GlobalText.LAN_CONFIRM);
                }catch (System.Exception ex) {
                    Debugger.UF_Exception(ex);
                }
            };

            AlertDialog.UF_ShowOkCancel(GlobalText.LAN_WARNING, GlobalText.LAN_CANCLE, GlobalText.LAN_CONFIRM, GlobalText.LAN_ERROR_MANUAL_FIX_VERSION, _callback, null);
        }
        static void Main(string[] args)
        {
            DelegateMethod dm = new DelegateMethod(Message);

            dm("Hello from delegate");

            List <Employee> empList = new List <Employee>()
            {
                new Employee {
                    Id = 101, Name = "Abhilash", Salary = 60000, Experience = 6.9
                },
                new Employee {
                    Id = 102, Name = "Abhishek", Salary = 80000, Experience = 5.0
                },
                new Employee {
                    Id = 103, Name = "Ajay", Salary = 40000, Experience = 4.0
                },
                new Employee {
                    Id = 104, Name = "Arjun", Salary = 70000, Experience = 9.2
                },
                new Employee {
                    Id = 105, Name = "Abhijeeth", Salary = 10000, Experience = 1.7
                },
            };

            IsPromotable dobj = new IsPromotable(promoteEmp);



            Employee.PromoteEmployee(empList, dobj);
        }
Esempio n. 3
0
        public TestSetupWindow(DelegateMethod realFouction)
        {
            InitializeComponent();
            temp = realFouction;

            cmbTestGear.Items.Add("0--20Ω");
            cmbTestGear.Items.Add("20--100Ω");
            cmbTestGear.SelectedIndex = 0;
            cmbInnerSupplyVoltage.Items.Add("100");
            cmbInnerSupplyVoltage.Items.Add("200");
            cmbInnerSupplyVoltage.Items.Add("500");
            cmbInnerSupplyVoltage.Items.Add("800");
            tbDeviceSampleFrequency_DC.Text     = "20";
            cmbInnerSupplyVoltage.SelectedIndex = 1;
            cmbDeviceACSampleFrequency.Items.Add(50);
            cmbDeviceACSampleFrequency.Items.Add(100);
            cmbDeviceACSampleFrequency.Items.Add(200);
            cmbDeviceACSampleFrequency.Items.Add(500);
            rbInnernalPower.IsChecked = true;
            tabAC.IsSelected          = true;
            rbAutoAnalysisParameterSet_AC.IsChecked = true;
            rbAutoAnalysisParameterSet_DC.IsChecked = true;
            rbEnableDCfilter.IsChecked           = true;
            rbDisableDCfilter.IsChecked          = false;
            rbSinglePiontMeasurment.IsChecked    = true;
            rbBackSwitch.IsChecked               = true;
            rbAutoContinuousMeasurment.IsChecked = false;
            rbInnernalPower.IsChecked            = true;
            tabAC.IsSelected = true;
            rbAutoAnalysisParameterSet_AC.IsChecked = true;
            rbAutoContinuousMeasurment.IsChecked    = false;
            rbSinglePiontMeasurment.IsChecked       = true;
        }
Esempio n. 4
0
 public static void ConsoleWrite(DelegateMethod dm)
 {
     if (dm != null)
     {
         Console.WriteLine(dm());
     }
 }
Esempio n. 5
0
        public static void Main()
        {
            //singlecast
            DelegateMethod sabiranje = new DelegateMethod(TwoNumAdd);

            Console.WriteLine(sabiranje(45, 50));

            RunDelegator(TwoNumAdd, 90, 50);
            RunDelegator(TwoNumMinus, 90, 50);

            Console.WriteLine("====================");

            //multicast
            DelegateMulticast del = new DelegateMulticast(TwoNumAdd2);

            del += new DelegateMulticast(TwoNumMinus2);

            del(100, 30);
            Console.WriteLine("====================");
            DelegateMethod delAnonymus = (int a, int b) => a * b;

            Console.WriteLine(delAnonymus(5, 10));

            Console.ReadKey();
        }
Esempio n. 6
0
 public void ClearDelegate()
 {
     while (this.OnDelegate != null)
     {
         this.OnDelegate -= this.OnDelegate;
     }
 }
Esempio n. 7
0
 private void UF_CallDelegateEvent(DelegateMethod method)
 {
     if (method != null)
     {
         method.Invoke(this);
     }
 }
    public void chanageWeapon(bool onHand)
    {
        if (onHand)
        {
            void MethodToPass()
            {
                //print("equip weapon");
                currentWeapon = weapon;
                weaponBack.transform.Find(weapon.ToString()).gameObject.SetActive(!onHand);
                weaponHanded_WeaponManager.transform.Find(weapon.ToString()).gameObject.SetActive(onHand);
            }

            methodToCall = MethodToPass;

            StartCoroutine(wait(0.3f, methodToCall));
        }
        else
        {
            void MethodToPass()
            {
                //print("Disarm");
                currentWeapon = Weapon.Armed;
                if (weaponBack.transform.Find(weapon.ToString()))
                {
                    weaponBack.transform.Find(weapon.ToString()).gameObject.SetActive(!onHand);
                }
                weaponHanded_WeaponManager.transform.Find(weapon.ToString()).gameObject.SetActive(onHand);
            }

            methodToCall = MethodToPass;

            StartCoroutine(wait(0.6f, methodToCall));
        }
    }
    void Roll()
    {
        if (Input.GetKeyDown(KeyCode.C) && !rolling && (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D)))
        {
            anim.SetBool("roll", true);
            rolling = true;
            void MethodToPass()
            {
                rolling = false;
            }

            methodToCall = MethodToPass;

            StartCoroutine(wait(0.83f, methodToCall));
        }
        else
        {
            anim.SetBool("roll", false);
        }
        if (rolling)//accelerate
        {
            //this.transform.Translate(Vector3.forward * Speed * Time.deltaTime);
            this.GetComponent <Rigidbody>().velocity = Vector3.forward * Speed * Time.deltaTime;
        }
    }
    public void changeAttackMode(int attackMode)
    {
        //changingAttackMode = true;
        anim.SetInteger("attackMode", attackMode);
        this.attackMode = attackMode;
        void MethodToPass()
        {
            if (attackMode == 0)
            {
                weaponBack.transform.Find(charStats.GetHavingWeapon().ToString()).gameObject.SetActive(true);
                weaponHanded_WeaponManager.transform.Find(charStats.GetHavingWeapon().ToString()).gameObject.SetActive(false);
            }
            if (attackMode == 1)
            {
                weaponBack.transform.Find(charStats.GetHavingWeapon().ToString()).gameObject.SetActive(false);
                weaponHanded_WeaponManager.transform.Find(charStats.GetHavingWeapon().ToString()).gameObject.SetActive(true);
            }
        }

        methodToCall = MethodToPass;

        if (attackMode == 0)
        {
            StartCoroutine(wait(0.8f, methodToCall));
        }
        if (attackMode == 1)
        {
            StartCoroutine(wait(0.05f, methodToCall));
        }
    }
Esempio n. 11
0
 static IEnumerator RunAfterNFrames(int amount, DelegateMethod delegat)
 {
     for (int i = 0; i < amount; i++)
     {
         yield return(endOfFrame);
     }
     delegat();
 }
 void Start()
 {
     sameTab      = false;
     MethodToCall = null;
     ID           = new DefaultDataScript();
     BG           = GameObject.Find("GaudyBG");
     ds           = BG.GetComponentInChildren <ReaderDataScript>();
 }
Esempio n. 13
0
        //添加折叠
        public FoldoutFolder AddFolder(string text, DelegateMethod callback)
        {
            FoldoutFolder folder = new FoldoutFolder(text, callback);

            this.Folders.Add(folder);
            folder.Depth = this.Depth + 1;
            return(folder);
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            //FuncClass funcClass = new FuncClass();
            //funcClass.Test();
            DelegateMethod delegateMethod = new DelegateMethod(ZhangSan.PayHouse);

            delegateMethod += new DelegateMethod(ZhangSan.PayHouse1);
            delegateMethod();
        }
Esempio n. 15
0
File: Timer.cs Progetto: kicata/OPP
 // the method that help to repeat other method after some time in some duration
 public static void RepeatMethod(DelegateMethod method, int seconds, long durationInSeconds)
 {
     long start = 0;
     while (start <= durationInSeconds)
     {
         method();
         Thread.Sleep(seconds * 1000);
         start += seconds;
     }
 }
Esempio n. 16
0
 protected void SetInputField(InputField field, float currentValue, DelegateMethod listenerMethod)
 {
     field.characterValidation = InputField.CharacterValidation.Decimal;
     field.text = currentValue.ToString();
     field.onValueChanged.RemoveAllListeners();
     field.onValueChanged.AddListener(delegate
     {
         listenerMethod();
     });
 }
Esempio n. 17
0
        /// <summary>Set property value on target; supports indexed properties.</summary>
        public static void InvokePropertySet(PropertyInfo propertyInfo, object target, params object[] parameterValues)
        {
            DelegateMethod method = GetSetProperty(propertyInfo);

            if (null == method)
            {
                ThrowMissingMethodException(propertyInfo.DeclaringType, propertyInfo.Name, Type.EmptyTypes, Type.EmptyTypes);
            }
            method.Method(target, parameterValues);
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            DelegateMethod dm = delegate
            {
                Console.WriteLine("Anonymous Method");
            };

            dm();
            Console.ReadLine();
        }
Esempio n. 19
0
        //携程启动安装
        private IEnumerator UF_coroutine_start_install_game(DelegateMethod callback)
        {
            //清空之前解压的代码文件,避免覆盖安装错误问题
#if !UNITY_EDITOR
            UF_deleteCacheFolder(new DirectoryInfo(GlobalPath.ScriptPath));
#endif
            if (GlobalSettings.InstallMode == "raw")
            {
                //无安装包方式
                UF_logInfo(">>>>>>>>>>>>>>>>>>>> Start Install Raw");
                UpgradeThread rawInstall = new UpgradeThread();
                rawInstall.UF_start(UF_threadInstallRaw, string.Empty);
                yield return(UF_StartCoroutine(rawInstall.UF_check_run_end()));

                UF_logInfo(">>>>>>>>>>>>>>>>>>>> End Install Raw");
                yield return(null);

                if (callback != null)
                {
                    callback(rawInstall.retcode);
                }
            }
            else if (GlobalSettings.InstallMode == "net")
            {
                //安装包下载方式
                UF_logInfo(">>>>>>>>>>>>>>>>>>>> Start Install Net");
                UpgradeThread baseInstall = new UpgradeThread();
                baseInstall.UF_start(UF_threadInstallNet, "base.zip");
                yield return(UF_StartCoroutine(baseInstall.UF_check_run_end()));

                UF_logInfo(">>>>>>>>>>>>>>>>>>>> End Install Net");
                yield return(null);

                if (callback != null)
                {
                    callback(baseInstall.retcode);
                }
            }
            else
            {
                //整包
                UF_logInfo(">>>>>>>>>>>>>>>>>>>> Start Install Base");
                UpgradeThread baseInstall = new UpgradeThread();
                baseInstall.UF_start(UF_threadInstallBase, "base.zip");
                yield return(UF_StartCoroutine(baseInstall.UF_check_run_end()));

                UF_logInfo(">>>>>>>>>>>>>>>>>>>> End Install Base");
                yield return(null);

                if (callback != null)
                {
                    callback(baseInstall.retcode);
                }
            }
        }
Esempio n. 20
0
 private void InvokeIfRequired(DelegateMethod method, params object[] args)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(method, new object[] { args });
     }
     else
     {
         method(args);
     }
 }
Esempio n. 21
0
 public void UF_Stop()
 {
     if (m_CurrentPlayClip != null)
     {
         m_IsOver = true;
         UF_ClearPlayQueue();
         m_CurrentPlayClip = null;
         m_PlayingCallback = null;
         this.ctrlSpeed    = 0;
     }
 }
Esempio n. 22
0
 public static void UF_SafeCallDelegate(DelegateMethod method, object param)
 {
     try{
         if (method != null)
         {
             method(param);
         }
     }
     catch (System.Exception e) {
         Debugger.UF_Exception(e);
     }
 }
Esempio n. 23
0
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int      x     = Convert.ToInt32(input[0]);
            int      y     = Convert.ToInt32(input[1]);

            DelegateMethod square = new DelegateMethod(minusSquare);
            DelegateMethod cube   = new DelegateMethod(plusCube);

            Console.WriteLine($"({x} - {y}) ^ 2 = {square(x, y, 2)}");
            Console.WriteLine($"({x} + {y}) ^ 3 = {cube(x, y, 3)}");
        }
Esempio n. 24
0
        public static void TrackExecutionTime(DelegateMethod delegateMethod, String action)
        {
            Stopwatch temp = Stopwatch.StartNew();

            delegateMethod();

            temp.Stop();

#if DEBUG
            Console.WriteLine(String.Format("({0}) Time Elapsed: {1}ms", action, temp.ElapsedMilliseconds));
#endif
        }
Esempio n. 25
0
 public void UF_OnReset()
 {
     if (m_DicAnimatorClips == null)
     {
         return;
     }
     m_ListPlayQueue.Clear();
     m_CurrentPlayClip   = null;
     m_PlayingCallback   = null;
     m_EventTriggerIndex = 0;
     lockPlay            = false;
 }
Esempio n. 26
0
        public static void run(int value, int toBase, int count, DelegateMethod method)
        {
            Stopwatch sp = new Stopwatch();

            sp.Start();
            for (int i = 0; i < count; i++)
            {
                string str = method(value, toBase);
                //Console.WriteLine(str);
            }
            sp.Stop();
            Console.WriteLine("方法:{0}   ,用时:{1}ms", method.Method.Name, sp.ElapsedMilliseconds);
        }
Esempio n. 27
0
 public void AcceptAction()
 {
     if (MethodToConfirm != null)
     {
         MethodToConfirm(obj);
     }
     else
     {
         AnyParamMethodToConfirm(args);
     }
     MethodToConfirm         = null;
     AnyParamMethodToConfirm = null;
 }
    public void changeAttackMode(int attackMode)
    {
        changingAttackMode = true;
        anim.SetInteger("attackMode", attackMode);
        this.attackMode = attackMode;
        void MethodToPass()
        {
            changingAttackMode = false;
        }

        methodToCall = MethodToPass;

        StartCoroutine(wait(1f, methodToCall));
    }
Esempio n. 29
0
        private static DelegateMethod GetMethod(Type targetType, string methodName, Type[] parametersTypes, Type[] genericArguments)
        {
            DelegateMethod method = FindDelegateMethod(targetType, methodName, parametersTypes, genericArguments);

            if (null == method)
            {
                MethodBase methodInfo = MatchMethod(targetType, methodName, parametersTypes, genericArguments);
                if (null != methodInfo)
                {
                    method = WrapMethod(methodInfo, parametersTypes, genericArguments);
                }
            }
            return(method);
        }
Esempio n. 30
0
        IEnumerator ITypewriterMotion(UILabel label, string text, DelegateMethod callback)
        {
            for (int k = 1; k < text.Length + 1; k++)
            {
                label.text = text.Substring(0, k);
                yield return(new WaitForSeconds(duration));
            }

            m_MotionID = 0;
            if (callback != null)
            {
                callback(null);
            }
        }
Esempio n. 31
0
        public void Test_Dump_Delegate()
        {
            Func <string, int> func   = (s) => int.Parse(s);
            Action <string>    action = (s) => Console.WriteLine(s);
            DelegateMethod     method = i => i * 2;

            Assert.AreEqual("System.Func`2[System.String,System.Int32] (System.Func`2[System.String,System.Int32])",
                            func.DumpToString());

            Assert.AreEqual("System.Action`1[System.String] (System.Action`1[System.String])",
                            action.DumpToString());

            Assert.AreEqual("DebugLibTest.DelegateMethod (DebugLibTest.DelegateMethod)",
                            method.DumpToString());
        }
 public int Execute(DelegateMethod method, DataSet data)
 {
     int ret = -1;
     try
     {
         this.dbHelper.Open();
         this.dbHelper.BeginTransaction();
         ret = method.Invoke(data);
         this.dbHelper.Commit();
     }
     #if Npgsql
     catch (NpgsqlException e)
     {
         this.dbHelper.Rollback();
         LogUtility.WriteLogError("", e);
         throw new DBException("", e);
     }
     #else
     catch (NpgsqlException e)
     {
         this.dbHelper.Rollback();
         LogUtility.WriteLogError("", e);
         throw new DBException("", e);
     }
     #endif
     catch (Exception e)
     {
         this.dbHelper.Rollback();
         LogUtility.WriteLogError("", e);
         throw new DBException("", e);
     }
     finally
     {
         this.dbHelper.Close();
     }
     return ret;
 }
 public void CallbackMethod(DelegateMethod d)
 {
     d("test callback");
 }
	public static bool test() {
		var obj = new DelegateMethod();
		return obj.method();
	}
Esempio n. 35
0
        static void Main(string[] args)
        {
            Console.WriteLine("Введите количество элементов массива:");
            int N = int.Parse(Console.ReadLine());
            Random r = new Random();
            int[] a;
            a = new int[N];
            for (int i = 0; i < N; i++)
            {
                a[i] = r.Next(-50, 50);
                Console.Write(a[i] + " ");
            }

            //Прямой метод
            List<TimeSpan> WatchList1 = new List<TimeSpan>();
            for(int i = 1; i<15; i++)
            {
                Stopwatch sw1 = new Stopwatch();
                sw1.Start();
                PryamoyMethod(a);
                sw1.Stop();
                WatchList1.Add(sw1.Elapsed);
            }
            WatchList1.Sort();
            Console.WriteLine("\nЗатраченное время на вычисление прямым методом: {0}", WatchList1[7]);

            //Делегат
            List<TimeSpan> WatchList2 = new List<TimeSpan>();
            for (int i = 1; i < 15; i++)
            {
                DelegateMethod method1 = new DelegateMethod(MethodOfDelegate);
                Stopwatch sw2 = new Stopwatch(); 
                sw2.Start();
                MethodDelegate(a, method1);
                sw2.Stop();
                WatchList2.Add(sw2.Elapsed);
            }
            WatchList1.Sort();
            Console.WriteLine("Затраченное время на вычисление через делегат: {0}", WatchList2[7]);

            //Анонимный делегат
            DelegateMethod AnonimusPositiveElement = delegate (int elem)
            {
                if (elem > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            };

            List<TimeSpan> WatchList3 = new List<TimeSpan>();
            for (int i = 1; i < 15; i++)
            {
               
                Stopwatch sw3 = new Stopwatch();
                sw3.Start();
                MethodDelegate(a, AnonimusPositiveElement);
                sw3.Stop();
                WatchList3.Add(sw3.Elapsed);
            }
            WatchList3.Sort();
            Console.WriteLine("Затраченное время на вычисление через анонимный делегат: {0}", WatchList3[7]);

            //Лямбда-выражение
            DelegateMethod LambdaPositiveElement = (int elem) => elem > 0 ? true : false;

            List<TimeSpan> WatchList4 = new List<TimeSpan>();
            for (int i = 1; i < 15; i++)
            {

                Stopwatch sw4 = new Stopwatch();
                sw4.Start();
                MethodDelegate(a, LambdaPositiveElement);
                sw4.Stop();
                WatchList4.Add(sw4.Elapsed);
            }
            WatchList3.Sort();
            Console.WriteLine("Затраченное время на вычисление через лямбда-выражение: {0}", WatchList4[7]);

            //LINQ-выражение
            List<TimeSpan> WatchList5 = new List<TimeSpan>();
            for (int i = 1; i < 15; i++)
            {

                Stopwatch sw5 = new Stopwatch();
                sw5.Start();
                Positive(a);
                sw5.Stop();
                WatchList5.Add(sw5.Elapsed);
            }
            WatchList3.Sort();
            Console.WriteLine("Затраченное время на вычисление через LINQ-выражение: {0}", WatchList5[7]);

            Console.ReadKey();
        }
Esempio n. 36
0
 public static IEnumerable<int> MethodDelegate(int[] mass, DelegateMethod delmeth)
 {
     List<int> poselem = new List<int>();
     foreach (var elem in mass)
     {
         if (delmeth(elem))
         {
             poselem.Add(elem);
         }
     }
     return poselem;
 }
 public static void run(int value, int toBase, int count, DelegateMethod method)
 {
     Stopwatch sp = new Stopwatch();
     sp.Start();
     for (int i = 0; i < count; i++)
     {
         string str = method(value, toBase);
         //Console.WriteLine(str);
     }
     sp.Stop();
     Console.WriteLine("方法:{0}   ,用时:{1}ms", method.Method.Name, sp.ElapsedMilliseconds);
 }