Ejemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="clientsidePropertyService">
 /// The <see cref="IClientsidePropertyService"/> to use when
 /// JavaScript needs to be returned to the user.
 /// </param>
 /// <param name="options">
 /// The configuration options for this service
 /// </param>
 /// <param name="flowDataProvider">
 /// The provider to use when accessing the <see cref="IFlowData"/>
 /// instance.
 /// </param>
 public FiftyOneJSService(
     IClientsidePropertyService clientsidePropertyService,
     IOptions <PipelineWebIntegrationOptions> options,
     IFlowDataProvider flowDataProvider)
 {
     ClientsidePropertyService = clientsidePropertyService;
     Options          = options;
     FlowDataProvider = flowDataProvider;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a new FiftyOneMiddleware object.
 /// </summary>
 /// <param name="next">
 /// The next component in the Pipeline
 /// </param>
 /// <param name="pipelineResultService">
 /// A service that will determine the device making the request
 /// and store details of the device against the HttpContext for
 /// use further down the Pipeline
 /// </param>
 /// <param name="jsService">
 /// A service that can serve the 51Degrees JavaScript if needed
 /// </param>
 /// <param name="flowDataProvider">
 /// A service to get FlowData Object from response
 /// </param>
 /// <param name="headerService">
 /// A service that can set headers in the response based on
 /// data from an <see cref="ISetHeadersElement"/>.
 /// </param>
 public FiftyOneMiddleware(RequestDelegate next,
                           IPipelineResultService pipelineResultService,
                           IFiftyOneJSService jsService,
                           IFlowDataProvider flowDataProvider,
                           ISetHeadersService headerService)
 {
     Next = next;
     PipelineResultService = pipelineResultService;
     JsService             = jsService;
     FlowDataProvider      = flowDataProvider;
     HeaderService         = headerService;
 }
        /// <summary>
        /// Create a new ClientsidePropertyService
        /// </summary>
        /// <param name="flowDataProvider"></param>
        /// <param name="pipeline"></param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if a required parameter is null.
        /// </exception>
        public ClientsidePropertyService(
            IFlowDataProvider flowDataProvider,
            IPipeline pipeline)
        {
            if (pipeline == null)
            {
                throw new ArgumentNullException(nameof(pipeline));
            }

            _flowDataProvider = flowDataProvider;
            _pipeline         = pipeline;

            var headersAffectingJavaScript = new List <string>();
            // Get evidence filters for all elements that have
            // JavaScript properties.
            var filters = _pipeline.FlowElements
                          .Where(e => e.Properties.Any(p =>
                                                       p.Type != null &&
                                                       p.Type == typeof(JavaScript)))
                          .Select(e => e.EvidenceKeyFilter);

            foreach (var filter in filters)
            {
                // If the filter is a white list or derived type then
                // get all HTTP header evidence keys from white list
                // and add them to the headers that could affect the
                // generated JavaScript.
                var whitelist = filter as EvidenceKeyFilterWhitelist;
                if (whitelist != null)
                {
                    headersAffectingJavaScript.AddRange(whitelist.Whitelist
                                                        .Where(entry => entry.Key.StartsWith(
                                                                   Core.Constants.EVIDENCE_HTTPHEADER_PREFIX + Core.Constants.EVIDENCE_SEPERATOR,
                                                                   StringComparison.OrdinalIgnoreCase))
                                                        .Select(entry => entry.Key.Substring(entry.Key.IndexOf(
                                                                                                 Core.Constants.EVIDENCE_SEPERATOR,
                                                                                                 StringComparison.OrdinalIgnoreCase) + 1)));
                }
            }
            _headersAffectingJavaScript = new StringValues(headersAffectingJavaScript.ToArray());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="pipeline"></param>
        /// <param name="flowDataProvider"></param>
        /// <param name="options"></param>
        public SetHeaderService(
            ILogger <SetHeaderService> logger,
            IPipeline pipeline,
            IFlowDataProvider flowDataProvider,
            IOptions <PipelineWebIntegrationOptions> options)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (pipeline == null)
            {
                throw new ArgumentNullException(nameof(pipeline));
            }
            if (flowDataProvider == null)
            {
                throw new ArgumentNullException(nameof(flowDataProvider));
            }

            _logger           = logger;
            _flowDataProvider = flowDataProvider;
            _options          = options;
        }
Ejemplo n.º 5
0
 public HomeController(IFlowDataProvider flowDataProvider)
 {
     // The flow data provider is injected here, so it can be used to
     // get a pre-processed flow data.
     _flowDataProvider = flowDataProvider;
 }
Ejemplo n.º 6
0
 public HomeController(IFlowDataProvider flow)
 {
     _flow = flow;
 }
Ejemplo n.º 7
0
 public ProcessController(IFlowDataProvider flow)
 {
     _flow = flow;
 }