How to get the robot name

Created at 18 Jul 2014, 20:54
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!
AY

aysos75

Joined 28.09.2013

How to get the robot name
18 Jul 2014, 20:54


how to get the name of a robot defines 

[Robot ("Name", TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] 
public class TrailCutII: Robot 
... 

from the base type Robot?

 


@aysos75
Replies

aysos75
19 Jul 2014, 20:50

RE:

Abdallah_Hacid said:

how to get the name of a robot defines 

[Robot ("Name", TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] 
public class TrailCutII: Robot 
... 

from the base type Robot?

 

If suffit de faire :

		/// <summary>
		/// Obtient le nom du robot
		/// </summary>
		/// <param name="robot">L'instance du robot actuel</param>
		/// <returns>Le nom du type dérivé de Robot et définissant une nouvelle instance de Robot</returns>
		public static string name(this Robot robot)
		{
			return robot.ToString();
		}

 


@aysos75

aysos75
19 Jul 2014, 20:52

RE: RE:

Abdallah_Hacid said:

Abdallah_Hacid said:

how to get the name of a robot defines 

[Robot ("Name", TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] 
public class TrailCutII: Robot 
... 

from the base type Robot?

 

If suffit de faire :

		/// 

/// Obtient le nom du robot ///

///L'instance du robot actuel /// Le nom du type dérivé de Robot et définissant une nouvelle instance de Robot public static string name(this Robot robot) { return robot.ToString(); }

 

Par contre comment obtenir le nom définit dans l'atribut

[Robot ("Name", TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] 
public class TrailCutII: Robot 
... 

 


@aysos75

Invalid
21 Jul 2014, 09:13

you can do smth like:

    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class TrailCutII : Robot
    {
        protected override void OnStart()
        {
            var name = this.GetName();
        }
    }

    public static class AlgoExtensions
    {
        public static string GetName(this Robot robot)
        {
            return robot.GetType().Name;
        }
    }

 


@Invalid