예제 #1
0
 public DocumentRequestor(IWebRequestor webRequestor, string url, bool persistStatus200)
 {
     this.webRequestor     = webRequestor;
     this.url              = url;
     this.persistStatus200 = persistStatus200;
     validate();
 }
예제 #2
0
 public DocumentRequestor(IWebRequestor webRequestor, string url, Cookie sessionCookie, bool persistStatus200)
 {
     this.url              = url;
     this.sessionCookie    = sessionCookie ?? throw new ArgumentNullException(nameof(sessionCookie));
     this.persistStatus200 = persistStatus200;
     validate();
 }
 public TelegramUpdatesReader(
     TelegramBotSettings botSettings,
     IWebRequestor webRequestor)
 {
     this.botSettings  = botSettings;
     this.webRequestor = webRequestor;
 }
예제 #4
0
 public DocumentRequestor(IWebRequestor webRequestor, string url, Cookie sessionCookie)
 {
     this.webRequestor  = webRequestor;
     this.url           = url;
     this.sessionCookie = sessionCookie ?? throw new ArgumentNullException(nameof(sessionCookie));
     validate();
 }
예제 #5
0
 public TelegramChatMessagePublisher(
     TelegramBotSettings botSettings,
     IWebRequestor webRequestor)
 {
     this.botSettings  = botSettings;
     this.webRequestor = webRequestor;
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SeriesService"/> class.
 /// </summary>
 /// <param name="webRequestor">The web requestor.</param>
 /// <param name="jsonSerializer">The JSON serializer.</param>
 public SeriesService(
     IWebRequestor webRequestor,
     IJsonSerializer jsonSerializer)
     : base(jsonSerializer)
 {
     this.webRequestor = webRequestor;
 }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CharacterService"/> class.
 /// </summary>
 /// <param name="webRequestor">The web requestor.</param>
 /// <param name="jsonSerializer">The JSON serializer.</param>
 public CharacterService(
     IWebRequestor webRequestor,
     IJsonSerializer jsonSerializer)
     : base(jsonSerializer)
 {
     this.webRequestor = webRequestor;
 }
        public ConnectionViewModel(ICommunicationEngine communicationEngine, IWebRequestor webRequestor, IHashCreator hashCreator)
        {
            _communicationEngine = communicationEngine;
            _webRequestor        = webRequestor;
            _hashCreator         = hashCreator;

            //Give the communication engine a way to reference back to this instance.
            if (_communicationEngine != null)
            {
                _communicationEngine.ParentConnectionViewModel = this;
            }

            Traffic = new ObservableList <TrafficData>(Application.Current.Dispatcher);

            //Create the command documents that this view model sends once here so we don't have to
            //create them each time the command is sent.
            _versionCommandDocument           = XDocument.Parse("<Version/>");
            _supportedCulturesCommandDocument = XDocument.Parse("<SupportedCultures/>");
            _instrumentInfoCommandDocument    = XDocument.Parse("<InstrumentInfo/>");
            _logoffCommandDocument            = XDocument.Parse("<Logoff/>");
            _inRemoteControlModeDocument      = XDocument.Parse("<RemoteControlState/>");

            SupportedCultures = new ObservableList <LanguageElement>(Application.Current.Dispatcher);
            InstrumentInfo    = new ObservableList <InstrumentInfoElement>(Application.Current.Dispatcher);

            IsTcpConnection = true;
            HttpServer      = "remote.lecosoftware.com";

            //Initialize default connection parameters.
            Port = 12345;
            var address = Dns.GetHostAddresses(Dns.GetHostName()).FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetwork);

            if (address != null)
            {
                IpAddress = address.ToString();
            }

            //Create the commands that the view will bind to.
            ConnectCommand           = new RelayCommand(OnConnect);
            DisconnectCommand        = new RelayCommand(OnDisconnect);
            LogonCommand             = new RelayCommand(OnLogon);
            LogoffCommand            = new RelayCommand(OnLogoff);
            GetInstrumentListCommand = new RelayCommand(OnGetInstrumentList);

            //We want to know if the app becomes disconnected so subscribe to diconnected event.
            EventAggregatorContext.Current.GetEvent <ClientDisconnectedEvent>().Subscribe(OnClientDisconnected);

            //Listen to our own property changes
            PropertyChanged += ConnectionViewModel_PropertyChanged;
        }
 /// <summary>
 /// Tell the reporter to use magic AWS REST address to get the AWS instance Id
 /// </summary>
 /// <returns>this</returns>
 public SignalFxReporterBuilder WithAWSInstanceIdDimension(IWebRequestor awsRequestor = null)
 {
     if (awsRequestor == null)
     {
         awsRequestor = new WebRequestor("http://169.254.169.254/latest/meta-data/instance-id")
                        .WithTimeout(1000 * 60)
                        .WithMethod("GET");
     }
     using (var resp = awsRequestor.Send())
     {
         string source = new StreamReader(resp).ReadToEnd();
         defaultDimensions[INSTANCE_ID_DIMENSION] = source;
         return(this);
     }
 }
예제 #10
0
        /// <summary>
        /// Constructor for unit tests
        /// </summary>
        internal BrowserEmulator(string baseUrl, IWebRequestor webRequestor, IBrowserEmulatorLog log, IFileSystem fileSystem)
        {
            // update given base url if it has no trailing /
            if (!baseUrl.EndsWith("/"))
            {
                baseUrl += "/";
            }

            // set initial Uri to be equal to root
            this._currentUri     = new Uri(baseUrl);
            this._currentCookies = new CookieContainer();
            this._webRequestor   = webRequestor;
            this._fileSystem     = fileSystem;
            this._log            = log;

            // we want to have output in the log
            SilentMode = false;
        }
