Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
J

Jost Pedro

@Jost Pedro
About
Posts
5
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Optimizing memory usage in Windows Vista
    J Jost Pedro

    Hi Willem!! well 200mb its a lot!! could you tell me how you turned of superfetch service? tanks Pedro

    Windows API performance help question

  • How to bind a TList with a DataGridView that contains DataGridViewComboBoxColumns
    J Jost Pedro

    Hi Guys, Im having trouble populating a datagridview that contains DataGridViewComboBoxColumns. I want to populate the datagrid with de contents of a TList but for some reason it is not working. The comboboxes are filled with values that match with does that might be in the Tlist and i use the following line to bind the list to the datagrid. dgTaskPredecessor.DataSource = task.Predecessors;//task.Predecessors is of TList type Can anyone help me? Tanks

    C# regex help tutorial question

  • Invoke Constructor method of any class that extends an Interface without having to specifically cast each class
    J Jost Pedro

    Hi guys, I have a class that extends an IMenuProvider interface and belongs to a plug-in project. In the UI project(other project) I've developed a menuService class that finds plug-ins that implement a IMenuProvider interface and execute the constructor method by using the invoke method. Here's the code.

    ...
    
     Type[] types = assembly.GetTypes();
                foreach (Type type in types)
                {
                    if (type.GetInterface("IMenuProvider") != null)
                    {
                        if (!ht.ContainsKey(type.FullName))
                        {
                            //get construct info.
                            ConstructorInfo cinfo = type.GetConstructor(System.Type.EmptyTypes);
                            
                            //invoke constructor 
                            IMenuProvider imp = (IMenuProvider)cinfo.Invoke(null);  **
                            ht.Add(type.FullName, imp);
                            RegisterProvider(imp);
                        }
                    }
                } 
    ...
    

    So what happens is the line marked with ** returns an error saying "Unable to cast object of type 'TestPlugin.PluginMenuProvider' to type 'Enki.UI.ComponentModel.IMenuProvider'." I know that I’m attempting to invoke the constructor method of the subclass PluginMenuProvider through the extension IMenuProvider but i don’t want to have to specify every subclass that extends the IMenuProvider interface. Now, my question is how can i invoke the constructor without having to declare and than cast each class type that extends the interface IMenuProvider like the line marked with ** does? Best regards. Pedro M.

    C# question design help

  • Compare types in a plugin API
    J Jost Pedro

    Hi mike, i believe that i miss guided you. I dont want to find which types in an assembly have a custom attribute. I pretend to find which assembly has a specific custom Attribute. So, want happens is I have an assembly that i know for sure that the custom attribute and i the only way that I get it saying that it has that attribute (return true) is comparing their FullName which,i think, is a rude solution to the problem. Tanks for your help. Best Regards Pedro M.

    C# design json help

  • Compare types in a plugin API
    J Jost Pedro

    Hi there, I’m trying to implement a plug in API in a application and I’m having problems in getting the Custom Attribute from an Assembly. First the custom attribute is something like this: [global::System.AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] public class AssemblyPluginAttribute : Attribute { readonly string pluginName; // This is a positional argument. public AssemblyPluginAttribute(string PluginName) { this.pluginName = PluginName; } public string PluginName { get { return this.pluginName; } } } Than in order to find a reference to this custom attribute I added to the plug-in project the following line. ... using Enki.UI.ComponentModel; [assembly: AssemblyPluginAttribute("TestPlugin")] namespace TestPlugin { ... Now ... to find if its a plug-in type assembly i look through the custom attributes of the assembly in order to find one matching with the one i defined (AssemblyPluginAttribute). The following line returns null list. Type AttType = typeof(Enki.UI.Plugins.AssemblyPluginAttribute); object[] obj = assembly.GetCustomAttributes(AttType, true); and the next one too... Attribute[] attlist= Attribute.GetCustomAttributes(assembly,AttType); but if instead of one of this two lines i use the following code ... foreach (Attribute att in Attribute.GetCustomAttributes(assembly)) { if (att.GetType().FullName.CompareTo(AttType.FullName)==0) return true; } ... it matches the full names!! I’ve tried many other ways to establish a possible comparison but none has the same result. I know, that if i found a way to get the result i desired i should stick to it an go on but I believe that this might lead me to a dead end in the future. Please, can anyone help me... to "see the light in the end of the tunnel"! :) Tanks Pedro M.

    C# design json help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups