Exemplo n.º 1
0
        /// <summary>
        /// Monitors stderr, writes lines to the datagrid.
        /// </summary>
        public void ErrorReaderThreadRunner()
        {
            InvokeDelegate invoker = new InvokeDelegate( this.WriteTextToLabel );
            while ( !this.killed )
            {
                string output = this.errorReader.ReadLine();
                if ( output != null )
                {
                    Console.WriteLine( output );
                }

                lock( this.xlock )
                {
                    this.tempText = output;
                    this.isError = true;

                    this.mainForm.BeginInvoke(invoker );

                    while ( this.tempText != null )
                    {
                        Thread.Sleep(1);
                    }
                }

            }
        }
Exemplo n.º 2
0
 static BeginMethodHandler()
 {
     try
     {
         Type          tArg1ByRef = typeof(TArg1).IsByRef ? typeof(TArg1) : typeof(TArg1).MakeByRefType();
         Type          tArg2ByRef = typeof(TArg2).IsByRef ? typeof(TArg2) : typeof(TArg2).MakeByRefType();
         Type          tArg3ByRef = typeof(TArg3).IsByRef ? typeof(TArg3) : typeof(TArg3).MakeByRefType();
         Type          tArg4ByRef = typeof(TArg4).IsByRef ? typeof(TArg4) : typeof(TArg4).MakeByRefType();
         Type          tArg5ByRef = typeof(TArg5).IsByRef ? typeof(TArg5) : typeof(TArg5).MakeByRefType();
         Type          tArg6ByRef = typeof(TArg6).IsByRef ? typeof(TArg6) : typeof(TArg6).MakeByRefType();
         Type          tArg7ByRef = typeof(TArg7).IsByRef ? typeof(TArg7) : typeof(TArg7).MakeByRefType();
         Type          tArg8ByRef = typeof(TArg8).IsByRef ? typeof(TArg8) : typeof(TArg8).MakeByRefType();
         DynamicMethod dynMethod  = IntegrationMapper.CreateBeginMethodDelegate(typeof(TIntegration), typeof(TTarget), new[] { tArg1ByRef, tArg2ByRef, tArg3ByRef, tArg4ByRef, tArg5ByRef, tArg6ByRef, tArg7ByRef, tArg8ByRef });
         if (dynMethod != null)
         {
             _invokeDelegate = (InvokeDelegate)dynMethod.CreateDelegate(typeof(InvokeDelegate));
         }
     }
     catch (Exception ex)
     {
         throw new CallTargetInvokerException(ex);
     }
     finally
     {
         if (_invokeDelegate is null)
         {
             _invokeDelegate = (TTarget instance, ref TArg1 arg1, ref TArg2 arg2, ref TArg3 arg3, ref TArg4 arg4, ref TArg5 arg5, ref TArg6 arg6, ref TArg7 arg7, ref TArg8 arg8) => CallTargetState.GetDefault();
         }
     }
 }
Exemplo n.º 3
0
        internal static unsafe int Initialize(IntPtr functions, int checksum)
        {
            assembliesContextManager = new AssembliesContextManager();
            assembliesContextManager.CreateAssembliesContext();

            plugins = new Dictionary <int, Plugin>();

            int     position = 0;
            IntPtr *buffer   = (IntPtr *)functions;

            unchecked {
                int     head             = 0;
                IntPtr *managedFunctions = (IntPtr *)buffer[position++];

                Invoke    = GenerateOptimizedFunction <InvokeDelegate>(managedFunctions[head++]);
                Exception = GenerateOptimizedFunction <ExceptionDelegate>(managedFunctions[head++]);
                Log       = GenerateOptimizedFunction <LogDelegate>(managedFunctions[head++]);
            }

            unchecked {
                int     head            = 0;
                IntPtr *nativeFunctions = (IntPtr *)buffer[position++];

                nativeFunctions[head++] = typeof(Core).GetMethod("ExecuteAssemblyFunction", BindingFlags.NonPublic | BindingFlags.Static).MethodHandle.GetFunctionPointer();
                nativeFunctions[head++] = typeof(Core).GetMethod("LoadAssemblyFunction", BindingFlags.NonPublic | BindingFlags.Static).MethodHandle.GetFunctionPointer();
                nativeFunctions[head++] = typeof(Core).GetMethod("UnloadAssemblies", BindingFlags.NonPublic | BindingFlags.Static).MethodHandle.GetFunctionPointer();
            }

            sharedFunctions = buffer[position++];
            sharedChecksum  = checksum;

            return(0xF);
        }
