Beispiel #1
0
 public override System.Type ReturnType()
 {
     System.Type rType = null;
     if (returnType.isAssigned)
     {
         rType = returnType.Get <System.Type>();
     }
     if (rType != null && parameterTypes.All(item => item.isAssigned && item.Get <System.Type>() != null))
     {
         if (rType == typeof(void))
         {
             return(CustomDelegate.GetActionDelegateType(parameterTypes.Select((item) => item.Get <System.Type>()).ToArray()));
         }
         else
         {
             System.Type[] types = new System.Type[parameterTypes.Count + 1];
             for (int x = 0; x < parameterTypes.Count; x++)
             {
                 types[x] = parameterTypes[x].Get <System.Type>();
             }
             types[types.Length - 1] = rType;
             return(CustomDelegate.GetFuncDelegateType(types));
         }
     }
     return(typeof(object));
 }
Beispiel #2
0
 public DispatchCallBenchmark()
 {
     _interfaceProxy     = Substitute.For <IInterfaceWithSingleMethod>();
     _abstractClassProxy = Substitute.For <AbstractClassWithSingleMethod>();
     _classPartialProxy  = Substitute.For <ClassWithSingleMethod>();
     _delegateProxy      = Substitute.For <CustomDelegate>();
 }
Beispiel #3
0
        public void TestAttributeUsage()
        {
            CustomDelegate cd = (sender) => { return(sender); };

            // Just check that [Custom] can be applied with no [AttributeUsage(AttributeTargets.All)] required
            Assert.AreEqual(5, cd(5));
        }
Beispiel #4
0
        private static void Main(string[] args)
        {
            var johnKowalski = new EmployeeModel
            {
                Age        = 35,
                FirstName  = "John",
                LastName   = "Kowalski",
                Profession = "Coding Knight"
            };
            var introductors       = new EmployeeIntroductor();
            var usageOfFunc        = new UsageOfFunc();
            var customIntroduction = new CustomDelegate();
            var actionIndroduction = new UsageOfAction();
            Func <EmployeeModel, string> firstnameHandler = usageOfFunc.GetEmployeeFirstname;
            Action <EmployeeModel>       actionHandler    = introductors.CallByFirstName;

            Console.WriteLine("Using Custom Delegate");
            CustomDelegate.EmployeeIntroductionCustomHandler customHandler = introductors.CallByFirstName;
            customHandler += introductors.CallByLastName;
            customHandler += introductors.ShowTheProfession;
            customHandler += ShowAgeOfEmployee;
            customIntroduction.CustomIntroduct(johnKowalski, customHandler);

            Console.WriteLine("Using Action Delegate");
            actionHandler += introductors.CallByLastName;
            actionHandler += introductors.ShowTheProfession;
            actionHandler += ShowAgeOfEmployee;
            actionIndroduction.ActionIntroduct(johnKowalski, actionHandler);

            Console.WriteLine("Getting Name by Func");
            Console.WriteLine(firstnameHandler(johnKowalski));

            Console.WriteLine("Press any key ...");
            Console.ReadLine();
        }
 public CustomDelegate this[string methodName]
 {
     get
     {
         CustomDelegate result = args => Bind(methodName, args);
         return(result);
     }
 }
 private void Start()
 {
     // Hook up some event listeners for us to test raising of events
     basicAction       += DataTestScript_BasicAction;
     complicatedAction += DataTestScript_ComplicatedAction;
     customDelegate    += DataTestScript_CustomDelegate;
     unityEvent.AddListener(HandleUnityAction);
 }
        public void Register_CustomCanvasType_Height_CustomInterface()
        {
            CustomCanvasType       the_object         = new CustomCanvasType();
            CustomCanvasType       custom_canvas      = new CustomCanvasType();
            Canvas                 canvas             = new Canvas();
            CustomStruct           custom_struct_1    = new CustomStruct(1);
            CustomEnum             custom_enum        = CustomEnum.EnumValue1;
            CustomDelegate         custom_delegate    = delegate { };
            CustomInterface        custom_interface_a = new CustomInterfaceImplA();
            CustomInterface        custom_interface_b = new CustomInterfaceImplB();
            DependencyProperty     property;
            DependencyPropertyInfo info;

            DependencyPropertyInfo.ChangedInfo changed_info;
            InkPresenter ink = new InkPresenter();              // The only builtin type derived from Canvas
            object       actual_value;
            object       previous_expected_value = null;
            int          iterations = 0;
            int          changes    = 0;

            CustomCanvasType_Height_CustomInterface = new DependencyPropertyInfo("Height", typeof(CustomCanvasType), typeof(CustomInterface), true);
            info = CustomCanvasType_Height_CustomInterface;

            property = info.Property;

            Assert.AreEqual(null, the_object.GetValue(property), "Default value 1");
            Assert.AreEqual(null, ink.GetValue(property), "Default value 2");

            Assert.Throws(delegate { the_object.SetValue(property, 0); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, 1); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, ""); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, new CustomClass()); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, new Canvas()); }, typeof(ArgumentException));
            Assert.Throws(delegate { the_object.SetValue(property, custom_enum); }, typeof(ArgumentException));

            foreach (object expected_value in new object [] { null, custom_interface_a, null, custom_interface_b, custom_interface_b, null })
            {
                iterations++;

                the_object.SetValue(property, expected_value);
                actual_value = the_object.GetValue(property);

                if (!object.Equals(expected_value, previous_expected_value))
                {
                    changes++;
                    changed_info = info.Changes [info.Changes.Count - 1];
                    DependencyPropertyChangedEventArgs args = changed_info.args;
                    Assert.AreEqual(args.OldValue, previous_expected_value, "OldValue");
                    Assert.AreEqual(args.NewValue, expected_value, "NewValue");
                    Assert.AreSame(changed_info.obj, the_object);
                }

                previous_expected_value = expected_value;

                Assert.AreEqual(expected_value, actual_value, "Iteration #{0}", iterations);
                Assert.AreEqual(changes, info.Changes.Count, "Iteration #{0} there should be {1} changes, but there were {2} changes", iterations, changes, info.Changes.Count);
            }
        }
