public StringSearcherControl(IConnector connector)
 {
     InitializeComponent();
     this.connector = connector;
     comboBox1.SelectedIndex = 2;
     comboBox2.SelectedIndex = 0;
 }
		public void OnDeserialization (Object sender) {
			ConnectFigure (_startConnector);
			StartConnector = _startConnector;
			
			ConnectFigure (_endConnector);
			EndConnector = _endConnector;
		}
Exemplo n.º 3
0
		/// <summary>
		/// Создать <see cref="MatLabConnector"/>.
		/// </summary>
		/// <param name="realConnector">Подключение, через которое будут отправляться заявки и получатся маркет-данные.</param>
		/// <param name="ownTrader">Контролировать время жизни подключения <paramref name="realConnector"/>.</param>
		public MatLabConnector(IConnector realConnector, bool ownTrader)
		{
			if (realConnector == null)
				throw new ArgumentNullException("realConnector");

			RealConnector = realConnector;

			RealConnector.Connected += RealTraderOnConnected;
			RealConnector.ConnectionError += RealTraderOnConnectionError;
			RealConnector.Disconnected += RealTraderOnDisconnected;
			RealConnector.Error += RealTraderOnError;
			RealConnector.MarketTimeChanged += RealTraderOnMarketTimeChanged;
			RealConnector.NewSecurities += RealTraderOnNewSecurities;
			RealConnector.SecuritiesChanged += RealTraderOnSecuritiesChanged;
			RealConnector.NewPortfolios += RealTraderOnNewPortfolios;
			RealConnector.PortfoliosChanged += RealTraderOnPortfoliosChanged;
			RealConnector.NewPositions += RealTraderOnNewPositions;
			RealConnector.PositionsChanged += RealTraderOnPositionsChanged;
			RealConnector.NewTrades += RealTraderOnNewTrades;
			RealConnector.NewMyTrades += RealTraderOnNewMyTrades;
			RealConnector.NewMarketDepths += RealTraderOnNewMarketDepths;
			RealConnector.MarketDepthsChanged += RealTraderOnMarketDepthsChanged;
			RealConnector.NewOrders += RealTraderOnNewOrders;
			RealConnector.OrdersChanged += RealTraderOnOrdersChanged;
			RealConnector.OrdersRegisterFailed += RealTraderOnOrdersRegisterFailed;
			RealConnector.OrdersCancelFailed += RealTraderOnOrdersCancelFailed;
			RealConnector.NewStopOrders += RealTraderOnNewStopOrders;
			RealConnector.StopOrdersChanged += RealTraderOnStopOrdersChanged;
			RealConnector.StopOrdersRegisterFailed += RealTraderOnStopOrdersRegisterFailed;
			RealConnector.StopOrdersCancelFailed += RealTraderOnStopOrdersCancelFailed;
			RealConnector.NewOrderLogItems += RealTraderOnNewOrderLogItems;

			_ownTrader = ownTrader;
		}
Exemplo n.º 4
0
 protected ConnectionBase(Point from, Point to)
     : base()
 {
     this.mFrom = new Connector(from);
     this.mFrom.Parent = this;
     this.mTo = new Connector(to);
     this.mTo.Parent = this;
 }
