Esempio n. 1
0
        public ApiEndpoints(IComponentContext components)
        {
            _apiBase = components.Resolve <IApiBase>();
            _logger  = components.Resolve <ILogger>();

            _baseHttpClient = new HttpClient()
            {
                BaseAddress = new Uri("https://api.nexusmods.com"),
                Timeout     = TimeSpan.FromSeconds(10)
            };

            _baseHttpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
        }
Esempio n. 2
0
 /// <summary>
 /// Sets api values in a result object.
 /// </summary>
 /// <param name="api">The object containing api values.</param>
 /// <param name="validationErrors">Validation errors from an api call.</param>
 /// <param name="result">The object in which the values are set.</param>
 public void SetApiValues(IApiBase api, IDictionary <string, string> validationErrors, ApiData result)
 {
     if (validationErrors != null)
     {
         result.ArgumentValidationErrors = new List <KeyValuePair <string, string> >();
         foreach (var error in validationErrors)
         {
             result.ArgumentValidationErrors.Add(new KeyValuePair <string, string>(error.Key, error.Value));
         }
     }
     result.FetchMessage = api.FetchMessage;
     result.Url          = api.Url;
 }
Esempio n. 3
0
        public ValidateModsViewModel(IComponentContext components)
        {
            _viewController    = components.Resolve <IViewController>();
            _validate          = components.Resolve <IValidate>();
            _fileSystemBrowser = components.Resolve <IFileSystemBrowser>();
            _nxmHandle         = components.Resolve <INxmHandle>();
            _apiEndpoints      = components.Resolve <IApiEndpoints>();
            _downloadClient    = components.Resolve <IDownloadClient>();
            _apiBase           = components.Resolve <IApiBase>();
            _installBase       = components.Resolve <IInstallBase>();

            _viewController.ViewIndexChangedEvent += ViewControllerOnViewIndexChangedEvent;
            _nxmHandle.RecievedPipedDataEvent     += QueueDownload;
            _downloadClient.DownloadUpdate        += DownloadUpdate;
        }
Esempio n. 4
0
        /// <summary>
        /// Sets api values in a result object.
        /// </summary>
        /// <param name="api">The object containing api values.</param>
        /// <param name="result">The object in which the values are set.</param>
        protected void SetApiValues(IApiBase api, ApiData result)
        {
            var validationErrors = api.GetArguments().ValidationErrors;

            if (validationErrors != null)
            {
                result.ArgumentValidationErrors = new List <KeyValuePair <string, string> >();
                foreach (var error in validationErrors)
                {
                    result.ArgumentValidationErrors.Add(new KeyValuePair <string, string>(error.Key, error.Value));
                }
            }
            result.FetchMessage = api.FetchMessage;
            result.Url          = api.Url;
        }
Esempio n. 5
0
 public void Initialize(IApiBase iApiBase)
 {
     foreach (var property in GetType()
              .GetProperties(BindingFlags.Instance | BindingFlags.Public)
              .Where(obj => typeof(IBaseService).IsAssignableFrom(obj.PropertyType)))
     {
         var obj = property.GetValue(this);
         if (obj == null)
         {
             continue;
         }
         var baseService = obj as IBaseService;
         baseService?.Initialize(iApiBase);
     }
     RequestParam = iApiBase.RequestParam;
 }
Esempio n. 6
0
        public ApiEndpoints(IComponentContext components)
        {
            _apiBase = components.Resolve <IApiBase>();
            _logger  = components.Resolve <ILogger>();

            _baseHttpClient = new HttpClient()
            {
                BaseAddress = new Uri("https://api.nexusmods.com"),
                Timeout     = TimeSpan.FromSeconds(10),
            };

            var platformType = Environment.Is64BitOperatingSystem ? "x64" : "x86";
            var headerString = $"Automaton/{Assembly.GetEntryAssembly().GetName().Version} ({Environment.OSVersion.VersionString}; {platformType}) {RuntimeInformation.FrameworkDescription}";

            _baseHttpClient.DefaultRequestHeaders.Add("User-Agent", headerString);
            _baseHttpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
        }
Esempio n. 7
0
        public ValidateModsViewModel(IComponentContext components)
        {
            _viewController    = components.Resolve <IViewController>();
            _validate          = components.Resolve <IValidate>();
            _fileSystemBrowser = components.Resolve <IFileSystemBrowser>();
            _nxmHandle         = components.Resolve <INxmHandle>();
            _apiEndpoints      = components.Resolve <IApiEndpoints>();
            _downloadClient    = components.Resolve <IDownloadClient>();
            _apiBase           = components.Resolve <IApiBase>();
            _installBase       = components.Resolve <IInstallBase>();
            _dialogController  = components.Resolve <IDialogController>();
            _logger            = components.Resolve <ILogger>();

            _viewController.ViewIndexChangedEvent += ViewControllerOnViewIndexChangedEvent;
            _nxmHandle.RecievedPipedDataEvent     += QueueDownload;
            _downloadClient.DownloadUpdate        += DownloadUpdate;

            BindingOperations.EnableCollectionSynchronization(MissingMods, _missingModsLocked);
        }
Esempio n. 8
0
 public TradeClient()
 {
     _api = new AlpacaApiBase();
 }
Esempio n. 9
0
 public OverlayApi(TinyIoCContainer container, IApiBase receiver)
 {
     this.dispatcher = container.Resolve <EventDispatcher>();
     this.receiver   = receiver;
     this.logger     = container.Resolve <ILogger>();
 }
Esempio n. 10
0
 public OverlayApi(IApiBase receiver)
 {
     this.receiver = receiver;
 }
Esempio n. 11
0
 public NexusLoginViewModel(IComponentContext components)
 {
     _apiBase        = components.Resolve <IApiBase>();
     _installBase    = components.Resolve <IInstallBase>();
     _viewController = components.Resolve <IViewController>();
 }