Beispiel #8
0
        public BlinkIDImplementation()
        {
            customDelegate = new CustomDelegate();

            BlinkID.Instance().LicenseKey = "PYIECP3J-XHJMFSKH-XXPEIG62-R7634IH2-5OZFR4WV-XYQPV25S-LDZNKHXW-CLLJIJF5";
            BlinkID.Instance().Delegate   = customDelegate;

            BlinkID.Instance().AddMrtdRecognizer();

            //BlinkID.Instance ().AddEudlRecognizer ();
            //BlinkID.Instance ().AddGerMrzRecognizer ();
            //BlinkID.Instance ().AddGerIDFrontRecognizer ();
            //BlinkID.Instance ().AddCroIdFrontRecognizer ();
            //BlinkID.Instance ().AddCroIdBackRecognizer ();
            //BlinkID.Instance ().AddAusIDFrontRecognizer ();
            //BlinkID.Instance ().AddAusIDBackRecognizer ();
            //BlinkID.Instance ().AddBarDecoderRecognizer ();
            //BlinkID.Instance ().AddCzIDFrontRecognizer ();
            //BlinkID.Instance ().AddCzIDBackRecognizer ();
            //BlinkID.Instance ().AddDedlRecognizer ();
            //BlinkID.Instance ().AddEudlRecognizer ();
            //BlinkID.Instance ().AddMyKadRecognizer ();
            //BlinkID.Instance ().AddIKadRecognizer ();
            //BlinkID.Instance ().AddPdf417Recognizer ();
            //BlinkID.Instance ().AddSingaporeIDRecognizer ();
            //BlinkID.Instance ().AddUkdlRecognizer ();
            //BlinkID.Instance ().AddSerbIDFrontRecognizer ();
            //BlinkID.Instance ().AddSerbIDBackRecognizer ();
            //BlinkID.Instance ().AddSlovakIDFrontRecognizer ();
            //BlinkID.Instance ().AddSlovakIDBackRecognizer ();
            //BlinkID.Instance ().AddSlovenianIDFrontRecognizer ();
            //BlinkID.Instance ().AddSlovenianIDBackRecognizer ();
            //BlinkID.Instance ().AddSingaporeIDFrontRecognizer ();
            //BlinkID.Instance ().AddSingaporeIDBackRecognizer ();
            //BlinkID.Instance ().AddUsdlRecognizer ();
            //BlinkID.Instance ().AddAusdlRecognizer ();
            //BlinkID.Instance ().AddZXingRecognizer ();

            //BlinkID.Instance ().AddVinParser ("VIN_PARSER_ID");
            //BlinkID.Instance ().AddLicensePlatesParser ("LICENSE_PLATES_PARSER_ID");

            //BlinkID.Instance ().AddTopUpOcrParser ("TOP_UP_OCR_PARSER_ID");
            //BlinkID.Instance ().AddRegexParser ("Blink\\d\\d\\d", "REGEX_PARSER_ID");
            //BlinkID.Instance ().AddIbanParser ("IBAN_PARSER_ID");
            //BlinkID.Instance ().AddEmailParser ("EMAIL_PARSER_ID");
            //BlinkID.Instance ().AddDateParser ("DATE_PARSER_ID");
            //BlinkID.Instance ().AddRawParser ("RAW_PARSER_ID");
            //BlinkID.Instance ().AddAmountParser ("AMOUNT_PARSER_ID");

            //BlinkID.Instance ().AddIdCardDetector ();

            //BlinkID.Instance ().ClearAllDetectors ();
            //BlinkID.Instance ().ClearAllParsers ();
            //BlinkID.Instance ().ClearAllRecognizers ();


            isFrontCamera = false;
        }
