Embedding resources in algos

Created at 10 Jun 2016, 21:41
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
ZE

zelenij.krokodil

Joined 05.06.2016

Embedding resources in algos
10 Jun 2016, 21:41


Looks like embedded resources are stripped from the algos during the build process?  I would like to have a config file embedded, rather than try to refer to it on the disk (which is my current solution).  Is this possible?


@zelenij.krokodil
Replies

Spotware
14 Jun 2016, 17:58

Dear Trader,

Could you please provide us with more details regarding your question?

What kind of configuration file do you want to embed in our code?

You can contact us at feedback@spotware.com, if you like.


@Spotware

zelenij.krokodil
14 Jun 2016, 18:26

I have a text file in my algo project in Visual Studio.  I set the build action to Embedded Resource.  In a regular .NET assembly I could read it with code similar to this:

 

var assembly = Assembly.GetExecutingAssembly();
var resourceName = "MyCompany.MyProduct.MyFile.txt";

using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
{
    string result = reader.ReadToEnd();
}

But the algo building process must be stripping resources, I guess, because mine isn't there.


@zelenij.krokodil

Spotware
15 Jun 2016, 14:37

Dear Trader,

We don't support resources.

However, we recommend you to create a class with constants and use it as a "resource".


@Spotware