Пример #1
0
    /*
     * public bool Storable
     * {
     *  get;
     *  set;
     * }*/


    public override byte[] Compose()
    {
        var name = base.Compose();
        var pv   = ((byte)(Permission) << 1) | (Recordable ? 1 : 0);

        if (Inherited)
        {
            pv |= 0x80;
        }

        if (WriteAnnotation != null && ReadAnnotation != null)
        {
            var rexp = DC.ToBytes(ReadAnnotation);
            var wexp = DC.ToBytes(WriteAnnotation);
            return(new BinaryList()
                   .AddUInt8((byte)(0x38 | pv))
                   .AddUInt8((byte)name.Length)
                   .AddUInt8Array(name)
                   .AddUInt8Array(ValueType.Compose())
                   .AddInt32(wexp.Length)
                   .AddUInt8Array(wexp)
                   .AddInt32(rexp.Length)
                   .AddUInt8Array(rexp)
                   .ToArray());
        }
        else if (WriteAnnotation != null)
        {
            var wexp = DC.ToBytes(WriteAnnotation);
            return(new BinaryList()
                   .AddUInt8((byte)(0x30 | pv))
                   .AddUInt8((byte)name.Length)
                   .AddUInt8Array(name)
                   .AddUInt8Array(ValueType.Compose())
                   .AddInt32(wexp.Length)
                   .AddUInt8Array(wexp)
                   .ToArray());
        }
        else if (ReadAnnotation != null)
        {
            var rexp = DC.ToBytes(ReadAnnotation);
            return(new BinaryList()
                   .AddUInt8((byte)(0x28 | pv))
                   .AddUInt8((byte)name.Length)
                   .AddUInt8Array(name)
                   .AddUInt8Array(ValueType.Compose())
                   .AddInt32(rexp.Length)
                   .AddUInt8Array(rexp)
                   .ToArray());
        }
        else
        {
            return(new BinaryList()
                   .AddUInt8((byte)(0x20 | pv))
                   .AddUInt8((byte)name.Length)
                   .AddUInt8Array(name)
                   .AddUInt8Array(ValueType.Compose())
                   .ToArray());
        }
    }