Beispiel #9
0
        unsafe void Custom(Action callback)
        {
            BlockLiteral   block          = new BlockLiteral();
            CustomDelegate block_callback = BlockCallback;

            block.SetupBlock(block_callback, callback);
            Bindings.Test.CFunctions.x_call_block(ref block);
            block.CleanupBlock();
        }
Beispiel #10
0
 protected override object Value()
 {
     System.Type type = returnType.Get <System.Type>();
     if (type != null)
     {
         if (type == typeof(void))
         {
             return(CustomDelegate.CreateActionDelegate((obj) => {
                 if (owner == null)
                 {
                     return;
                 }
                 for (int i = 0; i < parameterValues.Count; i++)
                 {
                     parameterValues[i] = obj[i];
                 }
                 body.InvokeFlow();
             }, parameterTypes.Select((item) => item.Get <System.Type>()).ToArray()));
         }
         else
         {
             System.Type[] types = new System.Type[parameterTypes.Count + 1];
             for (int x = 0; x < parameterTypes.Count; x++)
             {
                 types[x] = parameterTypes[x].Get <System.Type>();
             }
             types[types.Length - 1] = type;
             return(CustomDelegate.CreateFuncDelegate((obj) => {
                 if (owner == null)
                 {
                     return null;
                 }
                 for (int i = 0; i < parameterValues.Count; i++)
                 {
                     parameterValues[i] = obj[i];
                 }
                 Node n;
                 WaitUntil w;
                 if (!body.ActivateFlowNode(out n, out w))
                 {
                     throw new System.Exception("Coroutine aren't supported by anonymous function in runtime.");
                 }
                 if (n == null)
                 {
                     throw new System.Exception("No return value");
                 }
                 JumpStatement js = n.GetJumpState();
                 if (js == null || js.jumpType != JumpStatementType.Return || !(js.from is NodeReturn))
                 {
                     throw new System.Exception("No return value");
                 }
                 return (js.from as NodeReturn).GetReturnValue();
             }, types));
         }
     }
     return(null);
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            customDelegate = new CustomDelegate(this);

            // set license key for iOS with bundle ID com.microblink.xamarin.blinkid
            MBMicroblinkSDK.SharedInstance.SetLicenseKey("sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDL+B9jpa6FeAwozaXbqHSjMIKiqr4gD/bDmTXR0NcEQJxc98SUF7C/K1YYrbRc9ZVNfHdRwd2qQ35aa2PuyWiKisBm8am48D1N18uu0lylVoMkeqYf9Z/ggNP8nZkVRfY1y9egl01baFvPskSw4/5vt7fodsrK3XDMu+HUmeWVDqizB0jRwzh4Yu40AqOUTMYWVN3WgfSLQdWHlYKu2CFVTj83CYvNeGMQs+KTTEXvKiKmHSzhNeER9CVfoDC/qgXJV0kvdLO5+q0c4i");
        }
Beispiel #12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            customDelegate = new CustomDelegate(this);

            // set license key for iOS with bundle ID com.microblink.sample
            MBMicroblinkSDK.SharedInstance().SetLicenseKey("sRwAAAEVY29tLm1pY3JvYmxpbmsuc2FtcGxl1BIcP+dpSuS/38JVP6aONWHvT8wM+6zmoHkZcEdflMvkKx9QQNk8obEjEQ2ORa2AOCX0WIH6J7aiNng1sfYJhHJP5IFe4WT2T1FhZ8hS9NGfch5TmUt4otfsjHBaFCjwIg9C0VBO/Jr3EWvcYTy9h85elnvwjJVB5GQwb2UT+UpjD9qV4x4X7PdjO87TFVboMrcLPbv/ql7u9f1ic4cMuzh/ja7G+02rESCeA/BE3huTNORJNw9Llb2dsEEFA+NUP9sGejw=", null);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            customDelegate = new CustomDelegate(this);

            // set license key for iOS with bundle ID com.microblink.sample
            MBMicroblinkSDK.SharedInstance().SetLicenseKey("sRwAAAEVY29tLm1pY3JvYmxpbmsuc2FtcGxl1BIcP4FpSuS/38JVOzajlIagplKYt2m23387sgExhEf8R1Nj6g8zc/NHNwGBZ7y6/T162y+gLSutWi72yRCl1m5VfqBpIihcqOJA2YBmPOqMX5l+MDSjvZze8rHu8rLWdfE+cqzhunkOBu3IvtvbSrNOGIkDpX+OI43TDqFEeor7qtn209ngMix3gyHLwtOi4CnO9Bj7MGbfrno9OfXsw22MPkxSmmJwSe6WrnU8kNbJ6bMOO6mckvAxFwmi7RMfCHfNx3IuoGEZ7t0kDBiOH0MCu6MHKRWtjkijMC9Uq20dqvW1kR9K2UhO2tT0DYnKwCsgxBeW", null);
        }
