Beispiel #1
0
        public SbeType(XmlNode node)
        {
            this.Name          = node.Attributes["name"].Value;
            this.PrimitiveType = node.Attributes["primitiveType"] != null ? node.Attributes["primitiveType"].Value : "";
            if (node.Attributes["length"] != null)
            {
                this.Length = int.Parse(node.Attributes["length"].Value);
            }
            this.CharacterEncoding = node.Attributes["characterEncoding"] != null ? node.Attributes["characterEncoding"].Value : "";
            this.SemanticType      = node.Attributes["semanticType"] != null ? node.Attributes["semanticType"].Value : "";
            this.Description       = node.Attributes["description"] != null ? node.Attributes["description"].Value : "";
            this.Presence          = node.Attributes["presence"] != null ? node.Attributes["presence"].Value : "";
            this.ValueRef          = node.Attributes["valueRef"] != null ? node.Attributes["valueRef"].Value : "";
            if (node.Attributes["maxValue"] != null)
            {
                this.MaxValue = int.Parse(node.Attributes["maxValue"].Value);
            }
            this.Value = node.InnerText;

            if (!string.IsNullOrEmpty(this.ValueRef))
            {
                string toFind = this.ValueRef;

                if (this.ValueRef.Contains("."))
                {
                    toFind = this.ValueRef.Split('.')[0];
                }

                if (SbeLoader._Enums.Find(x => x.Name == toFind) != null)
                {
                    SbeEnum comp = SbeLoader._Enums.Find(x => x.Name == toFind);
                    if (comp.ValidValues.Find(x => x.Name == this.ValueRef.Split('.')[1]) != null)
                    {
                        this.Value = comp.ValidValues.Find(x => x.Name == this.ValueRef.Split('.')[1]).Value;
                    }
                }
            }
        }
Beispiel #2
0
        public SbeField(XmlNode node)
        {
            this.Value        = "";
            this.Name         = node.Attributes["name"].Value;
            this.Id           = node.Attributes["id"].Value;
            this.Type         = node.Attributes["type"] != null ? node.Attributes["type"].Value : "";
            this.SemanticType = node.Attributes["semanticType"] != null ? node.Attributes["semanticType"].Value : "";
            this.Presence     = node.Attributes["presence"] != null ? node.Attributes["presence"].Value : "";
            this.ValueRef     = node.Attributes["valueRef"] != null ? node.Attributes["valueRef"].Value : "";
            this.Offset       = node.Attributes["offset"] != null?int.Parse(node.Attributes["offset"].Value) : 0;

            this.DimensionType     = node.Attributes["dimensionType"] != null ? node.Attributes["dimensionType"].Value : "";
            this.CharacterEncoding = node.Attributes["characterEncoding"] != null ? node.Attributes["characterEncoding"].Value : "";

            if (!string.IsNullOrEmpty(this.DimensionType))
            {
                this.Type = this.DimensionType;
            }
            if (node.Attributes["blockLength"] != null)
            {
                this.BlockLength = int.Parse(node.Attributes["blockLength"].Value);
            }
            this.Fields = new List <SbeField>();

            if (this.Type.ToLower().Equals("groupsizeencoding"))
            {
                this.Value = "1";
            }

            if (node.ChildNodes.Count > 0)
            {
                foreach (XmlNode child in node.ChildNodes)
                {
                    this.Fields.Add(new SbeField(child));
                }
            }
            else if (SbeLoader._CompositeTypes.Find(x => x.Name == this.Type) != null)
            {
                SbeCompositeType comp = SbeLoader._CompositeTypes.Find(x => x.Name == this.Type);
                if (!this.Type.Contains("Encoding"))
                {
                    foreach (SbeType type in comp.Fields)
                    {
                        SbeField f = new SbeField();
                        f.Name          = type.Name;
                        f.Type          = type.PrimitiveType;
                        f.ValueRef      = type.ValueRef;
                        f.Presence      = type.Presence;
                        f.Value         = type.Value;
                        f.PrimitiveType = type.PrimitiveType;
                        if (this.Length == null)
                        {
                            f.Length = GetLengthByType(type.PrimitiveType);
                        }
                        this.Fields.Add(f);
                    }
                }
                else
                {
                    foreach (SbeType type in comp.Fields)
                    {
                        if (type.Name == "length")
                        {
                            SbeField f = new SbeField();
                            f.Name              = type.Name;
                            f.Type              = type.PrimitiveType;
                            f.PrimitiveType     = type.PrimitiveType;
                            f.ValueRef          = type.ValueRef;
                            f.Presence          = type.Presence;
                            f.Value             = type.Value;
                            f.Length            = type.MaxValue;
                            f.CharacterEncoding = type.CharacterEncoding;
                            this.Fields.Add(f);
                        }
                        else
                        {
                            SbeField f = new SbeField();
                            f.Name              = type.Name;
                            f.Type              = type.PrimitiveType;
                            f.PrimitiveType     = type.PrimitiveType;
                            f.ValueRef          = type.CharacterEncoding;
                            f.Presence          = type.Presence;
                            f.Value             = type.Value;
                            f.Length            = 0;
                            f.CharacterEncoding = type.CharacterEncoding;
                            this.Fields.Add(f);
                        }
                    }
                }
            }
            else if (SbeLoader._SimpleTypes.Find(x => x.Name == this.Type) != null)
            {
                SbeType comp = SbeLoader._SimpleTypes.Find(x => x.Name == this.Type);
                this.PrimitiveType     = comp.PrimitiveType;
                this.Presence          = comp.Presence;
                this.Value             = comp.Value;
                this.Length            = comp.Length;
                this.CharacterEncoding = comp.CharacterEncoding;
            }
            else if (SbeLoader._Enums.Find(x => x.Name == this.Type) != null)
            {
                SbeEnum comp = SbeLoader._Enums.Find(x => x.Name == this.Type);
                this.PrimitiveType = comp.EncodingType;
                if (this.Length == null)
                {
                    this.Length = GetLengthByType(this.PrimitiveType);
                }
            }

            if (!string.IsNullOrEmpty(this.ValueRef))
            {
                string toFind = this.ValueRef;

                if (this.ValueRef.Contains("."))
                {
                    toFind = this.ValueRef.Split('.')[0];
                }

                if (SbeLoader._Enums.Find(x => x.Name == toFind) != null)
                {
                    SbeEnum comp = SbeLoader._Enums.Find(x => x.Name == toFind);
                    if (comp.ValidValues.Find(x => x.Name == this.ValueRef.Split('.')[1]) != null)
                    {
                        this.Value = comp.ValidValues.Find(x => x.Name == this.ValueRef.Split('.')[1]).Value;
                    }
                }
            }

            if (this.Length == null)
            {
                this.Length = GetLengthByType(this.PrimitiveType);
            }
        }