Exemplo n.º 1
0
 private HandlerProvider(MqlHandler mqlHandler, HandlerElement handlerElement, TradePlatform.MT4.Core.Utils.ExpertInfo expertInfo)
 {
     this._mqlHandler = mqlHandler;
     this._mqlHandler.CallMqlInternal = new Func<string, IEnumerable<string>, string>(this.OnCallMqlMethod);
     this.HandlerConfiguration = handlerElement;
     this.ExpertInfo = expertInfo;
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            TradePlatform platform = new TradePlatform();

            platform.InitMarketData();
            platform.CreateSession();
            string command = "";

            Console.WriteLine("Welcome to TradingPlatform");
            MessageUtil.ShowMenu();

            while (true)
            {
                command = Console.ReadLine();
                if (command != null && !command.ToLower().Equals("exit") && command.Trim().Length > 0)
                {
                    platform.HandleCommand(command);
                }
                else if (command != null && command.ToLower().Equals("exit"))
                {
                    break;
                }
            }
        }
Exemplo n.º 3
0
 internal static HandlerProvider GetOrCreate(TradePlatform.MT4.Core.Utils.ExpertInfo expertInfo, HostElement hostElement)
 {
     Assembly assembly;
     Type type;
     MqlHandler mqlHandler;
     HandlerProvider item;
     lock (HandlerProvider._storageLocker)
     {
         if (!HandlerProvider._storage.ContainsKey(expertInfo.Discriminator))
         {
             if (hostElement.Handlers.ContainsKey(expertInfo.HandlerName))
             {
                 HandlerElement handlerElement = hostElement.Handlers[expertInfo.HandlerName];
                 try
                 {
                     assembly = Assembly.LoadFile(string.Concat(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "\\", handlerElement.AssemblyName, ".dll"));
                 }
                 catch (Exception exception1)
                 {
                     Exception exception = exception1;
                     throw new HandlerLoadException(expertInfo, "Requested assembly not found", exception);
                 }
                 try
                 {
                     type = assembly.GetType(handlerElement.TypeName);
                 }
                 catch (Exception exception3)
                 {
                     Exception exception2 = exception3;
                     throw new HandlerLoadException(expertInfo, "Requested type not found in assembly.", exception2);
                 }
                 try
                 {
                     mqlHandler = (MqlHandler)Activator.CreateInstance(type);
                 }
                 catch (Exception exception5)
                 {
                     Exception exception4 = exception5;
                     throw new HandlerLoadException(expertInfo, "Can't create intance of expert.", exception4);
                 }
                 try
                 {
                     foreach (ParameterElement inputParameter in handlerElement.InputParameters)
                     {
                         PropertyInfo property = mqlHandler.GetType().GetProperty(inputParameter.PropertyName);
                         Type propertyType = property.PropertyType;
                         object obj = Convert.ChangeType(inputParameter.PropertyValue, propertyType);
                         property.SetValue(mqlHandler, obj);
                     }
                 }
                 catch (Exception exception7)
                 {
                     Exception exception6 = exception7;
                     throw new HandlerLoadException(expertInfo, "Can't set input parameters for expert", exception6);
                 }
                 HandlerProvider handlerProvider = new HandlerProvider(mqlHandler, handlerElement, expertInfo);
                 HandlerProvider._storage.TryAdd(expertInfo.Discriminator, handlerProvider);
                 item = handlerProvider;
             }
             else
             {
                 throw new HandlerLoadException(expertInfo, "Requested application not found in configuration", null);
             }
         }
         else
         {
             item = HandlerProvider._storage[expertInfo.Discriminator];
         }
     }
     return item;
 }
Exemplo n.º 4
0
 public ExpertInfo(string discriminator, string handlerName, TradePlatform.MT4.Core.Utils.MethodCallInfo methodCallInfo)
 {
     this.Discriminator = discriminator;
     this.HandlerName = handlerName;
     this.MethodCallInfo = methodCallInfo;
 }