Beispiel #14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            customDelegate = new CustomDelegate(this);

            // set license key for iOS with bundle ID com.microblink.xamarin.blinkid
            MBMicroblinkSDK.SharedInstance.SetLicenseKey("sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDL+B9jpa6FeAwCB68F5GmyjOoTBeIV5sKcvJJBquml9J7/y9U/vJu4mzhLUXs1iRDyIO2u+oQPeM9hSt+FmDxgVgj8ajVU9dHSlyINcsnrj27p75PHrFGCK0dMVnKzWDEjIZUcQfphQ8z8L4+ovU2x9LkQpCU44RxQi6aL8wFvotax8Xeq/Q8fuEK5wkVFQ6SInQnvjBrMaTP2Z+6o4ZMcpkdqq0BYeCKi4XArDIQn/lEOLm8WwpNYSt");
        }
Beispiel #15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            customDelegate = new CustomDelegate(this);

            // set license key for iOS with bundle ID com.microblink.xamarin.blinkid
            MBMicroblinkSDK.SharedInstance.SetLicenseKey("sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDL+B9jpa6FeAx7x69Nn9VVTofYT2ZAb8+dDWUdwnBje1AqOjCH2Ckp78A0XKEBbg91lC3vJyWALjcuZHPeESnd+JI2IzBQbP/32HhRBLJaXyZxbOtTwNFBnadltFIf2AGL+FDIFJz3bc6VWOEA3ImT7S02gnAaYMS3Gy7PnIYJr33JHe+qOKzSUtESQLVIbMQp1+ubP7hh+/g3z2Vb8LRA0i2n/x/YRcqmA0bDe5oA3Ww39I/6O2PNGX/PNhLDkaVpbX3RYof5cx");
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            customDelegate = new CustomDelegate(this);

            // set license key for iOS with bundle ID com.microblink.xamarin.blinkid
            MBMicroblinkSDK.SharedInstance.SetLicenseKey("sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDL+B9jpa6FcAxRB59KP5uKHx3yK5i71SaHBhxP57cZUJAlNPBDUgzhrOUQdf7HIZk5yAOu2VV3dhk9+ZC9/rCR+Ob2psUpvm7GwgguVcn6byvrscHvxIjTisV1GyZ+Zhr5kjGhLvlToSWQ8kFkm+IVEmMXAJ/JWnHt8DESn0KTenlhpMKjhoPr5pAxOGLVSgqhoigoIOwmXwoL+e6SxfdH+yEQqsoSdVaTuIaojpMcmCtPDg2bHBZfot2QfDzEE=");
        }
Beispiel #17
0
        static void Main(string[] args)
        {
            City c = new City("Random City", 9548764, 3467435.546f, true);

            CustomDelegate print = new CustomDelegate(c.printName) + new CustomDelegate(c.printArea) + new CustomDelegate(c.printPopulation) + new CustomDelegate(c.printRegCenterStatus) + new CustomDelegate(printSpace);
            CustomDelegate set   = new CustomDelegate(c.setValues);
            CustomDelegate run   = print + set + print;

            run();
        }
Beispiel #18
0
        private void InitDelegate()
        {
            if (!delegateType.isAssigned)
            {
                return;
            }
            var type = delegateType.Get <System.Type>();

            methodInfo = type.GetMethod("Invoke");
            if (methodInfo.ReturnType == typeof(void))
            {
                m_Delegate = CustomDelegate.CreateActionDelegate((obj) => {
                    if (owner == null)
                    {
                        return;
                    }
                    if (obj != null)
                    {
                        while (parameterValues.Count < obj.Length)
                        {
                            parameterValues.Add(null);
                        }
                        for (int i = 0; i < obj.Length; i++)
                        {
                            parameterValues[i] = obj[i];
                        }
                    }
                    body.InvokeFlow();
                }, methodInfo.GetParameters().Select(i => i.ParameterType).ToArray());
            }
            else
            {
                var types = methodInfo.GetParameters().Select(i => i.ParameterType).ToList();
                types.Add(methodInfo.ReturnType);
                m_Delegate = CustomDelegate.CreateFuncDelegate((obj) => {
                    if (owner == null)
                    {
                        return(null);
                    }
                    if (obj != null)
                    {
                        while (parameterValues.Count < obj.Length)
                        {
                            parameterValues.Add(null);
                        }
                        for (int i = 0; i < obj.Length; i++)
                        {
                            parameterValues[i] = obj[i];
                        }
                    }
                    return(input.Get(methodInfo.ReturnType));
                }, types.ToArray());
            }
            // m_Delegate = ReflectionUtils.ConvertDelegate(m_Delegate, e.EventHandlerType);
        }