Exemplo n.º 5
0
        internal MessageClient(IConnector connector)
        {
            Contract.Requires(connector != null);

            this.Connector = connector;
            this.Connector.Connected += (sender, e) => OnConnected();
            this.Connector.ConnectFailed += (sender, e) => OnConnectFailed(e.Exception);
            this.Connector.Disconnected += (sender, e) => OnDisconnected();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:ConnectionBase"/> class.
 /// </summary>
 /// <param name="from">From.</param>
 /// <param name="to">To.</param>
 protected ConnectionBase(Point from, Point to)
     : base()
 {
     this.mFrom = new Connector(from);
     this.mFrom.Parent = this;
     this.mTo = new Connector(to);
     this.mTo.Parent = this;
     PenStyle = ArtPallet.GetDefaultPenStyle();
 }
		public virtual void ConnectStart (IConnector start)	{
			if (StartConnector == start) {
				return;
			}

			DisconnectStart ();
			StartConnector = start;
			ConnectFigure (StartConnector);
			OnConnectionChanged();
		}
Exemplo n.º 8
0
        public LivenessMonitor(IConnector connector, int livenessTimeout = 60000, int receiveTimeout = 10000)
        {
            IsUp = true;
            this.connector = connector;
            connector.MessageReceived += connector_MessageReceived;
            ReceiveTimeout = receiveTimeout;

            timer = new System.Timers.Timer(livenessTimeout);
            timer.Elapsed += timer_Elapsed;
        }
Exemplo n.º 9
0
        public static void ProcessAttachEndPoint(IBlockWeb containerWeb, IConnector connector, XmlElement endpointElement, string blockId)
        {
            string endpointKey = null;

            if (endpointElement.Name == "valueEndPoint")
            {
                if (!TemplateProcessor.ProcessTemplateFile(endpointElement, containerWeb, blockId, connector))
                {
                    object value = ObjectReader.ReadObject(endpointElement);
                    endpointKey = connector.AttachEndPoint(value);
                }
            }
            else if (endpointElement.Name == "serviceEndPoint")
            {
                if (!TemplateProcessor.ProcessTemplateFile(endpointElement, containerWeb, blockId, connector))
                {
                    string endpointBlockId = endpointElement.GetAttribute("blockId");
                    string endpointService = endpointElement.GetAttribute("service");

                    if (!endpointElement.HasAttribute("blockId")) endpointBlockId = blockId;

                    endpointKey = connector.AttachEndPoint(endpointBlockId, endpointService);
                }
            }
            else if (endpointElement.Name == "connectorEndPoint")
            {
                if (!TemplateProcessor.ProcessTemplateFile(endpointElement, containerWeb, blockId, connector))
                {
                    string endpointBlockId = endpointElement.GetAttribute("blockId");
                    string endPointConnectorKey = endpointElement.GetAttribute("connectorKey");

                    if (!endpointElement.HasAttribute("blockId")) endpointBlockId = blockId;

                    endpointKey = connector.AttachConnectorEndPoint(endpointBlockId, endPointConnectorKey);
                }
            }
            else
            {
                throw new InvalidOperationException();
            }

            //now process fixed args
            XmlElement fixedArgsElement = endpointElement.SelectSingleNode("fixedArgs") as XmlElement;

            if (fixedArgsElement != null && endpointKey != null)
            {
                List<Connector.EndPoint> fixedArgs = EndPointExtractor.ExtractArguments(fixedArgsElement, containerWeb);

                foreach (Connector.EndPoint endPoint in fixedArgs)
                {
                    connector.AddFixedArg(endpointKey, endPoint);
                }
            }
        }
Exemplo n.º 10
0
		/// <summary>
		/// Создать <see cref="MarketTimer"/>.
		/// </summary>
		/// <param name="connector">Подключение к торговой системе, из которого будет использоваться событие <see cref="IConnector.MarketTimeChanged"/>.</param>
		/// <param name="activated">Обработчик таймера.</param>
		public MarketTimer(IConnector connector, Action activated)
		{
			if (connector == null)
				throw new ArgumentNullException("connector");

			if (activated == null)
				throw new ArgumentNullException("activated");

			_connector = connector;
			_activated = activated;
		}
Exemplo n.º 11
0
        /// <summary>
        /// Gets the source field for connection.
        /// </summary>
        /// <param name="connector">The connector.</param>
        /// <returns>SourceField.</returns>
        public SourceField GetSourceFieldForConnection(IConnector connector)
        {
            var fields = new List<SourceField>();
            CollectAllFields(fields, null);

            var field = fields.FirstOrDefault(con => con.ConnectorOut.Id == connector.Id);
            if (field != null)
            {
                field.DataType = connector.DataType;
            }
            return field;
        }
Exemplo n.º 12
0
        public RougeSpyGameScene(SceneHandler handler, string name, IConnector connector, GraphicsDeviceManager graphicsDeviceManager)
            : base(handler, name, connector, graphicsDeviceManager)
        {
            //movement system
            MainSystem.UpdateComplexSystem.AddSubSystem(new InputUpdateSystem(MainSystem));
            MainSystem.UpdateComplexSystem.AddSubSystem(new CalculateMovementUpdateSystem(MainSystem));
            MainSystem.UpdateComplexSystem.AddSubSystem(new HitBoxCollisionUpdateSystem(MainSystem));
            MainSystem.UpdateComplexSystem.AddSubSystem(new ApplyMovementUpdateSystem(MainSystem));
            MainSystem.UpdateComplexSystem.AddSubSystem(new HitBoxUpdateSystem(MainSystem));

            //render system
            MainSystem.RenderComplexSystem.AddSubSystem(new Texture2DRenderSystem(MainSystem));
            MainSystem.RenderComplexSystem.AddSubSystem(new HitBoxRenderSystem(MainSystem, 2));

            //Player
            PlayerID = MainSystem.CreateEntityID();
            MainSystem.GetUpdateSystem<InputUpdateSystem>().CreateInputNode(PlayerID, new GamePadInput());
            MainSystem.GetUpdateSystem<CalculateMovementUpdateSystem>().CreateMovementNode(PlayerID);
            MainSystem.GetUpdateSystem<ApplyMovementUpdateSystem>().CreateMovementNode(PlayerID);
            MainSystem.GetComponent<Motion2DComponent>(PlayerID).Acceleration = 0.2f;
            MainSystem.GetComponent<Motion2DComponent>(PlayerID).Decceleration = 0.3f;
            MainSystem.GetComponent<Motion2DComponent>(PlayerID).MaxSpeed = 10.0f;
            Texture2D texture = AssetLoader.Instance.Load<Texture2D>("Player_Alpha_64_43");
            MainSystem.GetRenderSystem<Texture2DRenderSystem>().CreateTexture2DRenderNode(PlayerID, texture);
            MainSystem.GetComponent<Position2DComponent>(PlayerID).Position = new Vector2(200);
            MainSystem.GetComponent<Position2DComponent>(PlayerID).Origin = new Vector2(texture.Width / 2, texture.Height / 2);

            List<Vector2> points = new List<Vector2>();
            points.Add(Vector2.Zero);
            points.Add(new Vector2(texture.Width - 24, 0));
            points.Add(new Vector2(texture.Width - 24, texture.Height));
            points.Add(new Vector2(0, texture.Height));
            MainSystem.GetUpdateSystem<HitBoxUpdateSystem>().CreateHitBoxNode(PlayerID, points);
            MainSystem.GetComponent<HitBox2DComponent>(PlayerID).Offset = new Vector2(12, 0);
            MainSystem.GetUpdateSystem<HitBoxCollisionUpdateSystem>().CreateHitBoxCollisionUpadateNode(PlayerID, points, new PositionCorrectionHitBoxIntersectionReaction(MainSystem, PlayerID));
            MainSystem.GetRenderSystem<HitBoxRenderSystem>().CreateHitBoxRenderNode(PlayerID, points);

            string[][] blueprint = new string[3][];
            blueprint[0] = new string[] { "w", "w", "w" };
            blueprint[1] = new string[] { "w", " ", "w" };
            blueprint[2] = new string[] { "w", "w", "w" };

            List<Vector2> hitBoxOutline = new List<Vector2>();
            hitBoxOutline.Add(new Vector2(0, 0));
            hitBoxOutline.Add(new Vector2(64, 0));
            hitBoxOutline.Add(new Vector2(64, 64));
            hitBoxOutline.Add(new Vector2(0, 64));

            List<TileBluePrint> tileBluePrints = new List<TileBluePrint>();
            tileBluePrints.Add(new TileBluePrint("w", AssetLoader.Instance.Load<Texture2D>("WoodenTileA"), hitBoxOutline));
            TileMapBluePrint tileMapBluePrint = new TileMapBluePrint(blueprint, tileBluePrints, new Vector2(64,64));
            TileMapLoader.Load(tileMapBluePrint, MainSystem);            
        }
Exemplo n.º 13
0
        private void _ConnectAsyncCallback(IConnector connector, object callbackState)
        {
            if (!(callbackState is object[])) throw new ArgumentException();

            object[] states = (object[])callbackState;
            ConnectAsyncCallback callback = states[0] as ConnectAsyncCallback;
            object state = states[2];

            Daemon = new Daemon(_factory);
            Core = new Core(_factory);
            callback(connector, state);
        }
Exemplo n.º 14
0
 public void AttachConnector(IConnector connector)
 {
     if(connector == null)
         return;
     //only attach'm if not already present and not the parent
     if(!attachedConnectors.Contains(connector) && connector!=attachedTo)
     {
         connector.DetachFromParent();
         attachedConnectors.Add(connector);
         //make sure the attached connector is centered at this connector
         connector.Point = this.point;
         connector.AttachedTo = this;
     }
 }
Exemplo n.º 15
0
        public Scene(SceneHandler handler, string name, IConnector connector, GraphicsDeviceManager graphicsDeviceManager, List<Scene> children)
        {
            Handler = handler;
            Name = name;
            Connector = connector;

            GraphicsDeviceManager = graphicsDeviceManager;

            if (connector != null)
            {
                Connector.Next = this;
            }

            Children = children;
        }
Exemplo n.º 16
0
    /// <summary>
    /// Handles the mouse down event
    /// </summary>
    /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
    public bool MouseDown(MouseEventArgs e) {
      if (e == null)
        throw new ArgumentNullException("The argument object is 'null'");
      if (e.Button == MouseButtons.Left && Enabled && !IsSuspended) {
        fetchedConnector = this.Controller.Model.Selection.FindShapeConnector(e.Location);
        if (fetchedConnector != null) {

          initialPoint = e.Location;
          lastPoint = initialPoint;
          motionStarted = true;
          return true;
        }
      }
      return false;
    }
Exemplo n.º 17
0
        public FrmDatabaseImportProcess(List<DataImportTable> tableList, DataBase newBase, Connector.SgbdType sgbdType, IConnector conn)
        {
            InitializeComponent();
            Cursor.Current = Cursors.WaitCursor;
            _sgbdType = sgbdType;
            _db = newBase;
            _tableList = tableList;
            _conn = conn;
            foreach (DataImportTable table in tableList)
                table.Count = conn.GetCount(table.Name);
            _columnsCount = tableList.Sum(t => t.Columns.Count);

            launch();
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 18
0
        public MenuBuilder()
        {
            Encoding encoding = null;
            if (ConfigurationManager.AppSettings.AllKeys.Contains(CodepageKeyName))
            {
                var codepageValue = ConfigurationManager.AppSettings[CodepageKeyName];
                int codepage;
                int.TryParse(codepageValue, out codepage);
                if (codepage > 0)
                {
                    encoding = Encoding.GetEncoding(codepage);
                }
            }

            _connector = new Connector {OutputEncoding = encoding};
        }
Exemplo n.º 19
0
        public DDTConnection(IConnector mFrom, IConnector mTo, IModel model, ConnectionType type)
            : base(model)
        {
            this.From = new Connector(mFrom.Point, model);
                this.From.Name = "From";
                this.From.Parent = this;

                From.AttachTo(mFrom);

                this.To = new Connector(mTo.Point, model); ;
                this.To.Name = "To";
                this.To.Parent = this;

                To.AttachTo(mTo);

            this.connectionType = type;
        }
Exemplo n.º 20
0
 public Server()
 {
     connector = new Connector();
     connections = new List<IConnection>();
     commandExecutor = new CommandExecutor(
         new PingCommand(),
         new EchoCommand(),
         new ClientCommand(),
         new InfoCommand(),
         new ConfigCommand(),
         new ExistsCommand(),
         new DelCommand(),
         new GetCommand(),
         new SetCommand()
         );
     hash = new Hash();
 }
Exemplo n.º 21
0
 public static int getConnectorIndex(IConnector cnct)
 {
     if(cnct.Equals(((IDDTObject)cnct.Parent).connectorA))
        {
       return 1;
        }
        else if(cnct.Equals(((IDDTObject)cnct.Parent).connectorB))
        {
       return 2;
        }
        else if(cnct.Equals(((IDDTObject)cnct.Parent).connectorC))
        {
       return 3;
        }
        else if(cnct.Equals(((IDDTObject)cnct.Parent).connectorD))
        {
        return 4;
        }
        else
     return 0;
 }
Exemplo n.º 22
0
        public void Attach(IConnector connector, IBlockWeb context)
        {
            string epKey = null;

            if (value != null)
            {
                epKey = connector.AttachEndPoint(value);
            }
            else if (serviceName != null)
            {
                epKey = connector.AttachEndPoint(blockId, serviceName);
            }
            else
            {
                epKey = connector.AttachConnectorEndPoint(blockId, connectorKey);
            }

            foreach (EndPointDescriptor ep in FixedArgs)
            {
                connector.AddFixedArg(epKey, ep.GetEndPoint(context));
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Creates and configures the provider to use to connect to the data feed.
        /// </summary>
        /// <param name="settings"></param>
        /// <returns></returns>
        private IConnector DetermineConnector(Receiver settings)
        {
            IConnector result = Listener.Connector;

            switch (settings.ConnectionType)
            {
            case ConnectionType.COM:
                var existingSerialProvider = result as ISerialConnector;
                if (existingSerialProvider == null || existingSerialProvider.BaudRate != settings.BaudRate || existingSerialProvider.ComPort != settings.ComPort ||
                    existingSerialProvider.DataBits != settings.DataBits || existingSerialProvider.Handshake != settings.Handshake ||
                    existingSerialProvider.Parity != settings.Parity || existingSerialProvider.ShutdownText != settings.ShutdownText ||
                    existingSerialProvider.StartupText != settings.StartupText || existingSerialProvider.StopBits != settings.StopBits)
                {
                    var serialConnector = Factory.Resolve <ISerialConnector>();
                    serialConnector.Name         = settings.Name;
                    serialConnector.BaudRate     = settings.BaudRate;
                    serialConnector.ComPort      = settings.ComPort;
                    serialConnector.DataBits     = settings.DataBits;
                    serialConnector.Handshake    = settings.Handshake;
                    serialConnector.Parity       = settings.Parity;
                    serialConnector.ShutdownText = settings.ShutdownText;
                    serialConnector.StartupText  = settings.StartupText;
                    serialConnector.StopBits     = settings.StopBits;
                    result = serialConnector;
                }
                break;

            case ConnectionType.TCP:
                var existingConnector = result as INetworkConnector;
                if (existingConnector == null ||
                    existingConnector.Port != settings.Port ||
                    existingConnector.UseKeepAlive != settings.UseKeepAlive ||
                    existingConnector.IdleTimeout != settings.IdleTimeoutMilliseconds ||
                    existingConnector.IsPassive != settings.IsPassive ||
                    (!settings.IsPassive && existingConnector.Address != settings.Address) ||
                    (settings.IsPassive && !Object.Equals(existingConnector.Access, settings.Access)))
                {
                    var ipConnector = Factory.Resolve <INetworkConnector>();
                    ipConnector.Name         = settings.Name;
                    ipConnector.IsPassive    = settings.IsPassive;
                    ipConnector.Port         = settings.Port;
                    ipConnector.UseKeepAlive = settings.UseKeepAlive;
                    ipConnector.IdleTimeout  = settings.IdleTimeoutMilliseconds;

                    if (!settings.IsPassive)
                    {
                        ipConnector.Address = settings.Address;
                    }
                    else
                    {
                        ipConnector.Access = settings.Access;
                    }

                    result = ipConnector;
                }
                break;

            case ConnectionType.HTTP:
                var existingHttpConnector = result as IHttpConnector;
                if (existingHttpConnector == null ||
                    existingHttpConnector.WebAddress != settings.WebAddress ||
                    existingHttpConnector.FetchIntervalMilliseconds != settings.FetchIntervalMilliseconds
                    )
                {
                    var httpConnector = Factory.Resolve <IHttpConnector>();
                    httpConnector.Name       = settings.Name;
                    httpConnector.WebAddress = settings.WebAddress;
                    httpConnector.FetchIntervalMilliseconds = settings.FetchIntervalMilliseconds;
                    result = httpConnector;
                }
                break;

            default:
                throw new NotImplementedException();
            }

            return(result);
        }
Exemplo n.º 24
0
 public RulerPane(IConnector Connector) : base(Connector)
 {
     InitializeComponent();
 }
Exemplo n.º 25
0
        void Run(Address me, Address you, AmqpTcpEndpoint server, int sleep)
        {
            ConnectionFactory connectionFactory = new ConnectionFactory();

            connectionFactory.Endpoint = server;
            using (IConnector conn =
                       Factory.CreateConnector(new ConnectionBuilder(connectionFactory))) {
                IMessaging m = Factory.CreateMessaging();
                m.Connector    = conn;
                m.Identity     = me;
                m.Sent        += Sent;
                m.SetupSender += delegate(IModel channel) {
                    //We declare the recipient queue here to avoid
                    //sending messages into the ether. That's an ok
                    //thing to do for testing
                    channel.QueueDeclare(you, true, false, false, null);
                };
                m.SetupReceiver += delegate(IModel channel) {
                    channel.QueueDeclare(me, true, false, false, null);
                };
                m.Init();
                byte[] body = new byte[0];
                for (int i = 0;; i++)
                {
                    //send
                    IMessage msg = m.CreateMessage();
                    msg.Body = body;
                    msg.To   = you;
                    msg.Properties.SetPersistent(true);
                    m.Send(msg);
                    pending.Add(msg.MessageId, true);
                    //handle inbound
                    while (true)
                    {
                        IReceivedMessage r = m.ReceiveNoWait();
                        if (r == null)
                        {
                            break;
                        }
                        if (r.CorrelationId == null)
                        {
                            recv++;
                            DisplayStats();
                            m.Send(m.CreateReply(r));
                        }
                        else
                        {
                            if (pending.ContainsKey(r.CorrelationId))
                            {
                                pending.Remove(r.CorrelationId);
                                pend--;
                            }
                            else
                            {
                                disc++;
                            }
                            DisplayStats();
                        }
                        m.Ack(r);
                    }
                    //Slow down to prevent pending from growing w/o bounds
                    System.Threading.Thread.Sleep(sleep + pend);
                }
            }
        }
Exemplo n.º 26
0
 public GradingEndpoint(IConnector connector) : base(connector)
 {
 }
Exemplo n.º 27
0
        private void ConnectClick(object sender, RoutedEventArgs e)
        {
            if (Connector != null && !(Connector is FakeConnector))
            {
                return;
            }

            PosChart.Positions.Clear();
            PosChart.AssetPosition = null;
            PosChart.Refresh(1, 1, default(DateTimeOffset), default(DateTimeOffset));

            // create connection
            Connector = new QuikTrader();

            //_trader = new PlazaTrader { IsCGate = true };
            //_trader.Tables.Add(_trader.TableRegistry.Volatility);

            Portfolio.Portfolios = new PortfolioDataSource(Connector);

            PosChart.MarketDataProvider = Connector;
            PosChart.SecurityProvider   = Connector;

            // fill underlying asset's list
            Connector.NewSecurities += securities =>
                                       _assets.AddRange(securities.Where(s => s.Type == SecurityTypes.Future));

            Connector.SecuritiesChanged += securities =>
            {
                if ((PosChart.AssetPosition != null && securities.Contains(PosChart.AssetPosition.Security)) || PosChart.Positions.Cache.Select(p => p.Security).Intersect(securities).Any())
                {
                    _isDirty = true;
                }
            };

            // subscribing on tick prices and updating asset price
            Connector.NewTrades += trades =>
            {
                var assetPos = PosChart.AssetPosition;
                if (assetPos != null && trades.Any(t => t.Security == assetPos.Security))
                {
                    _isDirty = true;
                }
            };

            Connector.NewPositions += positions => this.GuiAsync(() =>
            {
                var asset = SelectedAsset;

                if (asset == null)
                {
                    return;
                }

                var assetPos = positions.FirstOrDefault(p => p.Security == asset);
                var newPos   = positions.Where(p => p.Security.UnderlyingSecurityId == asset.Id).ToArray();

                if (assetPos == null && newPos.Length == 0)
                {
                    return;
                }

                if (assetPos != null)
                {
                    PosChart.AssetPosition = assetPos;
                }

                if (newPos.Length > 0)
                {
                    PosChart.Positions.AddRange(newPos);
                }

                RefreshChart();
            });

            Connector.PositionsChanged += positions => this.GuiAsync(() =>
            {
                if ((PosChart.AssetPosition != null && positions.Contains(PosChart.AssetPosition)) || positions.Intersect(PosChart.Positions.Cache).Any())
                {
                    RefreshChart();
                }
            });

            Connector.Connect();
        }
Exemplo n.º 28
0
 internal ConnectorInfo(IConnector c, Endpoint e)
 {
     Connector = c;
     Endpoint  = e;
 }
Exemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MatLabConnector"/>.
 /// </summary>
 /// <param name="realConnector">The connection for market-data and transactions.</param>
 public MatLabConnector(IConnector realConnector)
     : this(realConnector, true)
 {
 }
Exemplo n.º 30
0
 public static void ProcessNodeChildren(XmlElement element, IBlockWeb blockWeb, string blockId, IConnector connector)
 {
     foreach (XmlNode actionNode in element.ChildNodes)
     {
         if (actionNode is XmlElement)
         {
             NodeProcessor.ProcessNode(actionNode as XmlElement, blockWeb, blockId, connector);
         }
     }
 }
Exemplo n.º 31
0
        private static IEnumerable <MailItem> CreateMailItems(ILogger logger, MimeMessage message, IConnector connector, IMailFolder folder, UniqueId uniqueId)
        {
            string messageEml = null;

            try
            {
                var stream = new MemoryStream();
                message.WriteTo(stream);
                stream.Position = 0;
                //var reader = new StreamReader(stream,Encoding.UTF8, true);
                var reader = new StreamReader(stream);
                messageEml = reader.ReadToEnd();
            }
            catch (Exception e)
            {
                logger.LogError(e, "Serialization failed");
            }

            DateTimeOffset date = DateTimeOffset.MinValue;

            try
            {
                date = message.Date;
            }
            catch
            {
            }

            foreach (var address in message.From)
            {
                if (address is MailboxAddress mailboxAddress)
                {
                    yield return(MailItem.CreateMailItem(mailboxAddress.Address, mailboxAddress.Name,
                                                         connector.ServerKey, folder.FullName, uniqueId.Id, messageEml, date));
                }
            }
        }
Exemplo n.º 32
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        public void MouseUp(MouseEventArgs e)
        {
            if (IsActive)
            {
                // First, make sure the initial point is far enough away from
                // the final point to make a connection.
                int maxX = Math.Abs(Math.Max(initialPoint.X, e.Location.X));
                int maxY = Math.Abs(Math.Max(initialPoint.Y, e.Location.Y));

                if (!(maxX > ConnectionBase.MinLength) ||
                    !(maxY > ConnectionBase.MinLength))
                {
                    return;
                }

                //whatever comes hereafter, a compund command is the most economic approach
                CompoundCommand package = new CompoundCommand(this.Controller);

                //let's see if the connection endpoints hit other connectors
                //note that the following can be done because the actual connection has not been created yet
                //otherwise the search would find the endpoints of the newly created connection, which
                //would create a loop and a stack overflow!
                IConnector startConnector = this.Controller.Model.Selection.FindConnectorAt(initialPoint);
                IConnector endConnector   = this.Controller.Model.Selection.FindConnectorAt(e.Location);

                #region Create the new connection
                Connection           cn     = new Connection(this.initialPoint, e.Location, this.Controller.Model);
                AddConnectionCommand newcon = new AddConnectionCommand(this.Controller, cn);

                #endregion

                #region Initial attachment?
                if (startConnector != null)
                {
                    BindConnectorsCommand bindStart = new BindConnectorsCommand(this.Controller, startConnector, cn.From);
                    package.Commands.Add(bindStart);
                }
                #endregion

                #region Final attachment?
                if (endConnector != null)
                {
                    BindConnectorsCommand bindEnd = new BindConnectorsCommand(this.Controller, endConnector, cn.To);
                    package.Commands.Add(bindEnd);
                }
                #endregion
                package.Text = "New connection";
                package.Commands.Add(newcon);
                this.Controller.UndoManager.AddUndoCommand(package);

                //do it all
                package.Redo();

                //reset highlight of the found connector
                if (foundConnector != null)
                {
                    foundConnector.Hovered = false;
                }
                //drop the painted ghost
                Controller.View.ResetGhost();
                this.doDraw = false;
            }
        }
Exemplo n.º 33
0
        public Orchestrator(ILogger <Orchestrator> logger,
                            StateMachine stateMachine, IThreadLogic threadLogic, IRecorderLogic recorderLogic, IReplayLogic replayLogic, IConnector connector, MainViewModel viewModel)
        {
            logger.LogDebug("Creating instance of {class}", nameof(Orchestrator));
            StateMachine  = stateMachine;
            ThreadLogic   = threadLogic;
            RecorderLogic = recorderLogic;
            ReplayLogic   = replayLogic;
            ViewModel     = viewModel;

            this.logger    = logger;
            this.connector = connector;
            RegisterEvents(connector);
        }
Exemplo n.º 34
0
 public TraceConnector(IConnector connector)
 {
     _connector = connector ?? throw new ArgumentNullException(nameof(connector));
 }
Exemplo n.º 35
0
 public ConditionalSubChainConnector(Predicate <TInput> predicate, Action <IConnectorLinker <TInput> > buildChain,
                                     ConnectorContext context) : base("Conditional", context)
 {
     _predicate            = predicate;
     _conditionalConnector = ConnectorLinker <TInput> .CreateAndBuild(buildChain, context);
 }
Exemplo n.º 36
0
 public void SetUp()
 {
     this.connectorMock = MockRepository.GenerateStub <IConnector>();
     this.order         = new Klarna.Rest.Checkout.CheckoutOrder(this.connectorMock, "0002");
 }
Exemplo n.º 37
0
 public AbstractSettingPane(IConnector Connector)
 {
     this.Connector = Connector;
 }
Exemplo n.º 38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MarketDepthCandleBuilderSource"/>.
 /// </summary>
 /// <param name="connector">The connection through which changed order books will be received using the event <see cref="IConnector.MarketDepthsChanged"/>.</param>
 public MarketDepthCandleBuilderSource(IConnector connector)
     : base(connector)
 {
     Connector.MarketDepthsChanged += OnMarketDepthsChanged;
 }
Exemplo n.º 39
0
        private void ConnectClick(object sender, RoutedEventArgs e)
        {
            if (_connector == null)
            {
                if (IsQuik.IsChecked == true)
                {
                    var isDde = IsDde.IsChecked == true;

                    if (isDde && Path.Text.IsEmpty())
                    {
                        MessageBox.Show(this, LocalizedStrings.Str2969);
                        return;
                    }

                    // создаем подключение
                    var trader = new QuikTrader(Path.Text)
                    {
                        IsDde = isDde
                    };

                    if (isDde)
                    {
                        // изменяем метаданные так, чтобы начали обрабатывать дополнительные колонки опционов
                        var columns = trader.SecuritiesTable.Columns;
                        columns.Add(DdeSecurityColumns.Strike);
                        columns.Add(DdeSecurityColumns.ImpliedVolatility);
                        columns.Add(DdeSecurityColumns.UnderlyingSecurity);
                        columns.Add(DdeSecurityColumns.TheorPrice);
                        columns.Add(DdeSecurityColumns.OptionType);
                        columns.Add(DdeSecurityColumns.ExpiryDate);
                    }

                    _connector = trader;
                }
                else
                {
                    var trader = new PlazaTrader
                    {
                        Address = Address.Text.To <EndPoint>(),
                        IsCGate = IsCGate.IsChecked == true
                    };

                    trader.Tables.Add(trader.TableRegistry.Volatility);

                    if (IsAutorization.IsChecked == true)
                    {
                        trader.Login    = Login.Text;
                        trader.Password = Password.Password;
                    }

                    _connector = trader;
                }

                Desk.MarketDataProvider = _connector;
                Desk.SecurityProvider   = _connector;
                Desk.CurrentTime        = null;

                // добавляем в выпадающий список только фьючерсы
                _connector.NewSecurities += securities =>
                                            this.GuiAsync(() =>
                {
                    _assets.AddRange(securities.Where(s => s.Type == SecurityTypes.Future));

                    if (SelectedAsset == null && _assets.Count > 0)
                    {
                        SelectedAsset = _assets.First();
                    }

                    if (SelectedAsset != null)
                    {
                        var newStrikes = securities
                                         .Where(s => s.Type == SecurityTypes.Option && s.UnderlyingSecurityId.CompareIgnoreCase(SelectedAsset.Id))
                                         .ToArray();

                        if (newStrikes.Length > 0)
                        {
                            _options.AddRange(newStrikes);
                            Desk.Options = _options;
                            Desk.RefreshOptions();
                        }
                    }
                });

                _connector.SecuritiesChanged += securities =>
                {
                    this.GuiAsync(() =>
                    {
                        if (SelectedAsset == null)
                        {
                            return;
                        }

                        var newStrikes = securities
                                         .Where(s => s.Type == SecurityTypes.Option && s.UnderlyingSecurityId.CompareIgnoreCase(SelectedAsset.Id))
                                         .Where(s => !_options.Contains(s))
                                         .ToArray();

                        if (newStrikes.Length > 0)
                        {
                            _options.AddRange(newStrikes);
                            Desk.Options = _options;
                            Desk.RefreshOptions();
                        }

                        if (Desk.Options.Intersect(securities).Any())
                        {
                            Desk.RefreshOptions();
                        }
                    });
                };

                // подписываемся на событие новых сделок чтобы обновить текущую цену фьючерса
                _connector.NewTrades += trades => this.GuiAsync(() =>
                {
                    var asset = SelectedAsset;
                    if (asset == null)
                    {
                        return;
                    }

                    if (asset.LastTrade != null)
                    {
                        LastPrice.Text = asset.LastTrade.Price.To <string>();
                    }
                });

                _connector.Connected += () =>
                {
                    var trader = _connector as QuikTrader;
                    if (trader != null && trader.IsDde)
                    {
                        var quikTrader = trader;
                        quikTrader.StartExport(new[] { quikTrader.SecuritiesTable, quikTrader.TradesTable });
                    }
                    else
                    {
                        _connector.StartExport();
                    }
                };
            }

            if (_connector.ConnectionState == ConnectionStates.Connected)
            {
                _connector.Disconnect();
            }
            else
            {
                _connector.Connect();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //Create an instance for PowerPoint
            IPresentation presentation = Presentation.Create();

            //Add a blank slide to Presentation
            ISlide slide = presentation.Slides.Add(SlideLayoutType.Blank);

            //Add header shape
            IShape headerTextBox = slide.Shapes.AddTextBox(58.44, 53.85, 221.93, 81.20);
            //Add a paragraph into the text box
            IParagraph paragraph = headerTextBox.TextBody.AddParagraph("Flow chart with ");
            //Add a textPart
            ITextPart textPart = paragraph.AddTextPart("Connector");

            //Change the color of the font
            textPart.Font.Color = ColorObject.FromArgb(44, 115, 230);
            //Make the textpart bold
            textPart.Font.Bold = true;
            //Set the font size of the paragraph
            paragraph.Font.FontSize = 28;

            //Add start shape to slide
            IShape startShape = slide.Shapes.AddShape(AutoShapeType.FlowChartTerminator, 420.45, 36.35, 133.93, 50.39);

            //Add a paragraph into the start shape text body
            AddParagraph(startShape, "Start", ColorObject.FromArgb(255, 149, 34));

            //Add alarm shape to slide
            IShape alarmShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 420.45, 126.72, 133.93, 50.39);

            //Add a paragraph into the alarm shape text body
            AddParagraph(alarmShape, "Alarm Rings", ColorObject.FromArgb(255, 149, 34));

            //Add condition shape to slide
            IShape conditionShape = slide.Shapes.AddShape(AutoShapeType.FlowChartDecision, 420.45, 222.42, 133.93, 97.77);

            //Add a paragraph into the condition shape text body
            AddParagraph(conditionShape, "Ready to Get Up ?", ColorObject.FromArgb(44, 115, 213));

            //Add wake up shape to slide
            IShape wakeUpShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 420.45, 361.52, 133.93, 50.39);

            //Add a paragraph into the wake up shape text body
            AddParagraph(wakeUpShape, "Wake Up", ColorObject.FromArgb(44, 115, 213));

            //Add end shape to slide
            IShape endShape = slide.Shapes.AddShape(AutoShapeType.FlowChartTerminator, 420.45, 453.27, 133.93, 50.39);

            //Add a paragraph into the end shape text body
            AddParagraph(endShape, "End", ColorObject.FromArgb(44, 115, 213));

            //Add snooze shape to slide
            IShape snoozeShape = slide.Shapes.AddShape(AutoShapeType.FlowChartProcess, 624.85, 245.79, 159.76, 50.02);

            //Add a paragraph into the snooze shape text body
            AddParagraph(snoozeShape, "Hit Snooze button", ColorObject.FromArgb(255, 149, 34));

            //Add relay shape to slide
            IShape relayShape = slide.Shapes.AddShape(AutoShapeType.FlowChartDelay, 624.85, 127.12, 159.76, 49.59);

            //Add a paragraph into the relay shape text body
            AddParagraph(relayShape, "Relay", ColorObject.FromArgb(255, 149, 34));

            //Connect the start shape with alarm shape using connector
            IConnector connector1 = slide.Shapes.AddConnector(ConnectorType.Straight, startShape, 2, alarmShape, 0);

            //Set the arrow style for the connector
            connector1.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the alarm shape with condition shape using connector
            IConnector connector2 = slide.Shapes.AddConnector(ConnectorType.Straight, alarmShape, 2, conditionShape, 0);

            //Set the arrow style for the connector
            connector2.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the condition shape with snooze shape using connector
            IConnector connector3 = slide.Shapes.AddConnector(ConnectorType.Straight, conditionShape, 3, snoozeShape, 1);

            //Set the arrow style for the connector
            connector3.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the snooze shape with relay shape using connector
            IConnector connector4 = slide.Shapes.AddConnector(ConnectorType.Straight, snoozeShape, 0, relayShape, 2);

            //Set the arrow style for the connector
            connector4.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the relay shape with alarm shape using connector
            IConnector connector5 = slide.Shapes.AddConnector(ConnectorType.Straight, relayShape, 1, alarmShape, 3);

            //Set the arrow style for the connector
            connector5.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the condition shape with wake up shape using connector
            IConnector connector6 = slide.Shapes.AddConnector(ConnectorType.Straight, conditionShape, 2, wakeUpShape, 0);

            //Set the arrow style for the connector
            connector6.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Connect the wake up shape with end shape using connector
            IConnector connector7 = slide.Shapes.AddConnector(ConnectorType.Straight, wakeUpShape, 2, endShape, 0);

            //Set the arrow style for the connector
            connector7.LineFormat.EndArrowheadStyle = ArrowheadStyle.Arrow;

            //Add No textbox to slide
            IShape noTextBox = slide.Shapes.AddTextBox(564.02, 245.43, 51.32, 26.22);

            //Add a paragraph into the text box
            noTextBox.TextBody.AddParagraph("No");

            //Add Yes textbox to slide
            IShape yesTextBox = slide.Shapes.AddTextBox(487.21, 327.99, 50.09, 26.23);

            //Add a paragraph into the text box
            yesTextBox.TextBody.AddParagraph("Yes");

            //Saves the presentation
            presentation.Save("ConnectorSample.pptx", FormatType.Pptx, Response);
        }
Exemplo n.º 41
0
 /// <summary>
 /// Let subclass to filter connection possibility
 /// </summary>
 /// <param name="from">start connector</param>
 /// <param name="to">end connector</param>
 /// <returns>true if this connection is possible, otherwise false</returns>
 protected virtual bool CanConnect(IConnector from, IConnector to)
 {
     return(true);
 }
Exemplo n.º 42
0
 public ExchangeRateProvider(IConnector connector, IParser parser)
 {
     this._connector = connector;
     this._parser    = parser;
 }
Exemplo n.º 43
0
 public LeafController(IConnector Connector)
 {
     db = Connector;
 }
Exemplo n.º 44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExpressionConnector"/> class.
        /// </summary>
        /// <param name="connectorType">Type of the connector.</param>
        /// <param name="connector">The connector.</param>
        /// <exception cref="System.ArgumentNullException">connector</exception>
        public ExpressionConnector(ConnectorType connectorType, IConnector connector)
        {
            if (connector == null)
                throw new ArgumentNullException("connector");

            Id = connector.Id;
            _connectorType = connectorType;
            _dataType = connector.DataType;
            _name = connector.Name;
            _connector = connector;
            _connector.PropertyChanged += OnConnectorPropertyChanged;
        }
Exemplo n.º 45
0
        public MainWindow()
        {
            InitializeComponent();

            var assetsSource  = new ObservableCollectionEx <Security>();
            var optionsSource = new ObservableCollectionEx <Security>();

            Options.ItemsSource = optionsSource;
            Assets.ItemsSource  = assetsSource;

            _assets  = new ThreadSafeObservableCollection <Security>(assetsSource);
            _options = new ThreadSafeObservableCollection <Security>(optionsSource);

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(5)
            };

            timer.Tick += (sender, args) =>
            {
                if (!_isDirty)
                {
                    return;
                }

                _isDirty = false;
                RefreshChart();
            };
            timer.Start();

            //
            // draw test data on the chart

            var asset = new Security {
                Id = "RIM4@FORTS"
            };

            Connector = new FakeConnector(new[] { asset });

            PosChart.AssetPosition = new Position
            {
                Security     = asset,
                CurrentValue = -1,
            };

            PosChart.MarketDataProvider = Connector;
            PosChart.SecurityProvider   = Connector;

            var expDate = new DateTime(2014, 6, 14);

            PosChart.Positions.Add(new Position
            {
                Security = new Security {
                    Code = "RI C 110000", Strike = 110000, ImpliedVolatility = 45, OptionType = OptionTypes.Call, ExpiryDate = expDate, Board = ExchangeBoard.Forts, UnderlyingSecurityId = asset.Id
                },
                CurrentValue = 10,
            });
            PosChart.Positions.Add(new Position
            {
                Security = new Security {
                    Code = "RI P 95000", Strike = 95000, ImpliedVolatility = 30, OptionType = OptionTypes.Put, ExpiryDate = expDate, Board = ExchangeBoard.Forts, UnderlyingSecurityId = asset.Id
                },
                CurrentValue = -3,
            });

            PosChart.Refresh(100000, 10, new DateTime(2014, 5, 5), expDate);

            Instance = this;
        }
Exemplo n.º 46
0
        /// <summary>
        /// Handles the mouse move event
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        public void MouseMove(MouseEventArgs e)
        {
            if(e == null)
                throw new ArgumentNullException("The argument object is 'null'");
            Point point = e.Location;
            if(IsActive)
            {
                //can be a connector
                if(Selection.Connector != null)
                {
                    Selection.Connector.Move(new Point(point.X - lastPoint.X, point.Y - lastPoint.Y));
                    #region Do we hit something meaningful?

                    if (hoveredConnector != null)
                        hoveredConnector.Hovered = false;

                    hoveredConnector = Selection.FindConnectorAt(e.Location);
                    if(hoveredConnector!=null)
                        hoveredConnector.Hovered = true;
                    if(hoveredConnector != null && hoveredConnector!=Selection.Connector)
                    {
                        Controller.View.CurrentCursor = CursorPallet.Grip;

                    }
                    else
                        Controller.View.CurrentCursor = CursorPallet.Move;
                    #endregion
                }
                else //can be a selection
                {
                    foreach(IDiagramEntity entity in Selection.SelectedItems)
                    {

                        entity.Move(new Point(point.X - lastPoint.X, point.Y - lastPoint.Y));
                    }
                }
                lastPoint = point;
            }
        }
Exemplo n.º 47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Resource" /> class.
 /// </summary>
 /// <param name="connector">the connector</param>
 public Resource(IConnector connector)
 {
     this.Connector = connector;
 }
Exemplo n.º 48
0
			//private const int _maxCandleCount = 50;

			public StorageCandleManager(IConnector connector)
				: base(connector)
			{
				//Sources.OfType<StorageCandleSource>().Single().Drive = new LocalMarketDataDrive(UserConfig.Instance.CandleSeriesDumpPath);

				Sources.OfType<StorageCandleSource>().Single().StorageRegistry = ConfigManager.GetService<IStorageRegistry>();
				Sources.Where(s => !(s is StorageCandleSource)).ForEach(s => s.Processing += OnProcessing);

				Stopped += OnStopped;
			}
Exemplo n.º 49
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CandleManager"/>.
 /// </summary>
 /// <param name="connector">The connection to trading system to create the source for tick trades by default.</param>
 public CandleManager(IConnector connector)
     : this()
 {
     Sources.Add(new ConnectorCandleSource(connector));
 }
 /// <summary>
 /// Moves the connector to the given location.
 /// </summary>
 /// <param name="cn">The cn.</param>
 /// <param name="point">The point.</param>
 private void MoveConnector(IConnector cn, Point point)
 {
     connectorMemory.Add(cn, cn.Point);//luckily the Point is a struct so the value will be actually copied and we can safely change the value next
     cn.Move(new Point(point.X - cn.Point.X, point.Y - cn.Point.Y));
     cn.Enabled = false;
 }
Exemplo n.º 51
0
    protected override void Initialize() {
      base.Initialize();

      //the initial size
      this.Transform(0, 0, 200, headerHeight);
      this.color = Color.LightBlue;

      this.iconMaterial = new IconMaterial();
      this.iconMaterial.Gliding = false;
      this.Children.Add(iconMaterial);

      Bitmap expandBitmap = new Bitmap(HeuristicLab.Common.Resources.VSImageLibrary.Expand);
      Bitmap collapseBitmap = new Bitmap(HeuristicLab.Common.Resources.VSImageLibrary.Collapse);
      this.expandIconMaterial = new ExpandableIconMaterial(expandBitmap, collapseBitmap);
      this.expandIconMaterial.Gliding = false;
      this.expandIconMaterial.Transform(new Rectangle(new Point(Rectangle.Right - 20, Rectangle.Y + 7), expandIconMaterial.Icon.Size));
      this.expandIconMaterial.Visible = false;
      this.expandIconMaterial.OnExpand += new EventHandler(expandIconMaterial_OnExpand);
      this.expandIconMaterial.OnCollapse += new EventHandler(expandIconMaterial_OnCollapse);
      this.Children.Add(expandIconMaterial);

      this.predecessor = this.CreateConnector(OperatorShapeInfoFactory.PredecessorConnector, new Point(Rectangle.Left, Center.Y));
      this.Connectors.Add(predecessor);

      this.successor = this.CreateConnector(OperatorShapeInfoFactory.SuccessorConnector, (new Point(Rectangle.Right, Center.Y)));
      this.Connectors.Add(successor);
    }
Exemplo n.º 52
0
 /// <summary>
 /// Configure the class to use the default parser type and connector
 /// </summary>
 public METARAccessor()
 {
     _parserType = ParserType.XML;
     _connector  = new HttpConnector();
 }
Exemplo n.º 53
0
 /// <summary>
 /// Configure the class to request data via the included connector
 /// and request data in the format associated with the parser
 /// </summary>
 /// <param name="parser"></param>
 /// <param name="connector"></param>
 public METARAccessor(ParserType parser, IConnector connector)
     : this(parser)
 {
     _connector = connector;
 }
Exemplo n.º 54
0
    public void InitialPlugins()
    {
        var _path_base = new System.IO.DirectoryInfo(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
        List <System.IO.DirectoryInfo> dirs = new List <System.IO.DirectoryInfo>();

        #region Paths parse

        if (Config.config.Get("plug") != null)
        {
            var _paths_string = Config.config.Get("plug").Get <string>("paths");
            if (_paths_string != null && _paths_string.Length > 0)
            {
                foreach (var _path_string in _paths_string)
                {
                    if (string.IsNullOrWhiteSpace(_path_string))
                    {
                        break;
                    }
                    System.IO.DirectoryInfo dir;
                    TryGetPath(_path_string, _path_base, out dir);
                    dirs.Add(dir);
                }
            }
        }

        if (dirs.Count < 1)
        {
            dirs.Add(_path_base);
            dirs.Add(new System.IO.DirectoryInfo(System.IO.Path.Combine(_path_base.FullName, "plugs")));
        }
        #endregion

        #region Load Dll files
        foreach (var dir in dirs.Where(w => w.Exists))
        {
            foreach (var file in dir.GetFiles("*.dll", System.IO.SearchOption.TopDirectoryOnly))
            {
                var _assembly = System.Reflection.Assembly.LoadFile(file.FullName);

                IManifest  manifest  = null;
                IConnector connector = null;

                foreach (var _main in _assembly.GetTypes().Where(w => w.GetInterface(nameof(IConnector)) != null || w.GetInterface(nameof(IManifest)) != null).ToList())
                {
                    var runnable = Activator.CreateInstance(_main);
                    if (runnable != null && runnable is IManifest)
                    {
                        manifest = (IManifest)runnable;
                    }
                    if (runnable != null && runnable is IConnector)
                    {
                        connector = (IConnector)runnable;
                    }
                }

                if (manifest != null && connector != null && !plugs.ContainsKey(manifest))
                {
                    plugs.Add(manifest, connector);
                    connector.Initial(Config.config, Story.story);
                }
            }
        }
        #endregion
    }
Exemplo n.º 55
0
		private CandleManager CreateCandleManager(IConnector connector, TimeSpan candlesKeepTime)
		{
			return new CandleManager(connector) { Container = { CandlesKeepTime = candlesKeepTime } };

			//var candleManager = new StorageCandleManager(connector) { Container = { CandlesKeepTime = TimeSpan.FromDays(1) } };

			//foreach (var type in AppConfig.Instance.CandleSources)
			//{
			//	var source = type.CreateInstance<object>();

			//	source.DoIf<object, ICandleManagerSource>(s => candleManager.Sources.Add(s));
			//	source.DoIf<object, ICandleBuilderSource>(s => candleManager.Sources.OfType<ICandleBuilder>().ForEach(b => b.Sources.Add(s)));
			//}

			//candleManager.StorageRegistry = ConfigManager.GetService<IStorageRegistry>();

			//return candleManager;
		}
Exemplo n.º 56
0
 private void RegisterEvents(IConnector connector)
 {
     ReplayLogic.ReplayFinished += ReplayFinished;
     connector.Initialized      += Connector_Initialized;
     connector.Closed           += Connector_Closed;
 }
Exemplo n.º 57
0
 public void AddConnection(IConnector from, IConnector to)
 {
     Connection con = new Connection(from.Point, to.Point);
     this.AddConnection(con);
 }
Exemplo n.º 58
0
 /// <summary>
 /// See interface docs.
 /// </summary>
 /// <param name="connector"></param>
 /// <param name="bytesExtractor"></param>
 /// <param name="rawMessageTranslator"></param>
 public void ChangeSource(IConnector connector, IMessageBytesExtractor bytesExtractor, IRawMessageTranslator rawMessageTranslator)
 {
     throw new InvalidOperationException("You cannot call ChangeSource on a merged feed listener");
 }
Exemplo n.º 59
0
        public static object ProcessNode(XmlElement element, IBlockWeb blockWeb, string blockId, IConnector connector)
        {
            switch (element.Name)
            {
                case "blockWeb":
                    {
                        string id = null;
                        if (element.HasAttribute("id"))
                        {
                            id = element.GetAttribute("id");
                        }

                        BlockWeb newWeb = null;

                        if ( blockId != null )
                        {
                            newWeb = (BlockWeb) blockWeb[blockId].ProcessRequest("ProcessMetaService", BlockMetaServiceType.GetInnerWeb,
                                null, null);
                        }
                        else
                        {
                            newWeb = new BlockWeb(id, DefaultBroker);
                        }

                        TemplateProcessor.ProcessTemplateFile(element, newWeb, blockId, connector);
                        ProcessNodeChildren(element, newWeb, blockId, connector);

                        return newWeb;
                    }
                case "actions":
                    {
                        TemplateProcessor.ProcessTemplateFile(element, blockWeb, blockId, connector);

                        ProcessNodeChildren(element, blockWeb, blockId, connector);

                        break;
                    }
                case "blocks":
                    {
                        TemplateProcessor.ProcessTemplateFile(element, blockWeb, blockId, connector);

                        ProcessNodeChildren(element, blockWeb, blockId, connector);

                        break;
                    }
                case "block":
                    {
                        BlockHandle cid = ObjectReader.ReadBlockHandle(element);
                        string id = null;

                        if (element.HasAttribute("id"))
                        {
                            id = element.GetAttribute("id");
                        }
                        else
                        {
                            id = "ctl_" + (Guid.NewGuid().ToString());
                        }

                        blockWeb.AddBlock(cid, id);

                        TemplateProcessor.ProcessTemplateFile(element, blockWeb, id, connector);

                        ProcessNodeChildren(element, blockWeb, id, connector);

                        //(blockWeb[id] as IContainedBlock).OnAfterLoad();

                        break;
                    }
                case "attachEndPoint":
                    {
                        EndPointExtractor.ProcessAttachEndPointsAction(element, blockWeb, blockId);

                        break;
                    }
                case "processRequest":
                    {
                        ActionProcessor.ProcessProcessRequest(element, blockWeb, blockId);

                        break;
                    }
                case "setProperty":
                    {
                        ActionProcessor.ProcessSetProperty(element, blockWeb, blockId);

                        break;
                    }
                case "setVariable":
                    {
                        ActionProcessor.ProcessSetVariable(element, blockWeb, blockId);

                        break;
                    }
                case "serviceEndPoint":
                case "valueEndPoint":
                case "connectorEndPoint":
                    {
                        EndPointExtractor.ProcessAttachEndPoint(blockWeb, connector, element, blockId);

                        break;
                    }
            }

            return null;
        }
Exemplo n.º 60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TradeCandleBuilderSource"/>.
 /// </summary>
 /// <param name="connector">The connection through which new trades will be received using the event <see cref="IConnector.NewTrades"/>.</param>
 public TradeCandleBuilderSource(IConnector connector)
     : base(connector)
 {
     Connector.NewTrades += AddNewValues;
 }