Exemplo n.º 1
0
        public static void Insert <V>(this IMultiFieldValueMapper <V> mapper, IFileWriter writer)
            where V : class, new()
        {
            if (mapper.SignatureFieldMapper != null)
            {
                mapper.SignatureFieldMapper.Target = mapper.Value;
                mapper.SignatureFieldMapper.Insert(writer);
            }

            foreach (var f in mapper.FieldMappers)
            {
                f.Target = mapper.Value;
                f.Insert(writer);
            }
        }
Exemplo n.º 2
0
        public static ExtractStatus Extract <V>(this IMultiFieldValueMapper <V> mapper, IFileReader reader)
            where V : class, new()
        {
            ExtractStatus r = ExtractStatus.Failed;

            if (mapper.SignatureFieldMapper == null)
            {
                if (mapper.Value == null)
                {
                    mapper.Value = new V();
                }
            }
            else
            {
                mapper.SignatureFieldMapper.Target = mapper.Value;
                r = mapper.SignatureFieldMapper.Extract(reader);
                if (r != ExtractStatus.Success)
                {
                    return(r);
                }
                if (mapper.Value == null)
                {
                    mapper.Value = mapper.SignatureFieldMapper.Target;
                }
            }

            if (null == mapper.Value)
            {
                if (mapper.IsMandatory)
                {
                    throw new Exception(mapper.FieldInfo + "Mandatory field is empty.");
                }
            }
            else if (null != mapper.FieldMappers)
            {
                foreach (var f in mapper.FieldMappers)
                {
                    f.Target = mapper.Value;
                    r        = f.Extract(reader);
                    if (r != ExtractStatus.Success)
                    {
                        break;
                    }
                }
            }

            return(ExtractStatus.Success);
        }
Exemplo n.º 3
0
        private static ExtractStatus ExtractValues <V>(IMultiFieldValueMapper <V> mapper, IFileReader reader)
            where V : class, new()
        {
            ExtractStatus r = ExtractStatus.Success;

            if (null != mapper.FieldMappers)
            {
                foreach (var f in mapper.FieldMappers)
                {
                    f.Target = mapper.Value;
                    r        = f.Extract(reader);
                    if (r != ExtractStatus.Success)
                    {
                        break;
                    }
                }
            }
            return(r);
        }