Beispiel #19
0
        protected BaseSignInWithAppleService(Func <UIWindow> windowProvider)
        {
            _appleIdProvider = new ASAuthorizationAppleIdProvider();

            _authControllerDelegate = new CustomDelegate();
            _authControllerDelegate.CompletedWithAppleId  += DidCompleteAuthWithAppleId;
            _authControllerDelegate.CompletedWithPassword += DidCompleteAuthWithPassword;
            _authControllerDelegate.CompletedWithError    += DidCompleteAuthWithError;

            _presentationProvider = new CustomPresentationContextProvider(windowProvider);
        }
 public static MulticastDelegate DefineDelegate(Type delegateType, CustomDelegate methodBody)
 {
     MethodInfo invokeMethod = delegateType.GetMethod("Invoke", BindingFlags.Public | BindingFlags.Instance);
     
     Type returnType = invokeMethod.ReturnType;
     List<Type> parameterTypes = new List<Type>();
     foreach(ParameterInfo param in invokeMethod.GetParameters())
     {
         parameterTypes.Add(param.ParameterType);
     }
     return DefineDelegate(delegateType, methodBody, returnType, parameterTypes.ToArray());
 }
Beispiel #21
0
        private Car(Vector2 ScrSize)
        {
            CarPos.X = 0;
            CarPos.Y = 0;

            Bounds = ScrSize;
            Origin = new Vector2();
            Speed = 0.0f;
            Parent = mainClass.GetInstance();
            LastMove = new Vector2();

            KeyHandler = _KeyHandler;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            customDelegate = new CustomDelegate(this);

            // set license key for iOS with bundle ID com.microblink.xamarin.blinkid
            MBMicroblinkSDK.SharedInstance.SetLicenseKey("sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDF2B9jpa6FeAx5h89osjSFXqQRtWjes0WSEXe3rubgFApHsFdSF2oJZL0MhSL18AgbaLmPiOT3RFu+lqtKtpsjqRfxEVmc9cU98GnjciEeAOC331OUeT5R1p7zKqsenX/3IytQJuMG4ruEaRXc5746y/Kv8ch0XDgv/nRu4siNlvpkjsUjkeyokbUUwi+uzL6t2G4V/sX0SXTMWPjG7zjtW4ovwpGs6fct/dpBJQfzRQNCn9kg==");

            mrtdRecognizer = new MBMrtdRecognizer();
            usdlRecognizer = new MBUsdlRecognizer();
            eudlRecognizer = new MBEudlRecognizer();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            customDelegate = new CustomDelegate(this);

            // set license key for iOS with bundle ID com.microblink.xamarin.blinkid
            MBMicroblinkSDK.SharedInstance.SetLicenseKey("sRwAAAEeY29tLm1pY3JvYmxpbmsueGFtYXJpbi5ibGlua2lks3unDF2B9jpa6FeAxSjaWUg1ROYBfuTUj5ciQyp9KpRtdClsjclAqYTT1BA7QMj6tUv6yIwdGZNSUhiR253O9Zugyv6tsc8hB9XvpMvDAHOiAmgzkj5SacPTjp5C4xZwKCmER2NUf4YSDddznrI7btd5cNnr0Bc5lT0wNHzlN7Z6r04dqoI+jzrCW65IgF8DrA/t4C6O0/lxthm+IfAmobL0kfI0ui6/fy3m8OZ31AacLKO1qb4T0A==");

            mrtdRecognizer = new MBMrtdRecognizer();
            usdlRecognizer = new MBUsdlRecognizer();
            eudlRecognizer = new MBEudlRecognizer();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            // Perform any additional setup after loading the view, typically from a nib.

            customDelegate = new CustomDelegate ();

            BlinkID.Instance().LicenseKey = "VVBZXXL4-YIHNFMHI-V3RF6KDA-WPFHFFEX-5X72P6VO-55RZ66YJ-IYVFVAOY-MYETCD5W";
            BlinkID.Instance().Delegate = customDelegate;

            //BlinkID.Instance ().AddMrtdRecognizer ();
            //BlinkID.Instance ().AddEudlRecognizer ();
            //BlinkID.Instance ().AddCroIdFrontRecognizer ();
            //BlinkID.Instance ().AddCroIdBackRecognizer ();
            //BlinkID.Instance ().AddAusIDFrontRecognizerSettings ();
            //BlinkID.Instance ().AddAusIDBackRecognizerSettings ();
            //BlinkID.Instance ().AddBarDecoderRecognizer ();
            //BlinkID.Instance ().AddCzIDFrontRecognizer ();
            //BlinkID.Instance ().AddCzIDBackRecognizer ();
            //BlinkID.Instance ().AddDedlRecognizer ();
            //BlinkID.Instance ().AddEudlRecognizer ();
            //BlinkID.Instance ().AddMyKadRecognizer ();
            //BlinkID.Instance ().AddPdf417Recognizer ();
            //BlinkID.Instance ().AddSingaporeIDRecognizerSettings ();
            //BlinkID.Instance ().AddUkdlRecognizer ();
            //BlinkID.Instance ().AddUsdlRecognizer ();
            //BlinkID.Instance ().AddZXingRecognizer ();

            //BlinkID.Instance ().AddVinParser ("");
            //BlinkID.Instance ().AddRegexParser ("", "");
            //BlinkID.Instance ().AddIbanParser ("");
            //BlinkID.Instance ().AddEmailParser ("");
            //BlinkID.Instance ().AddDateParser ("");
            //BlinkID.Instance ().AddRawParser ("");
            //BlinkID.Instance ().AddAmountParser ("");

            BlinkID.Instance ().AddIdCardDetector ();

            //BlinkID.Instance ().ClearAllDetectors ();
            //BlinkID.Instance ().ClearAllParsers ();
            //BlinkID.Instance ().ClearAllRecognizers ();

            isFrontCamera = false;

            customDelegate.MetadataImageView = metadataImageView;
            customDelegate.MetadataTextView = metadataTextView;
        }
        public BlinkIDImplementation()
        {
            customDelegate = new CustomDelegate();

            BlinkID blinkID = BlinkID.Instance();

            //BlinkID.Instance().LicenseKey = "VGOMO4WX-I4TEAUQ3-OFDPCLTX-ERCIDCFW-TEPV5B2S-LPKTCT6N-OQPMSBMK-BVVS7XSA";
            //BlinkID.Instance().LicenseKey = "2GZV3LZ2-TKEHYWFS-LDV4ZV2Q-PGONQKPY-47SBFKUI-NOW4IWTE-XXBVPXEK-FDTZGQO6";
            BlinkID.Instance().LicenseKey = "AT5LHBUW-7QZPI3L7-S3QT5AE2-JVZH427V-LM4YGIGD-3PCSZR6S-5QB3SNFO-SFKPTYSN";
            BlinkID.Instance().Delegate   = customDelegate;

            BlinkID.Instance().AddMrtdRecognizer();

            //BlinkID.Instance ().AddEudlRecognizer ();
            //BlinkID.Instance ().AddCroIdFrontRecognizer ();
            //BlinkID.Instance ().AddCroIdBackRecognizer ();
            //BlinkID.Instance ().AddAusIDFrontRecognizer ();
            //BlinkID.Instance ().AddAusIDBackRecognizer ();
            //BlinkID.Instance ().AddBarDecoderRecognizer ();
            //BlinkID.Instance ().AddCzIDFrontRecognizer ();
            //BlinkID.Instance ().AddCzIDBackRecognizer ();
            //BlinkID.Instance ().AddDedlRecognizer ();
            //BlinkID.Instance ().AddEudlRecognizer ();
            //BlinkID.Instance ().AddMyKadRecognizer ();
            //BlinkID.Instance ().AddPdf417Recognizer ();
            //BlinkID.Instance ().AddSingaporeIDRecognizer ();
            //BlinkID.Instance ().AddUkdlRecognizer ();
            //BlinkID.Instance ().AddUsdlRecognizer ();
            //BlinkID.Instance ().AddZXingRecognizer ();

            //BlinkID.Instance ().AddVinParser ("VIN_PARSER_ID");

            //BlinkID.Instance ().AddRegexParser ("Blink\\d\\d\\d", "REGEX_PARSER_ID");
            //BlinkID.Instance ().AddIbanParser ("IBAN_PARSER_ID");
            //BlinkID.Instance ().AddEmailParser ("EMAIL_PARSER_ID");
            //BlinkID.Instance ().AddDateParser ("DATE_PARSER_ID");
            //BlinkID.Instance ().AddRawParser ("RAW_PARSER_ID");
            //BlinkID.Instance ().AddAmountParser ("AMOUNT_PARSER_ID");

            //BlinkID.Instance ().AddIdCardDetector ();

            //BlinkID.Instance ().ClearAllDetectors ();
            //BlinkID.Instance ().ClearAllParsers ();
            //BlinkID.Instance ().ClearAllRecognizers ();

            isFrontCamera = false;
        }
        public RedisClientWrapper(object client)
        {
            _client = client;

            // Populate delegates
            var type = client.GetType();

            _set           = (Func <string, int, bool>)type.GetMethods().Where(m => m.Name == "Set" && m.IsGenericMethod && m.GetParameters().Length == 2).First().MakeGenericMethod(typeof(int)).CreateDelegate(typeof(Func <string, int, bool>), _client);
            _ping          = (Func <bool>)type.GetMethod("Ping").CreateDelegate(typeof(Func <bool>), _client);
            _custom        = (CustomDelegate)type.GetMethod("Custom").CreateDelegate(typeof(CustomDelegate), _client);
            _echo          = (Func <string, string>)type.GetMethod("Echo").CreateDelegate(typeof(Func <string, string>), _client);
            _getSlowlog    = (Func <int?, IEnumerable>)type.GetMethod("GetSlowlog").CreateDelegate(typeof(Func <int?, IEnumerable>), _client);
            _incr          = (Func <string, long>)type.GetMethod("Incr").CreateDelegate(typeof(Func <string, long>), _client);
            _incrByFloat   = (Func <string, double, double>)type.GetMethod("IncrByFloat").CreateDelegate(typeof(Func <string, double, double>), _client);
            _getServerTime = (Func <DateTime>)type.GetMethod("GetServerTime").CreateDelegate(typeof(Func <DateTime>), _client);
            _changeDb      = (Action <long>)type.GetMethod("ChangeDb").CreateDelegate(typeof(Action <long>), _client);
        }
        public BlinkIDImplementation()
        {
            customDelegate = new CustomDelegate ();

            BlinkID.Instance ().LicenseKey = "5MYXRDEJ-O2CLWMIU-PRCSYAV4-ES45AC2P-NCPDQ5YM-KCFCB6XL-WJMPE5IO-F63JKM4H";
            BlinkID.Instance ().Delegate = customDelegate;

            BlinkID.Instance ().AddMrtdRecognizer ();

            //BlinkID.Instance ().AddEudlRecognizer ();
            //BlinkID.Instance ().AddCroIdFrontRecognizer ();
            //BlinkID.Instance ().AddCroIdBackRecognizer ();
            //BlinkID.Instance ().AddAusIDFrontRecognizer ();
            //BlinkID.Instance ().AddAusIDBackRecognizer ();
            //BlinkID.Instance ().AddBarDecoderRecognizer ();
            //BlinkID.Instance ().AddCzIDFrontRecognizer ();
            //BlinkID.Instance ().AddCzIDBackRecognizer ();
            //BlinkID.Instance ().AddDedlRecognizer ();
            //BlinkID.Instance ().AddEudlRecognizer ();
            //BlinkID.Instance ().AddMyKadRecognizer ();
            //BlinkID.Instance ().AddPdf417Recognizer ();
            //BlinkID.Instance ().AddSingaporeIDRecognizer ();
            //BlinkID.Instance ().AddUkdlRecognizer ();
            //BlinkID.Instance ().AddUsdlRecognizer ();
            //BlinkID.Instance ().AddZXingRecognizer ();

            //BlinkID.Instance ().AddVinParser ("VIN_PARSER_ID");

            //BlinkID.Instance ().AddRegexParser ("Blink\\d\\d\\d", "REGEX_PARSER_ID");
            //BlinkID.Instance ().AddIbanParser ("IBAN_PARSER_ID");
            //BlinkID.Instance ().AddEmailParser ("EMAIL_PARSER_ID");
            //BlinkID.Instance ().AddDateParser ("DATE_PARSER_ID");
            //BlinkID.Instance ().AddRawParser ("RAW_PARSER_ID");
            //BlinkID.Instance ().AddAmountParser ("AMOUNT_PARSER_ID");

            //BlinkID.Instance ().AddIdCardDetector ();

            //BlinkID.Instance ().ClearAllDetectors ();
            //BlinkID.Instance ().ClearAllParsers ();
            //BlinkID.Instance ().ClearAllRecognizers ();

            isFrontCamera = false;
        }
