Giter VIP home page Giter VIP logo

Comments (1)

cleftheris avatar cleftheris commented on September 15, 2024

Though I managed to implement a feature while trying to achieve something like the description above, I found no easy way to support conditional values (Components) without at least a wrapper class (Element).

The reason behind this is essentialy that conditions are based upon other component values. This means that in order to know weather to deserialize and read a value one must search, deserialize and compare an other value (Component) residing on a different path. The `EdiReader advances its current position each time someone calls to Read from it so this is extremely inefficient in order to support any case because the reader would have to be able to seek back and forth for stuff.

Nevertheless, we have a nice working solution since release v1.0.8 where we enabled conditional Element classes instead! These do not compromise performance.

This enables the following scenario:

Say we got this EdiFact fragment and there is 4 DTM lines near the start. These lines may or may not be in the message and represent various date times , the first number after DTM is the field code which identifies the meaning of the line, the last line specifies the time zone - so the designer of the message unfortunately "overloaded" the meaning of DTM as is so common with legacy EDI. The challenge is that these are not really a segment in the message which would allow me to use a condition attribute to pull out the data into the relevant C# property.

But you can pull the data using a Conditional & Element class attributes with the following POCOS

    [EdiElement, EdiPath("DTM/0"), EdiCondition("137", Path = "DTM/0/0")]
    public class CreationDate
    {
        [EdiValue("9(3)", Path = "DTM/0/0")]
        public int Code { get; set; }
        [EdiValue("X(12)", Path = "DTM/0/1", Format = "yyyyMMddHHmm")]
        public DateTime Date { get; set; }
    }

    [EdiElement, EdiPath("DTM/0"), EdiCondition("ZZZ", Path = "DTM/0/0")]
    public class CreationZone
    {
        [EdiValue("X(3)", Path = "DTM/0/0")]
        public string Code { get; set; }
        [EdiValue("9(1)", Path = "DTM/0/1")]
        public int UtcOffset { get; set; }
    }

    public class Interchange
    {
        public List<Message> Messages { get; set; }
    }

    [EdiMessage]
    public class Message
    {
        public CreationDate CreationDate { get; set; }

        public CreationZone CreationZone { get; set; }
    }

from edi.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.