Esempio n. 1
0
        private int EvalLength(ElementInstance parent, Stream stream, long stopAt)
        {
            int len = 0;

            if (Length == null)
            {
                Debug.Assert(stopAt >= stream.Position);
                len = (int)((stopAt - stream.Position) / DataElement.Size);
            }
            else
            {
                try
                {
                    len = Convert.ToInt32(Length);
                }
                catch (FormatException)
                {
                    IConvertible evalLen = parent.Eval(Length) as IConvertible;
                    if (evalLen != null)
                    {
                        len = evalLen.ToInt32(null);
                    }
                }
            }

            return len;
        }