Exemplo n.º 4
0
        public static int RunWinForms(string arg)
        {
            bool isOk = false;

            try {
                //File.WriteAllText(@"C:\Projects\logify_sandbox\LogifyInject\LogifyInject\dbg.log", "LogifyInit.Run");
                const int totalTimeout = 5000;
                const int smallTimeout = 1000;
                int       count        = totalTimeout / smallTimeout;
                for (int i = 0; i < count; i++)
                {
                    if (Application.OpenForms == null || Application.OpenForms.Count <= 0)
                    {
                        Thread.Sleep(smallTimeout);
                    }
                    else
                    {
                        //File.WriteAllText(@"C:\Projects\DevExpress.Logify\Maintenance\LogifyInject\dbg.log", "Win.BeginInvoke");
                        Delegate call = new InvokeDelegate(InitLogifyWinForms);
                        Application.OpenForms[0].BeginInvoke(call);
                        isOk = true;
                        break;
                    }
                }
                if (!isOk)
                {
                    //File.WriteAllText(@"C:\Projects\DevExpress.Logify\Maintenance\LogifyInject\dbg.log", "Win.Direct");
                    InitLogifyWinForms();
                }
                return(0);
            }
            catch {
                return(1);
            }
        }
Exemplo n.º 5
0
        public static bool InvokeCoreApi(InvokeDelegate invoke)
        {
            // Note: try/catch block prevents propagating EntryPointNotFoundException in case when the user is using new methods which are absent in the native profiler library.
            HResults hr;

            try
            {
                hr = invoke();
            }
            catch (TypeLoadException e)
            {
                // Bug: System.EntryPointNotFoundException is private class in .NET Standard 1.x and .NET Core 1.x.
                if (e.GetType().FullName == "System.EntryPointNotFoundException")
                {
                    return(false);
                }
                throw;
            }
            switch (hr)
            {
            case HResults.S_OK:
                return(true);

            case HResults.S_FALSE:
                return(false);

            default:
                throw new InternalProfilerException((int)hr);
            }
        }
Exemplo n.º 6
0
        public object Invoke(object target,
                             MethodInfo method,
                             object[] arguments,
                             InvokeDelegate @delegate)
        {
            HandlerPipeline  pipeline   = GetPipeline(method, target);
            MethodInvocation invocation = new MethodInvocation(target, method, arguments);

            IMethodReturn result =
                pipeline.Invoke(invocation,
                                delegate
            {
                try
                {
                    object returnValue = @delegate(arguments);
                    return(new MethodReturn(invocation.Arguments, method.GetParameters(), returnValue));
                }
                catch (Exception ex)
                {
                    return(new MethodReturn(ex, method.GetParameters()));
                }
            });

            if (result.Exception != null)
            {
                FieldInfo remoteStackTraceString = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic);
                remoteStackTraceString.SetValue(result.Exception, result.Exception.StackTrace + Environment.NewLine);
                throw result.Exception;
            }

            return(result.ReturnValue);
        }
Exemplo n.º 7
0
 public AuthorizeMiddleware(InvokeDelegate next, Action <AuthorizationOptions> setupAction)
 {
     this.AuthorizationOptions = new AuthorizationOptions();
     setupAction.Invoke(this.AuthorizationOptions);
     authorizationService = Application.Current.GetService <AuthorizationService>();
     _next = next;
 }
Exemplo n.º 8
0
		public static void Invoke(System.Windows.Forms.Control con, InvokeDelegate callback) {
			if (con.InvokeRequired) {
				con.Invoke(callback);
			} else {
				callback();
			}
		}
Exemplo n.º 9
0
		public static void Invoke(System.Windows.Forms.Control Control, InvokeDelegate Delegate) {
			if (Control.InvokeRequired) {
				Control.Invoke(Delegate);
			} else {
				Delegate();
			}
		}
