The BuildingBlock API documentation for Initialize() says:
I tried, but can't get a library name different form the assembly name.
May I have a working code example that sets the LibraryName for a BuildingBlock?
QUOTE:
Here you can change the LibraryName, which determines the name of the node that your Building Block appears under in the WL8 Building Blocks list.
I tried, but can't get a library name different form the assembly name.
May I have a working code example that sets the LibraryName for a BuildingBlock?
Rename
I've never had to assign LibraryName. Just use the Name field.
Edit: In my experience, the Assembly name is used as the LibraryName (without assigning it).
CODE:
public class MyBlock: ConditionBuildingBlock { public override string Name => "My Block's Name"; :
Edit: In my experience, the Assembly name is used as the LibraryName (without assigning it).
Did you assign a value to the LibraryName property?
Yes, I tried:
and
None of these works.
CODE:
public override void Initialize() { LibraryName = "finantic.MyFancyBlocks"; }
and
CODE:
public ConstructorOfMyClass() { LibraryName = "finantic.VeryFancyBlocks"; }
None of these works.
Here is what I found works. The Name property is the name of the building block. The node in the tree is the name of the assembly. So, edit the class library properties and change the Assembly Name property to what you want, with a couple of caveats:
- If the Assembly Name contains a space then the tree node will appear with quotes around the name.
- If the Assembly Name contains one dot, then the node will have the part of the name after the dot.
- If the Assembly Name contains more than one dot, then the node will be whatever comes after the first dot.
Note that if you rename the DLL, it will still use the Assembly Name info in the DLL.
Hence, here is a simple do-nothing exit building block:
Here is the setting for the class library (I use JetBrains Rider IDE, but should be similar for Visual Studio):
And...
- If the Assembly Name contains a space then the tree node will appear with quotes around the name.
- If the Assembly Name contains one dot, then the node will have the part of the name after the dot.
- If the Assembly Name contains more than one dot, then the node will be whatever comes after the first dot.
Note that if you rename the DLL, it will still use the Assembly Name info in the DLL.
Hence, here is a simple do-nothing exit building block:
CODE:
using WealthLab.Backtest; namespace MyBuildingBlock; public class MyEntryExitBb : EntryExitBuildingBlock { public override string Name => "Paul's Exit Building Block"; public override void Initialize() { base.Initialize(); } }
Here is the setting for the class library (I use JetBrains Rider IDE, but should be similar for Visual Studio):
And...
Hi paul, many thanks for this elaborate research.
This is (of course) a solution.
But still the advertised (documented) way does not work :(
This is (of course) a solution.
But still the advertised (documented) way does not work :(
We will work on getting this working as advertised!!
We've got it working as expected for the next release.
Hmmm.... this took 25 minutes....
... you should get some blue band ... ;)
... you should get some blue band ... ;)
It was a trivial fix 🤷🏼♂️ Wish they were all that easy!
Your Response
Post
Edit Post
Login is required