Beispiel #1
0
        public int EstimatedSizeInBytes(bool excludeDataBody)
        {
            // the calculated overhead is actually 1745 bytes, but we are allowing for
            // errors and variations in both the header and body fragments, of up to 250 bytes.
            const int bytesPerStringChar = 2;    // 16-bit Unicode strings
            int       result             = 2000; // overhead

            result += Name?.Length * bytesPerStringChar ?? 0;
            result += DataTypeName?.Length * bytesPerStringChar ?? 0;
            result += AppScope?.Length * bytesPerStringChar ?? 0;
            result += NetScope?.Length * bytesPerStringChar ?? 0;
            result += (AppProps.Serialise().Length *bytesPerStringChar);  // hack - slow - todo - use Text property
            result += (SysProps.Serialise().Length *bytesPerStringChar);  // hack - slow - todo - use Text property
            if (!excludeDataBody)
            {
                result += YData?.Length ?? 0;
                result += YSign?.Length ?? 0;
            }
            const int bufferBytesPerByte = 2;

            return(result * bufferBytesPerByte);
        }