Beispiel #28
0
        static void Main()
        {
            Console.WriteLine("Please enter a positive integer number for the seconds: ");
            Console.Write("t = ");
            int t = int.Parse(Console.ReadLine());

            CustomDelegate myDelegate = new CustomDelegate(ExecuteMeEachTSeconds);

            Console.WriteLine("Please enter a positive integer for the number of repetions of the method calling");
            Console.Write("repetitions = ");
            int repetitions = int.Parse(Console.ReadLine());


            // I am not sure if this is exactly what the problem is asking for, but still, here is my solution:
            for (int i = 0; i < repetitions; i++)
            {
                myDelegate(t);
                Thread.Sleep(t * 1000);
            }
        }
Beispiel #29
0
        public void RaisesCustomDelegateIfRaiserInContextOnAdd()
        {
            var mock = new EventfulMock();

            mock.Behaviors.Add(new EventBehavior());
            mock.Behaviors.Add(StuntBehavior.Create((m, n) => m.CreateValueReturn(null)));

            var(id, name)   = (5, "foo");
            var(id2, name2) = (0, "");

            CustomDelegate handler = (i, n) => { id2 = i; name2 = n; };

            mock.Custom += handler;

            CallContext <EventRaiser> .SetData(new CustomEventRaiser(new object[] { id, name }));

            mock.Custom += null;

            Assert.Equal(id, id2);
            Assert.Equal(name, name2);
        }
        public static MulticastDelegate BindToEvent(string eventName, object source, CustomDelegate body)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            
            // Find the matching event defined on that type
            Type sourceType = source.GetType();
            EventInfo targetEvent = sourceType.GetEvent(eventName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);

            if (targetEvent == null)
                throw new ArgumentException(
                    string.Format("Event '{0}' was not found on source type '{1}'", eventName, sourceType.FullName));

            // When the event fires, redirect call from the event
            // handler to the CustomDelegate body
            Type delegateType = targetEvent.EventHandlerType;
            MulticastDelegate result = DelegateFactory.DefineDelegate(delegateType, body);

            targetEvent.AddEventHandler(source, result);
            return result;
        }
