11

I want to be able to write PowerShell CmdLets using IronPython, and furthermore I need one CmdLet to look at the environment and add CmdLets to the PowerShell based on the contents. For example, reading a directory, and adding a CmdLet Remove- for every filename it sees there.

JPBlanc
  • 70,406
  • 17
  • 130
  • 175
moshez
  • 36,202
  • 1
  • 22
  • 14
  • Can you be more clear on what you want to add ? Can't you do it in C#. – JPBlanc May 27 '11 at 16:34
  • 1
    I'm sure I *can* do it in C#. I don't want to, though. I want to do it in IronPython... – moshez Jun 02 '11 at 18:41
  • 1
    You shouldn't define cmdlets dynamically like that. Especially for things like individual files. – JasonMArcher Jun 18 '11 at 17:39
  • 3
    Yes, yes I should. I'm obviously not going to actually write a separate Remove- command for a bunch of files -- that was just an example of the dynamicity I need. – moshez Jun 22 '11 at 18:11
  • When you already know how to do it in C#, it should be no problem to transform this into IronPython, as you have access to the same framework. Do I miss something here? – Niklas B. Sep 01 '11 at 23:21
  • The problem here is that an IronPython class is not a CLR class or compatible with a CLR class. A CLR class is static and an IronPython class is dynamic and the DLR, as far as I know, doesn't for example provide IronPython classes to have .net CLR attributes, which you need for CMDLET development. – CosmosKey Sep 04 '11 at 20:32

1 Answers1

3

As far as I know it can't be done!

The problem here is that an IronPython class is not a CLR class or compatible with a CLR class. A CLR class is static and an IronPython class is dynamic and the DLR, as far as I know, doesn't for example provide IronPython classes to have .net CLR attributes, which you need for CMDLET development.

CosmosKey
  • 1,287
  • 11
  • 13
  • actually the way to do it is buried inside the latest update: https://ironpython.svn.codeplex.com/svn/IronPython_Main/Languages/IronPython/Samples/ClrType/clrtype.py – Kyle Roux Jul 14 '17 at 07:48