Get Plugin from custom form  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Get Plugin from custom form

Postby SBarnes » Fri Mar 11, 2022 1:32 pm

Is there a way to get the plugin object that a custom form is residing in?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Get Plugin from custom form

Postby Mike.Sheen » Fri Mar 11, 2022 1:48 pm

You can get the name of the plugin with Assembly.GetExecutingAssembly and then match the assembly name with the plugin name in Manager.PluginCollection - the item in Manager.PluginCollection is the plugin.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Get Plugin from custom form  Topic is solved

Postby SBarnes » Fri Mar 11, 2022 2:00 pm

Thanks, based on that suggestion this should do it as a function in the form

Code: Select all
      private JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin GetPlugin()
      {
         List<JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin> plugins = this.Manager.PluginCollection.Cast<JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin>().ToList();
         return plugins.FirstOrDefault( p => p.Name == System.Reflection.Assembly.GetExecutingAssembly().GetName().FullName );
         
      }
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Get Plugin from custom form

Postby Mike.Sheen » Thu Mar 07, 2024 3:53 pm

SBarnes wrote:Thanks, based on that suggestion this should do it as a function in the form

Code: Select all
      private JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin GetPlugin()
      {
         List<JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin> plugins = this.Manager.PluginCollection.Cast<JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin>().ToList();
         return plugins.FirstOrDefault( p => p.Name == System.Reflection.Assembly.GetExecutingAssembly().GetName().FullName );
         
      }


That doesn't work because you're comparing the Assembly FullName with the Plugin Name - the FullName includes the SNK and version - you just want Name.

Code: Select all
private JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin GetPlugin()
{
   List<JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin> plugins = this.Manager.PluginCollection.Cast<JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin>().ToList();
   return plugins.FirstOrDefault(p => p.Name == System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
}
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 19 guests

cron