Closed pjmagee closed 6 years ago
For metadata and part creation policy it seems simple, most likely a decorator like "exports" that populates a field on the class, and then on IronPythonComposablePart we'd populate the dictionary and policy. Or something of the sort.
For custom attributes it might be a bit trickier, as I'm not sure how to map c#'s attributes from python. What would be the use case you had in mind?
If you can create a pull request with failing tests I think I might be able to quickly look into it. Otherwise I'd have to look into how metadata is used from a consumer point of view. Look at https://github.com/JogoShugh/IronPythonMef/blob/master/src/IronPythonMef.Tests/MefImportAndExportTests.cs to see an example.
Thanks for replying so quickly. Sorry for my poor explanation, i was thinking custom attributes that could be created in C#, for example ones that may extend the ExportMetadataAttribute so that not only those by MEF have to be used in a Python script. Custom attributes are not important though. My main concern was that certain exports should be shared or non-shared. For example, I have a bot which I would like to use MEF with Python so I could create scripts to handle games in a per server connection so I would need a way to ensure all connections are recomposed with modules configured with the correct creation policy.
In the long run it would be great if RubyMef and PythonMef were supported MEF extensions. This is quite beyond my own abilities at the moment though :)
For shared/non-shared exports, I think I've got a solution barely working.
But I've just realized that I've made a mistake in implementing this, as I used the ComposablePart as the root component, and I should have used a ComposablePartDefinition created from a Catalog.
So, in short, I think we'll be able to quickly have non-shared exports, but non-shared imports are a bit further away, since I think it would imply creating catalogs for scripts, instead of directly creating parts.
That's great!
Exporting by using custom attributes is actually something I desperately need to... I found on the net some info on how to add attributes to ironpython objects but I do not seem to be able to do that.
Do you think we can add our exportmethods by modifying the lib.py provided?
@mattiascibien what would your custom attribute do? Is it a custom export?
If I had a failing test it would be awesome, but just a description of what you're trying to achieve might help me figure out exactly how to enable it.
@brunomlopes In my program I am using a cutom export attribute for exporting a paricoular type with associated metadata https://github.com/SuperbEdit/SuperbEdit/blob/develop/SuperbEdit.Base/ActionItem.cs#L125 so when I want to export that type i just do:
[ExportSomething(MetadataParm1="", MetadataParam2=""]
I can use @export but is it possible to add attributes for @exportmetadata and @partcreationpolicy of python parts, further more, what about custom attributes?
cheers,
merry xmas!