Beispiel #31
0
        public static void Main(string[] args)
        {
            Square sq  = (a) => a * a;
            int    rez = sq(5);

            Console.WriteLine(rez);

            LoginService.SetLogin();
            LoginService.SetPassword();

            CustomDelegate <int> cd = (int Tvalue) => Console.WriteLine(Tvalue);

            cd(11111);

            CustomDelegate <double> cd2 = (double Tvalue) => Console.WriteLine(Tvalue + 2);

            cd2(0.1);

            CustomDelegate <string> cd3 = (string Tvalue) => Console.WriteLine(Tvalue.IndexOf('a'));

            cd3("aaa");
        }
Beispiel #32
0
        public override System.Type ReturnType()
        {
            if (!delegateType.isAssigned)
            {
                return(typeof(object));
            }
            var type = delegateType.Get <System.Type>();

            methodInfo = type.GetMethod("Invoke");
            if (methodInfo != null)
            {
                if (methodInfo.ReturnType == typeof(void))
                {
                    return(CustomDelegate.GetActionDelegateType(methodInfo.GetParameters().Select(p => p.ParameterType).ToArray()));
                }
                else
                {
                    var types = methodInfo.GetParameters().Select(i => i.ParameterType).ToList();
                    types.Add(methodInfo.ReturnType);
                    return(CustomDelegate.GetFuncDelegateType(types.ToArray()));
                }
            }
            return(typeof(object));
        }
