예제 #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);
            }
        }
예제 #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);
        }
예제 #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);
        }