Exemplo n.º 10
0
        internal static unsafe int Initialize(IntPtr managedFunctionsBuffer, IntPtr nativeFunctionsBuffer, IntPtr sharedFunctionsBuffer)
        {
            assembliesContextManager = new AssembliesContextManager();
            assembliesContextManager.CreateAssembliesContext();

            pluginLoaders = new Dictionary <int, PluginLoader>();

            unchecked {
                int     head             = 0;
                IntPtr *managedFunctions = (IntPtr *)managedFunctionsBuffer;

                Invoke    = GenerateOptimizedFunction <InvokeDelegate>(managedFunctions[head++]);
                Exception = GenerateOptimizedFunction <ExceptionDelegate>(managedFunctions[head++]);
                Log       = GenerateOptimizedFunction <LogDelegate>(managedFunctions[head++]);
            }

            unchecked {
                int     head            = 0;
                IntPtr *nativeFunctions = (IntPtr *)nativeFunctionsBuffer;

                nativeFunctions[head++] = typeof(Core).GetMethod("ExecuteAssemblyFunction", BindingFlags.NonPublic | BindingFlags.Static).MethodHandle.GetFunctionPointer();
                nativeFunctions[head++] = typeof(Core).GetMethod("LoadAssemblyFunction", BindingFlags.NonPublic | BindingFlags.Static).MethodHandle.GetFunctionPointer();
                nativeFunctions[head++] = typeof(Core).GetMethod("UnloadAssemblies", BindingFlags.NonPublic | BindingFlags.Static).MethodHandle.GetFunctionPointer();
            }

            sharedFunctions = sharedFunctionsBuffer;

            return(0xF);
        }
Exemplo n.º 11
0
        private SimpleProgress(InvokeDelegate cancelCallback)
        {
            InitializeComponent();
            this.cancel = cancelCallback;

            this.Closing += new CancelEventHandler(ThreadedInfoForm_Closing);
        }
Exemplo n.º 12
0
        private SimpleProgress(InvokeDelegate cancelCallback)
        {
            InitializeComponent();
            this.cancel = cancelCallback;

            this.Closing += new CancelEventHandler(ThreadedInfoForm_Closing);
        }
Exemplo n.º 13
0
    public IAsyncResult BeginInvoke(Delegate method, object[] args)
    {
        ElapsedEventHandler handler = (ElapsedEventHandler)method;
        InvokeDelegate      D       = Invoke;

        return(D.BeginInvoke(handler, args, CallbackMethod, null));
    }
Exemplo n.º 14
0
        private void MonForm_Load(object sender, EventArgs e)
        {
            CDM = new CDisplayManager();
            displayinit();
            DisplayRefresh();
            cm = new CMonitor();
            cm.RegMonitor(this);
            myInvoke = new InvokeDelegate(Invokefun);
            chebm1   = new Bitmap(".\\img\\scar00.gif");
            chebm2   = new Bitmap(".\\img\\car00.gif");
            Color backcolor = chebm1.GetPixel(1, 1);

            chebm1.MakeTransparent(backcolor);
            backcolor = chebm2.GetPixel(1, 1);
            chebm2.MakeTransparent(backcolor);
            chebm = chebm2;
            radioButton1.Checked = false;
            radioButton2.Checked = true;
            cm.Che_Type          = 1;
            groupBox4.Enabled    = false;
            radioButton3.Checked = true;
            radioButton4.Checked = false;
            radioButton5.Checked = true;
            radioButton6.Checked = false;
            alarm = true;
            //tmp数据
            lookdata = new CMonData();
        }
Exemplo n.º 15
0
 private async Task ControlBeginInvoke(Label label, InvokeDelegate invokeDelegate)
 {
     await Task.Delay(250).ContinueWith((t) =>
     {
         label.BeginInvoke(invokeDelegate);
     });
 }
Exemplo n.º 16
0
        public SetUser_Form(ModuleSettings settings)
        {
            InitializeComponent();
            this.settings = settings;

            label_xm.Text               = string.Empty;
            label_sfzhm.Text            = string.Empty;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            idcardinfo = new CIDCardInfo();
            idcardinfo.InitIDcardDev();
            idcardinfo.Start();
            idcardinfo.OnIDCardReceived += new CIDCardInfo.IDCardRequest(idcardinfo_OnIDCardReceived);
            userinvoke = new InvokeDelegate(userinvokefun);

            conn = new SqlConnection();
            conn.ConnectionString = "Data Source=" + settings.Ipaddress + ";Initial Catalog=zhuangkao;Persist Security Info=True;User ID=sa;Password=cgcsxb";
            ad = new SqlDataAdapter();
            string sqlstr = "select * from zkuser";

            ad.SelectCommand = new SqlCommand(sqlstr, conn);
            SqlCommandBuilder cmdbuilder = new SqlCommandBuilder(ad);

            conn.Open();
            ds = new DataSet();
            ad.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];
            dataGridView1.Columns["username"].HeaderText  = "用户名";
            dataGridView1.Columns["nickname"].HeaderText  = "警号";
            dataGridView1.Columns["class"].HeaderText     = "权限级别";
            dataGridView1.Columns["password"].Visible     = false;
            dataGridView1.Columns["myorder"].Visible      = false;
            dataGridView1.Columns["idcardnumber"].Visible = false;
        }
Exemplo n.º 17
0
 public void Invoke(InvokeDelegate d)
 {
     if (d != null)
     {
         d();
     }
 }
Exemplo n.º 18
0
        /// <summary>
        /// 调用
        /// </summary>
        /// <param name="endPoint"></param>
        /// <param name="handler"></param>
        /// <param name="isSendPoint"></param>
        /// <param name="paramters"></param>
        /// <returns></returns>
        protected virtual object ExecuteInovke <T>(EndPointInfo endPoint, InvokeDelegate <T> handler, bool isSendPoint,
                                                   params object[] paramters)
        {
            var key = string.Format("{0}{1}", typeof(T), endPoint.Name);

            CheckClient <T>(endPoint, key);
            if (!TryOpen <T>(key, endPoint))
            {
                return(null);
            }
            if (isSendPoint)
            {
                if (paramters == null)
                {
                    paramters = new object[] { endPoint };
                }
                else
                {
                    var temp = new List <object>(paramters)
                    {
                        endPoint
                    };
                    paramters = temp.ToArray();
                }
            }
            object rev = handler((T)Clients[key], paramters);

            endPoint.UseConnect();
            return(rev);
        }
Exemplo n.º 19
0
        private void Filter_SelectionChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            InvokeDelegate del = () =>
            {
                if (e.NewValue != null)
                {
                    var item = e.NewValue as RibbonGalleryItem;
                    if (sender == Filter)
                    {
                        ViewModel.AssignedToFilterSelectedItem = (string)item.Content;
                    }
                    else
                    {
                        ViewModel.ChildrenFilterSelectedItem = (string)item.Name;
                    }
                    var grid = WpfHelper.FindVisualChild <DataGrid>(this);
                    if (grid != null)
                    {
                        var workItemControl = WorkItemControl.SelectedItem;
                        if (workItemControl != null)
                        {
                            workItemControl.MoveFocus(new TraversalRequest(FocusNavigationDirection.Up));
                        }
                    }
                }
                else
                {
                    ResetFilter();
                }
            };

            Dispatcher.Invoke(del, DispatcherPriority.DataBind);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 调用
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="endPointInfos"></param>
        /// <param name="invokeHandler"></param>
        /// <param name="getEndPointsHandler"></param>
        /// <param name="isSendPoint"></param>
        /// <param name="paramters"></param>
        /// <returns></returns>
        public object Invoke <T>(IList <EndPointInfo> endPointInfos, InvokeDelegate <T> invokeHandler, GetEndPointsDelegate getEndPointsHandler, bool isSendPoint,
                                 params object[] paramters)
        {
            var points = getEndPointsHandler != null?getEndPointsHandler(endPointInfos, paramters) : endPointInfos.Where(it => it.IsException == false).ToList();

            if (points == null || points.Count == 0)
            {
                return(null);
            }
            EndPointInfo endPoint  = points.GetBestEndPoint();
            var          endPoints = endPoint.GetAllEndPoints();

            for (int i = 0; i < endPoints.Count; i++)
            {
                try
                {
                    return(ExecuteInovke(endPoints[i], invokeHandler, isSendPoint, paramters));
                }
                catch (Exception ex)
                {
                    Log.AddException(ex);
                    endPoints[i].IsException = true;
                    Action <EndPointInfo> action = CheckConnectionAlive <T>;
                    action.BeginInvoke(endPoint, null, null);
                }
            }
            return(null);
        }
Exemplo n.º 21
0
        public main_view(CModel model)
        {
            InitializeComponent();
            message = new CMyMessageFuns();
            data    = new byte[30];

            this.model = model;
            ctrl       = new CController(model, this);
            pictureBox1.ImageLocation = ".\\photonull.bmp";

            string connstr = "Data Source=" + model.settings.Ipaddress + ";Initial Catalog=zhuangkao;Persist Security Info=True;User ID=sa;Password=cgcsxb";//;Pooling=true;Max Pool Size=20;";

            conn = new SqlConnection(connstr);
            conn.Open();

            view_init();

            model.OnIDCardReceived += new CModel.IDCardRequest(model_OnIDCardReceived);
            TextInvoke              = new InvokeDelegate(TextInvoke_fun);
            datagridinvoke          = new DataGridInvokeDelegate(datagridinvokefun);
            string[] tmpstr = model.settings.Ksy.Split(',');
            for (int i = 0; i < tmpstr.Length; i++)
            {
                comboBox1.Items.Add(tmpstr[i]);
            }
            // comboBox1.Text = comboBox1.Items[0].ToString();
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.EditMode      = DataGridViewEditMode.EditProgrammatically;
            textBox1.Focus();
        }