Beispiel #33
0
 public static void OverloadedMethod(CustomDelegate cd)
 {
     Console.WriteLine("OverloadedMethod(<CustomDelegate>)");
     cd(1.5f);
 }
 public CustomDelegateRedirector(CustomDelegate target)
 {
     _target = target;
 }
        public static MulticastDelegate DefineDelegate(Type delegateType, CustomDelegate methodBody, Type returnType, Type[] parameterTypes)
        {
            // Generate an interface that matches the given signature and return type
            Type interfaceType = InterfaceBuilder.DefineInterfaceMethod(returnType, parameterTypes);

            // Proxy the interface type 
            CustomDelegateRedirector redirector = new CustomDelegateRedirector(methodBody);
            object interfaceInstance = _factory.CreateProxy(typeof (object), redirector, interfaceType);

            // Map the call from the custom delegate to the target
            // delegate type
            MethodInfo targetMethod = interfaceType.GetMethods()[0];
            MulticastDelegate result = BindTo(delegateType, targetMethod, interfaceInstance);


            return result;
        }
 public static void OverloadedMethod (CustomDelegate cd) {
     Console.WriteLine("OverloadedMethod(<CustomDelegate>)");
     cd(1.5f);
 }
Beispiel #37
0
 public static void TestDelegate(CustomDelegate customDelegate, string content)
 {
     customDelegate(content);
 }
 public CustomDelegateInvoker(CustomDelegate targetDelegate, object[] suppliedArguments)
 {
     _targetDelegate = targetDelegate;
     _suppliedArguments = suppliedArguments;
 }
Beispiel #39
0
 public void Method(CustomDelegate customDelegate)
 {
     customDelegate();
 }
 public static MulticastDelegate DefineDelegate(CustomDelegate methodBody, Type returnType, params Type[] parameterTypes)
 {
     Type delegateType = DelegateFactory.DefineDelegateType("___Anonymous", returnType, parameterTypes);
     return DefineDelegate(delegateType, methodBody, returnType, parameterTypes);
 }