Ejemplo n.º 1
0
        protected SquidexClientBase(SquidexOptions options, HttpClient httpClient)
        {
            Guard.NotNull(options, nameof(options));
            Guard.NotNull(httpClient, nameof(httpClient));

            Options = options;

            this.httpClient = httpClient;
        }
Ejemplo n.º 2
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
        protected internal SquidexClientBase(SquidexOptions options, HttpClient httpClient)
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
        {
            Guard.NotNull(options, nameof(options));
            Guard.NotNull(httpClient, nameof(httpClient));

            Options = options;

            this.httpClient = httpClient;
        }
Ejemplo n.º 3
0
        public static SquidexOptions ToSquidexOptions(this IConfiguration configuration)
        {
            var squidexOptions = new SquidexOptions
            {
                AppName      = configuration["Squidex:AppName"],
                ClientId     = configuration["Squidex:ClientId"],
                ClientSecret = configuration["Squidex:ClientSecret"],
                Url          = configuration["Squidex:Url"]
            };

            return(squidexOptions);
        }
        public void ConnectToCMS(AppOptions appOptions)
        {
            var options = new SquidexOptions()
            {
                AppName      = appOptions.AppName,
                ClientId     = appOptions.ClientId,
                ClientSecret = appOptions.ClientSecret,
                Url          = appOptions.Url
            };

            clientManager        = new SquidexClientManager(options);
            ledColorsSeqClient   = clientManager.CreateContentsClient <LedColorsSeq, LedColorsSeqData>("cp-led-color-sequence");
            collectionPointsData = clientManager.CreateContentsClient <CollectionPoint, CollectionPointData>("collection-points");
            cpImageAsset         = clientManager.CreateContentsClient <ImageAsset, ImageAssetData>("cp-image-asset");
            cpQuoteAsset         = clientManager.CreateContentsClient <QuoteAsset, QuoteAssetData>("cp-qoute-asset");
        }
Ejemplo n.º 5
0
        public FeaturesService(IOptions <MyNewsOptions> options)
        {
            if (options.Value.IsConfigured())
            {
                var squidexOptions = new SquidexOptions
                {
                    AppName      = options.Value.AppName,
                    ClientId     = options.Value.ClientId,
                    ClientSecret = options.Value.ClientSecret,
                    Url          = "https://cloud.squidex.io"
                };

                var clientManager = new SquidexClientManager(squidexOptions);

                client = clientManager.CreateContentsClient <NewsEntity, FeatureDto>("feature-news");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Authenticator"/> class.
        /// </summary>
        /// <param name="options">The options to configure.</param>
        /// <exception cref="ArgumentNullException"><paramref name="options"/> is null.</exception>
        public Authenticator(SquidexOptions options)
        {
            Guard.NotNull(options, nameof(options));

            var handler = new HttpClientHandler();

            options.Configurator.Configure(handler);

            httpClient =
                options.ClientFactory.CreateHttpClient(handler) ??
                new HttpClient(handler, false);

            httpClient.Timeout = options.HttpClientTimeout;

            options.Configurator.Configure(httpClient);

            this.options = options;
        }
Ejemplo n.º 7
0
        private static SquidexOptions CreateOptions(ConfiguredApp app, bool emulate)
        {
            var options = new SquidexOptions
            {
                AppName      = app.Name,
                ClientId     = app.ClientId,
                ClientSecret = app.ClientSecret,
                Url          = app.ServiceUrl
            };

            if (app.IgnoreSelfSigned)
            {
                options.Configurator = AcceptAllCertificatesConfigurator.Instance;
            }

            if (emulate)
            {
                options.ClientFactory = new GetOnlyHttpClientFactory();
            }

            return(options);
        }
Ejemplo n.º 8
0
 public SquidexService(IOptions <SquidexOptions> squidexOptions)
 {
     _squidexClientManager = new SquidexClientManager(squidexOptions.Value);
     _squidexOptions       = squidexOptions.Value;
 }