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
  1. Home
  2. General Programming
  3. C#
  4. Plugins

Plugins

Scheduled Pinned Locked Moved C#
hostingquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pokabot
    wrote on last edited by
    #1

    How do you give a plugin access to all data and methods of the hosting application? Is it possible to set a plugins/interfaces method to respond to a windows event?

    P E 2 Replies Last reply
    0
    • P pokabot

      How do you give a plugin access to all data and methods of the hosting application? Is it possible to set a plugins/interfaces method to respond to a windows event?

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      You don't give a plugin access to the data and methods of the hosting application. Your host communicates with the plugin (which is the opposite way around). Typically, your application will provide some interfaces which your plugin may or may not implement. For instance:

      public interface IDataWrapper
      {
        object State{ get ; set ; }
        bool HasProcessed{ get; }
      }
      
      public interface IPlugin
      {
        void Start();
      }
      
      public class MyPlugin : IPlugin, IDataWrapper
      {
        private object _state;
        private bool _isSuccessful = false;
        public object State 
        {
          get { return _state; }
          set { _state = value; }
        }
        public bool HasProcessed
        {
          get { return _isSuccessful; }
        }
        // Do some processing with this...
        public void Start()
        {
          // Do something....
        }
      }
      

      Then, in your application you would load the plugin and do something like:

      IPlugin plugin = LoadPlugin(...);
      IDataWrapper wrapped = plugin as IDataWrapper;
      if (wrapped != null)
      {
        wrapped.State = ...;
      }
      
      plugin.Start();
      
      if (wrapped != null)
      {
        if (wrapped.HasProcessed)
        {
          ...
        }
      }
      

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      1 Reply Last reply
      0
      • P pokabot

        How do you give a plugin access to all data and methods of the hosting application? Is it possible to set a plugins/interfaces method to respond to a windows event?

        E Offline
        E Offline
        Ed Poore
        wrote on last edited by
        #3

        Take a look at this[^] article, it provides a nice introduction.


        My Blog[^]

        P 1 Reply Last reply
        0
        • E Ed Poore

          Take a look at this[^] article, it provides a nice introduction.


          My Blog[^]

          P Offline
          P Offline
          pokabot
          wrote on last edited by
          #4

          The above article would be great if in c#. Could anyone rewrite? ty

          E P 2 Replies Last reply
          0
          • P pokabot

            The above article would be great if in c#. Could anyone rewrite? ty

            E Offline
            E Offline
            Ed Poore
            wrote on last edited by
            #5

            There used to be a combo box which allowed you to select the language. To be honest it's not that difficult to translate from VB.NET to C# since the classes used are all the same.


            My Blog[^]

            1 Reply Last reply
            0
            • P pokabot

              The above article would be great if in c#. Could anyone rewrite? ty

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              Download the code, compile it and run it through the excellent .NET Reflector (from Lutz Roeder). Reflector allows you to change the language target, so you can see what it would be in C#.

              Deja View - the feeling that you've seen this post before.

              My blog | My articles

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

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