Ejemplo n.º 1
0
        private void RunWithNullParamsButton_Click(object sender, EventArgs e)
        {
            MethodPlugInfo plugInfo = SelectedPluggedMethodInfo;

            if (plugInfo != null)
            {
                MethodBase cosmosPlugMethod = plugInfo.CosmosMethodInfo;
                try
                {
                    //I'm expecting all plug methods to be static (because they are at the moment).
                    //Should this ever change, the following code will need a complete re-write

                    var      netParams = cosmosPlugMethod.GetParameters();
                    object[] paramVals = new object[netParams.Length];
                    for (int i = 0; i < paramVals.Length; i++)
                    {
                        paramVals[i] = null;
                    }
                    object result = cosmosPlugMethod.Invoke(null, paramVals);
                    RunResultBox.Text = "Successful! \r\nOutput object:\r\n" + result.ToString();
                }
                catch (TargetInvocationException ex)
                {
                    RunResultBox.Text = "Target threw exception: " + ex.InnerException.GetType().Name + "\r\n" + ex.InnerException.Message;
                }
                catch (Exception ex)
                {
                    RunResultBox.Text = "Exception (probably invalid parameters): " + ex.GetType().Name + "\r\n" + ex.Message;
                }
            }
        }
Ejemplo n.º 2
0
        private void NetPlugCalssesListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            CosmosPlugClassesListBox.Items.Clear();
            PluggedMethodsListBox.Items.Clear();
            UnPluggedMethodsListBox.Items.Clear();

            NetClassPlugInfo plugInfo = SelectedNetClassInfo;

            if (SelectedNetClassInfo != null)
            {
                List <Type> cosmosPlugClassTypes = plugManager.PlugImpls[plugInfo.NetClassType];
                foreach (Type aCosmosPlugClassType in cosmosPlugClassTypes)
                {
                    AddPlugEntry(new CosmosClassPlugInfo(aCosmosPlugClassType), CosmosPlugClassesListBox);
                }

                //Get all methods on the Net class
                //Then try and resolve them :)

                Type netType = plugInfo.NetClassType;

                var netMethods = netType.GetMethods(BindingFlags.Instance | BindingFlags.Static |
                                                    BindingFlags.NonPublic | BindingFlags.Public);
                foreach (System.Reflection.MethodInfo netMethodInfo in netMethods)
                {
                    var netParams        = netMethodInfo.GetParameters();
                    var netParamTypes    = netParams.Select(q => q.ParameterType).ToArray();
                    var cosmosMethodInfo = plugManager.ResolvePlug(netMethodInfo, netParamTypes);

                    MethodPlugInfo methodPlugInfo = new MethodPlugInfo(netMethodInfo, cosmosMethodInfo);
                    if (cosmosMethodInfo != null)
                    {
                        AddPlugEntry(methodPlugInfo, PluggedMethodsListBox);
                    }
                    else
                    {
                        AddPlugEntry(methodPlugInfo, UnPluggedMethodsListBox);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void NetPlugCalssesListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            CosmosPlugClassesListBox.Items.Clear();
            PluggedMethodsListBox.Items.Clear();
            UnPluggedMethodsListBox.Items.Clear();

            NetClassPlugInfo plugInfo = SelectedNetClassInfo;
            if(SelectedNetClassInfo != null)
            {
                List<Type> cosmosPlugClassTypes = plugManager.PlugImpls[plugInfo.NetClassType];
                foreach(Type aCosmosPlugClassType in cosmosPlugClassTypes)
                {
                    AddPlugEntry(new CosmosClassPlugInfo(aCosmosPlugClassType), CosmosPlugClassesListBox);
                }

                //Get all methods on the Net class
                //Then try and resolve them :)

                Type netType = plugInfo.NetClassType;

                var netMethods = netType.GetMethods(BindingFlags.Instance | BindingFlags.Static |
                                   BindingFlags.NonPublic | BindingFlags.Public);
                foreach (System.Reflection.MethodInfo netMethodInfo in netMethods)
                {
                    var netParams = netMethodInfo.GetParameters();
                    var netParamTypes = netParams.Select(q => q.ParameterType).ToArray();
                    var cosmosMethodInfo = plugManager.ResolvePlug(netMethodInfo, netParamTypes);

                    MethodPlugInfo methodPlugInfo = new MethodPlugInfo(netMethodInfo, cosmosMethodInfo);
                    if (cosmosMethodInfo != null)
                    {
                        AddPlugEntry(methodPlugInfo, PluggedMethodsListBox);
                    }
                    else
                    {
                        AddPlugEntry(methodPlugInfo, UnPluggedMethodsListBox);
                    }
                }
            }
        }