示例#1
0
        public void EntityLinkExtractor_Returns_ElasticEntityLink()
        {
            var extractor = new EntityLinkExtractor();
            var actual    = extractor.GetValue(dataElements, "1004");

            actual.Value.Should().Be("Test");
            actual.EntityRecordId.Should().Be("100");
            actual.EntityType.Should().Be("type");
        }
        private object GetValue(List <DataElement> detailData, FieldConfiguration fieldConfiguration)
        {
            object retVal = null;

            try
            {
                switch (fieldConfiguration.Type)
                {
                case ElasticFieldTypes.TypeString:
                    var textExtractor = new TextExtractor();
                    retVal = GetValue(detailData, fieldConfiguration, textExtractor);
                    break;

                case ElasticFieldTypes.TypeTimePeriod:
                    var timePeriodExtractor = new TimePeriodExtractor();
                    retVal = GetValue(detailData, fieldConfiguration, timePeriodExtractor);
                    break;

                case ElasticFieldTypes.TypeDateWithYear:
                    var dateWithYearExtractor = new DateWithYearExtractor();
                    retVal = GetValue(detailData, fieldConfiguration, dateWithYearExtractor);
                    break;

                case ElasticFieldTypes.TypeBase64:
                    var elasticBase64Extractor = new Base64Extractor();
                    retVal = GetValue(detailData, fieldConfiguration, elasticBase64Extractor);
                    break;

                case ElasticFieldTypes.TypeInt + "?":
                case ElasticFieldTypes.TypeInt:
                    var intExtractor = new IntExtractor();
                    retVal = GetValue(detailData, fieldConfiguration, intExtractor);
                    break;

                case ElasticFieldTypes.TypeBool + "?":
                case ElasticFieldTypes.TypeBool:
                    var boolExtractor = new BoolExtractor();
                    retVal = GetValue(detailData, fieldConfiguration, boolExtractor);
                    break;

                case ElasticFieldTypes.TypeFloat + "?":
                case ElasticFieldTypes.TypeFloat:
                    var floatExtractor = new FloatExtractor();
                    retVal = GetValue(detailData, fieldConfiguration, floatExtractor);
                    break;

                case ElasticFieldTypes.TypeHyperlink:
                    var hyperlinkExtractor = new HyperlinkExtractor();
                    retVal = GetValue(detailData, fieldConfiguration, hyperlinkExtractor);
                    break;

                case ElasticFieldTypes.TypeEntityLink:
                    var entityLinkExtractor = new EntityLinkExtractor();
                    retVal = GetValue(detailData, fieldConfiguration, entityLinkExtractor);
                    break;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                throw;
            }

            return(retVal);
        }