예제 #11
0
        public LongPoller(
            IWebRequestor requestor, 
            ISerialiser formatter, 
            ITaskScheduler scheduler, 
            MessageReceiver receiver, 
            ITaskStarter starter)
        {
            Contract.Requires(requestor != null);
            Contract.Requires(formatter != null);
            Contract.Requires(scheduler != null);
            Contract.Requires(receiver != null);
            Contract.Requires(starter != null);

            this.requestor = requestor;
            this.formatter = formatter;
            this.scheduler = scheduler;
            this.receiver = receiver;
            this.starter = starter;
        }
예제 #12
0
        /// <summary>
        /// Constructs instance of CommunicationEngine class.
        /// </summary>
        /// <param name="webRequestor">Instance of class used to perform HTTP-type communications with instrument.</param>
        public CommunicationEngine(IWebRequestor webRequestor)
        {
            _webRequestor = webRequestor;

            //Create the heartbeat timer to keep the connection alive.
            _heartbeatTimer          = new System.Timers.Timer();
            _heartbeatTimer.Elapsed += HeartbeatTimerOnElapsed;
            _heartbeatTimer.Interval = 5000;//30000; //30 seconds

            //Create the heartbeat command document once so we don't have to keep creating it every time we send a heartbeat command.
            //_heartbeatEventArgs = new SendDataEventArgs(XDocument.Parse("<Status  IncludeGauges=\"False\" IncludeSystemCheckResults=\"False\" IncludeLeakCheckResults=\"False\"/>"), null);
            _heartbeatEventArgs = new SendDataEventArgs("<Heartbeat/>", null);

            //Start out with English as the default.
            RequestCulture = "en-US";

            //Listen for other parts of the application requesting this class to send data.
            EventAggregatorContext.Current.GetEvent <SendDataEvent>().Subscribe(OnSendData);

            //Start the background thread to monitor commands to send to Cornerstone.
            Task.Factory.StartNew(MonitorQueue);

            EncodingToUse = Encoding.Unicode;
        }
예제 #13
0
 public DocumentRequestor(IWebRequestor webRequestor, string url)
 {
     this.webRequestor = webRequestor;
     this.url          = url;
     validate();
 }
예제 #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImageService"/> class.
 /// </summary>
 /// <param name="webRequestor">The web requestor.</param>
 public ImageService(IWebRequestor webRequestor)
 {
     this.webRequestor = webRequestor;
 }
예제 #15
0
 internal WebHelper(IWebRequestor webRequestor)
 {
     WebRequestor = webRequestor;
 }
예제 #16
0
 internal AzureCloudServiceManager(IWebRequestor requestor)
 {
     _webRequestor           = requestor;
     ComputeManagementClient = new ComputeManagementClient(Dependencies.Subscription.Credentials);
 }
예제 #17
0
 internal WebHelper(IWebRequestor webRequestor)
 {
     WebRequestor = webRequestor;
 }
        /// <summary>
        /// Initializes a new instance of the SearchProvider class.
        /// The class is created by the Script Explorer framework when a Search is performed, 
        /// either by a client GUI or through a REST URL access. A fresh object
        /// is created for each operation.
        /// </summary>
        /// <param name="name">The Provider name</param>
        /// <param name="configurationElement">The configuration from app/web.config<</param>
        /// <param name="host">The configured host</param>
        /// <param name="logger">The configured logger</param>
        /// <param name="settings">The settings.</param>
        /// <param name="webRequestor">A web requestor implementation for making http requests</param>
        public SearchProvider(string name, RepositoryElement configurationElement, IHost host, ILogger logger, ISettingsManager settings, IWebRequestor webRequestor)
            : base(name, configurationElement, host, logger, settings)
        {
            Guard.NotNull(() => webRequestor, webRequestor);

            this.ApiKey = ConfigurationElement.Attributes[ApiKeyAttributeName];

            if(string.IsNullOrEmpty(this.ApiKey))
            {
                throw new ArgumentNullException(string.Format(CultureInfo.CurrentCulture, Resources.KeyMissing, name));
            }

            var maxResultsValue = ConfigurationElement.Attributes[MaxResultsAttributeName];
            int maxResults;

            if (int.TryParse(maxResultsValue, out maxResults))
            {
                if (maxResults > DefaultMaxResults)
                {
                    this.MaxResults = DefaultMaxResults;
                }
                else
                {
                    this.MaxResults = maxResults;
                }
            }
            else
            {
                this.MaxResults = DefaultMaxResults;
            }

            this.CustomSearchId = ConfigurationElement.Attributes[CustomSearchIdAttributeName];
            this.CustomSearchReference = ConfigurationElement.Attributes[CustomSearchReferenceAttributeName];

            if (string.IsNullOrEmpty(this.CustomSearchId) && string.IsNullOrEmpty(this.CustomSearchReference))
            {
                throw new ArgumentNullException(string.Format(CultureInfo.CurrentCulture, Resources.CustomSearchMissing, name));
            }

            this.webRequestor = webRequestor;
        }
 internal AzureCloudServiceManager(IWebRequestor requestor)
 {
     _webRequestor = requestor;
     ComputeManagementClient = new ComputeManagementClient(Dependencies.Subscription.Credentials);
 }
 public MessageTransporter(IWebRequestor requestor, ISerialiser formatter)
 {
     this.requestor = requestor;
     this.formatter = formatter;
 }