#pragma warning restore CA1721 // Property names should not match get methods /// <summary> /// Get the <see cref="CloudRequestEngine"/> that will be making /// requests on behalf of this engine. /// </summary> public ICloudRequestEngine GetInstance() { if (_cloudRequestEngine == null) { lock (_cloudRequestEngineLock) { if (_cloudRequestEngine == null) { if (_pipelinesAccessor().Count > 1) { throw new PipelineConfigurationException( $"'{GetType().Name}' does not support being " + $"added to multiple Pipelines."); } if (_pipelinesAccessor().Count == 0) { throw new PipelineConfigurationException( $"'{GetType().Name}' has not yet been added " + $"to a Pipeline."); } _cloudRequestEngine = _pipelinesAccessor()[0].GetElement <ICloudRequestEngine>(); if (_cloudRequestEngine == null) { throw new PipelineConfigurationException( $"The '{GetType().Name}' requires a 'CloudRequestEngine' " + $"before it in the Pipeline. This engine will be unable " + $"to produce results until this is corrected."); } } } } return(_cloudRequestEngine); }
/// <summary> /// Get property meta data from the <see cref="CloudRequestEngine"/> /// for properties relating to this engine instance. /// This method will populate the <see cref="_aspectProperties"/> /// field. /// </summary> /// <remarks> /// There will be one <see cref="CloudRequestEngine"/> in a /// Pipeline that makes the actual web requests to the cloud service. /// One or more cloud aspect engines will take the response from these /// cloud requests and convert them into strongly typed objects. /// Given this model, the cloud aspect engines have no knowledge /// of which properties the <see cref="CloudRequestEngine"/> can /// return. /// They must extract the properties relevant to them from the /// meta-data for all properties that the /// <see cref="CloudRequestEngine"/> exposes. /// </remarks> /// <param name="engine"> /// The <see cref="CloudRequestEngine"/> from which to retrieve /// property meta-data. /// </param> /// <returns> /// True if the _aspectProperties has been successfully populated /// with the relevant property meta-data. /// False if something has gone wrong. /// </returns> private bool LoadAspectProperties(ICloudRequestEngine engine) { var dictionary = engine.PublicProperties; if (dictionary != null && dictionary.Count > 0 && dictionary.ContainsKey(ElementDataKey)) { _aspectProperties = new List <IAspectPropertyMetaData>(); _dataSourceTier = dictionary[ElementDataKey].DataTier; foreach (var item in dictionary[ElementDataKey].Properties) { var property = LoadProperty(item); if (property != null) { _aspectProperties.Add(property); } } return(_aspectProperties.Count > 0); } else { Logger.LogError($"Aspect properties could not be " + $"loaded for {GetType().Name}", this); return(false); } }