Exemplo n.º 22
0
        /// <summary>
        /// Monitors stderr, writes lines to the datagrid.
        /// </summary>
        public void ErrorReaderThreadRunner()
        {
            InvokeDelegate invoker = new InvokeDelegate(this.WriteTextToLabel);

            while (!this.killed)
            {
                string output = this.errorReader.ReadLine();
                if (output != null)
                {
                    Console.WriteLine(output);
                }


                lock (this.xlock)
                {
                    this.tempText = output;
                    this.isError  = true;

                    this.mainForm.BeginInvoke(invoker);



                    while (this.tempText != null)
                    {
                        Thread.Sleep(1);
                    }
                }
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Invoke the delegate with the provided parameters.<br></br>
        /// The method must be static
        /// </summary>
        /// <returns></returns>
        public object Invoke(object instance, params object[] parameters)
        {
            if ((instance == null) && ((Access & AccessModifiers.Static) == 0))
            {
                throw new ArgumentNullException(nameof(instance), "Can not read value without a new instance");
            }

            var parameterCount = ParameterCount;

            if (parameters.Length >= parameterCount)
            {
                return(InvokeDelegate.Invoke(instance, parameters));
            }

            var oldParameters = parameters;

            parameters = new object[parameterCount];
            for (var i = oldParameters.Length + 1; i < parameterCount; i++)
            {
                var parameterInfo = Parameters[i];
                if (parameterInfo.IsOptional == false)
                {
                    throw new ArgumentException("Not enough parameters", nameof(parameters));
                }
                parameters[i] = parameterInfo.DefaultValue;
            }
            oldParameters.CopyTo(parameters, 0);
            return(InvokeDelegate.Invoke(instance, parameters));
        }
Exemplo n.º 24
0
 public Main()
 {
     Instance = this;
     InitializeComponent();
     LoadCheats();
     InvokeControls    = new InvokeDelegate(UpdateInformation);
     InvokeControlsPos = new InvokeDelegatePos(UpdateInformationPos);
 }
Exemplo n.º 25
0
 public void ControlEventMethod(object sender, EventArgs e)
 {
     if (lbltmp.InvokeRequired)
     {
         InvokeDelegate del = new InvokeDelegate(InvokeController);
         lbltmp.BeginInvoke(del, (List <DataResult.DBResult>)sender);
     }
 }
Exemplo n.º 26
0
        public JSObject(object target)
        {
            var type          = target.GetType();
            var invokeMethod  = type.GetMethod(nameof(Invoke));
            var disposeMethod = type.GetMethod(nameof(Dispose));

            _invokeMethodDelegate  = Delegate.CreateDelegate(typeof(InvokeDelegate), target, invokeMethod) as InvokeDelegate;
            _disposeMethodDelegate = Delegate.CreateDelegate(typeof(DisposeDelegate), target, disposeMethod) as DisposeDelegate;
        }
 private void EnsureIsInitializedCore()
 {
     int num;
     int num2;
     InvokeDelegate delegate2 = new InvokerUtil().GenerateInvokeDelegate(this.Method, out num, out num2);
     this.outputParameterCount = num2;
     this.inputParameterCount = num;
     this.invokeDelegate = delegate2;
 }
Exemplo n.º 28
0
 public CarSignalForm()
 {
     InitializeComponent();
     myinit();
     cm = new CMonitor();
     cm.RegMonitor(this);
     cm.LvboDelayTime = 10;
     myInvoke         = new InvokeDelegate(Invokefun);
     mycount          = 0;
 }
Exemplo n.º 29
0
        private void EnsureIsInitializedCore()
        {
            // Only pass locals byref because InvokerUtil may store temporary results in the byref.
            // If two threads both reference this.count, temporary results may interact.
            InvokeDelegate invokeDelegate = InvokerUtil.GenerateInvokeDelegate(Method, out int inputParameterCount, out int outputParameterCount);

            _outputParameterCount = outputParameterCount;
            _inputParameterCount  = inputParameterCount;
            _invokeDelegate       = invokeDelegate; // must set this last due to race
        }
        private void EnsureIsInitializedCore()
        {
            int            num;
            int            num2;
            InvokeDelegate delegate2 = new InvokerUtil().GenerateInvokeDelegate(this.Method, out num, out num2);

            this.outputParameterCount = num2;
            this.inputParameterCount  = num;
            this.invokeDelegate       = delegate2;
        }
Exemplo n.º 31
0
 /// <summary>
 /// Ivoke the state method on the given target if the state has one
 /// </summary>
 public void Invoke(object target, float time)
 {
     if (InvokeWithTimeDelegate != null)
     {
         InvokeWithTimeDelegate.Invoke(target, time);
     }
     else if (InvokeDelegate != null)
     {
         InvokeDelegate.Invoke(target);
     }
 }
Exemplo n.º 32
0
 void CreateDelegateNoLambda()
 {
     if (IsVoidMethod)
     {
         invokeDelegate = (session, obj) => MethodInfo.Invoke(session, obj);
     }
     else
     {
         invokeDelegate = (session, obj) => MethodInfo.Invoke(session, obj);
     }
 }
Exemplo n.º 33
0
 public static void Invoke(System.Windows.Forms.Control con, InvokeDelegate callback)
 {
     if (con.InvokeRequired)
     {
         con.Invoke(callback);
     }
     else
     {
         callback();
     }
 }
Exemplo n.º 34
0
        public InvokeDelegate Build()
        {
            InvokeDelegate next = context => Task.Run(() => { });

            foreach (var current in _middlewares.Reverse())
            {
                next = current(next);
            }

            return(next);
        }
Exemplo n.º 35
0
        private void _server_OnConnect(TcpServerConnection connection)
        {
            _server.Send($"Welcome!{_nl}");
            InvokeDelegate del = () =>
            {
                EndPoint ep = connection.Socket.Client.RemoteEndPoint;
                handleInput($"Remote endpoint : {ep}{_nl}");
            };

            Invoke(del);
        }
Exemplo n.º 36
0
        public static SimpleProgress StartProgress( InvokeDelegate cancelCallback
                                        ,string title
                                        ,string initialProgress )
        {
            var win = new SimpleProgress(cancelCallback);
            win.Text = title;
            win.progressMessage.Text = initialProgress;

            win.Show();

            return win;
        }
Exemplo n.º 37
0
        public void LogLine(String s, bool debug = false)
        {
            if (_options != null && !_options.PrintDebug && debug)
            {
                return;
            }
            if (logBox.InvokeRequired)
            {
                var d = new InvokeDelegate(LogLine);
                Invoke(d, new object[] { s, debug });
                return;
            }
            if (debug) s = "Debug: " + s;

            if (logBox.Lines.Length > 100)
            {
                logBox.Lines = logBox.Lines.Skip(logBox.Lines.Length - 100).ToArray();
            }

            logBox.AppendText((logBox.Text.Length > 0 ? Environment.NewLine : "") + DateTime.Now.ToString("d.M.yy HH:mm:ss: ") + s);
        }
Exemplo n.º 38
0
		public static void Invoke(System.Windows.Forms.ToolStripItem con, InvokeDelegate callback) {
			callback();
		}
Exemplo n.º 39
0
 public void Invoke(InvokeDelegate d)
 {
     if (d!=null) d();
 }
Exemplo n.º 40
0
    public static int Main()
    {
        SCMethod ();

        try {
            CMethod ();
            error ("static critical method called");
        } catch (MethodAccessException) {
        }

        SCClass sc = new SCClass ();
        sc.Method ();

        try {
            CClass c = new CClass (); // Illegal
            error ("critical object instantiated");
            c.Method ();	// Illegal
            error ("critical method called");
        } catch (MethodAccessException) {
        }

        try {
            doSCDev ();
            error ("security-critical-derived class error");
        } catch (TypeLoadException) {
        }

        try {
            doCMethodDev ();
        } catch (TypeLoadException) {
        }

        try {
            getpid ();
            error ("pinvoke called");
        } catch (MethodAccessException) {
        }

        try {
            MethodDelegate md = new MethodDelegate (CClass.StaticMethod);
            md ();
            error ("critical method called via delegate");
        } catch (MethodAccessException) {
        }

        try {
            CriticalClass.NestedClassInsideCritical.Method ();
        } catch (MethodAccessException) {
        }

        try {
            doSCInterfaceDev ();
        } catch (TypeLoadException) {
        }

        /*
        try {
            unsafeMethod ();
        } catch (VerificationException) {
        }
        */

        try {
            Type type = Type.GetType ("Test");
            MethodInfo method = type.GetMethod ("TransparentReflectionCMethod");

            method.Invoke(null, null);
        } catch (MethodAccessException) {
            error ("transparent method not called via reflection");
        }

        try {
            Type type = Type.GetType ("Test");
            MethodInfo method = type.GetMethod ("ReflectionCMethod");

            method.Invoke(null, null);
        } catch (MethodAccessException) {
        }

        try {
            Type type = Type.GetType ("Test");
            MethodInfo method = type.GetMethod ("TransparentReflectionCMethod");
            InvokeDelegate id = new InvokeDelegate (method.Invoke);

            id (null, null);
        } catch (MethodAccessException) {
            error ("transparent method not called via reflection delegate");
        }

        try {
            Type type = Type.GetType ("Test");
            MethodInfo method = type.GetMethod ("ReflectionCMethod");
            InvokeDelegate id = new InvokeDelegate (method.Invoke);

            id (null, null);
        } catch (MethodAccessException) {
        }

        //Console.WriteLine ("ok");

        if (haveError)
            return 1;

        return 0;
    }
Exemplo n.º 41
0
		internal static void Invoke(System.Windows.Forms.ToolStripItem Control, InvokeDelegate Delegate) {
			Delegate();
		}
Exemplo n.º 42
0
 private void EnsureIsInitializedCore()
 {
     // Only pass locals byref because InvokerUtil may store temporary results in the byref.
     // If two threads both reference this.count, temporary results may interact.
     int inputParameterCount;
     int outputParameterCount;
     var invokeDelegate = new InvokerUtil().GenerateInvokeDelegate(Method, out inputParameterCount, out outputParameterCount);
     _outputParameterCount = outputParameterCount;
     _inputParameterCount = inputParameterCount;
     _invokeDelegate = invokeDelegate;  // must set this last due to race
 }
Exemplo n.º 43
0
 /// <summary>
 /// Method which  fills the table
 /// </summary>
 /// <param name="response">data from table</param>
 public void FillTable(string response)
 {
     bool done = true;
     string[] strArr = response.Split(',');
     int j = 0;
     int i = 0;
     InvokeDelegate invM = new InvokeDelegate(InvokeMethodMan);
     InvokeDelegate invW = new InvokeDelegate(InvokeMethodWoman);
     while (done)
     {               
         if (Convert.ToString(strArr[j]) == "Person.Man")
         {
             this.dataGridView1.Invoke(invM, new Object[] {strArr,i,j});
             i++;
         }
         else if (Convert.ToString(strArr[j]) == "Person.Woman")
         {
             this.dataGridView1.Invoke(invW, new Object[] { strArr, i, j });
             i++;
         }
         
         if (j+6> strArr.Length)
         {
            done = false;
         }
         else
         {
             j = j + 6;
         }
     }
 }
Exemplo n.º 44
0
 internal void Invoke(InvokeDelegate todo)
 {
     base.Invoke(todo);
 }
Exemplo n.º 45
0
 // OnReceivedFreq is called from the FreqUpdateUdpListener threaed
 private void OnReceivedFreq(EntryFrequencyUpdate efu)
 {
     // transfer the notification to the Form's thread (Main)
     InvokeDelegate id = new InvokeDelegate(AddOrUpdateRemote);
     BeginInvoke(id, efu);
 }
Exemplo n.º 46
0
	public static int Main ()
	{
		SCMethod ();

		try {
			CMethod ();
			error ("static critical method called");
		} catch (MethodAccessException) {
		}

		SCClass sc = new SCClass ();
		sc.Method ();

		try {
			CClass c = new CClass (); // Illegal
			error ("critical object instantiated");
			c.Method ();	// Illegal
			error ("critical method called");
		} catch (MethodAccessException) {
		}

		try {
			doSCDev ();
			error ("security-critical-derived class error");
		} catch (TypeLoadException) {
		}

		try {
			doCMethodDev ();
		} catch (TypeLoadException) {
		}

		try {
			getpid ();
			error ("pinvoke called");
		} catch (MethodAccessException) {
		}

		try {
			MethodDelegate md = new MethodDelegate (CClass.StaticMethod);
			md ();
			error ("critical method called via delegate");
		} catch (MethodAccessException) {
		}

		try {
			CriticalClass.NestedClassInsideCritical.Method ();
		} catch (MethodAccessException) {
		}

		try {
			doSCInterfaceDev ();
		} catch (TypeLoadException) {
		}

		/*
		try {
			unsafeMethod ();
		} catch (VerificationException) {
		}
		*/

		try {
			Type type = Type.GetType ("Test");
			MethodInfo method = type.GetMethod ("TransparentReflectionCMethod");

			method.Invoke(null, null);
		} catch (MethodAccessException) {
			error ("transparent method not called via reflection");
		}

		try {
			Type type = Type.GetType ("Test");
			MethodInfo method = type.GetMethod ("ReflectionCMethod");

			method.Invoke(null, null);
		} catch (MethodAccessException) {
		}

		try {
			Type type = Type.GetType ("Test");
			MethodInfo method = type.GetMethod ("TransparentReflectionCMethod");
			InvokeDelegate id = new InvokeDelegate (method.Invoke);

			id (null, null);
		} catch (MethodAccessException) {
			error ("transparent method not called via reflection delegate");
		}

		try {
			Type type = Type.GetType ("Test");
			MethodInfo method = type.GetMethod ("ReflectionCMethod");
			InvokeDelegate id = new InvokeDelegate (method.Invoke);

			id (null, null);
		} catch (MethodAccessException) {
		}


		// wrapper 7
		try {
			CallStringTest ();
		} catch (MethodAccessException) {
			error ("string test failed");
		}

		try {
			doBadTransparentOverrideClass ();
			error ("BadTransparentOverrideClass error");
		} catch (TypeLoadException) {
		}

		try {
			doBadSafeCriticalOverrideClass ();
			error ("BadSafeCriticalOverrideClass error");
		} catch (TypeLoadException) {
		}

		try {
			doBadCriticalOverrideClass ();
			error ("BadCriticalOverrideClass error");
		} catch (TypeLoadException) {
		}

		new TransparentClassWithSafeCriticalDefaultConstructor ();
		try {
			new TransparentInheritFromSafeCriticalDefaultConstructor ();
		} catch (TypeLoadException) {
		}
		new SafeInheritFromSafeCriticalDefaultConstructor ();

		// arrays creation tests
		ArraysCreatedByTransparentCaller ();
		ArraysCreatedBySafeCriticalCaller ();
		// the above also calls ArraysCreatedBySafeCriticalCaller since (Transparent) Main cannot call it directly

		if (haveError)
			return 1;

//		Console.WriteLine ("ok");
		return 0;
	}
Exemplo n.º 47
0
		static SecuredReflectionMethods()
		{
			if (!SecuredReflection.HasReflectionPermission)
			{
				if (!ProfilerInterceptor.IsProfilerAttached)
					ProfilerInterceptor.ThrowElevatedMockingException();

				ProfilerInterceptor.CreateDelegateFromBridge("ReflectionInvoke", out Invoke);
				ProfilerInterceptor.CreateDelegateFromBridge("ReflectionGetProperty", out GetProperty);
				ProfilerInterceptor.CreateDelegateFromBridge("ReflectionSetProperty", out SetProperty);
				ProfilerInterceptor.CreateDelegateFromBridge("ReflectionGetField", out GetField);
				ProfilerInterceptor.CreateDelegateFromBridge("ReflectionSetField", out SetField);
			}
			else
			{
				Invoke = (method, instance, args) => method.Invoke(instance, args);
				GetProperty = (prop, instance, indexArgs) => prop.GetValue(instance, indexArgs);
				SetProperty = (prop, instance, value, indexArgs) => prop.SetValue(instance, value, indexArgs);
				GetField = (field, instance) => field.GetValue(instance);
				SetField = (field, instance, value) => field.SetValue(instance, value);
			}
		}
Exemplo n.º 48
0
 //allow us to invoke events on the view UI thread
 public static void Invoke(this IView view, InvokeDelegate d)
 {
     view.Invoke(d);
 }
Exemplo n.º 49
0
 public static void Invoke(InvokeDelegate callback)
 {
     lock (m_delayedCallbacks)
     {
         m_delayedCallbacks.Add(callback);
     }
 }
Exemplo n.º 50
0
 public void Invoke(InvokeDelegate d)
 {
     base.Invoke(d);
 }
Exemplo n.º 51
0
        /// <summary>
        /// Initialises a new instance of toxav.
        /// </summary>
        /// <param name="tox"></param>
        /// <param name="settings"></param>
        /// <param name="max_calls"></param>
        public ToxAv(ToxHandle tox, ToxAvCodecSettings settings, int max_calls)
        {
            toxav = ToxAvFunctions.New(tox, max_calls);

            if (toxav == null || toxav.IsInvalid)
                throw new Exception("Could not create a new instance of toxav.");

            MaxCalls = max_calls;
            CodecSettings = settings;

            Invoker = new InvokeDelegate(dummyinvoker);

            callbacks();
        }
Exemplo n.º 52
0
        /// <summary>
        /// Initializes a new instance of tox.
        /// </summary>
        /// <param name="options"></param>
        public Tox(ToxOptions options)
        {
            tox = ToxFunctions.New(ref options);

            if (tox == null || tox.IsInvalid)
                throw new Exception("Could not create a new instance of toxav.");

            Options = options;
            Invoker = new InvokeDelegate(dummyinvoker);

            callbacks();
        }