Пример #1
0
        public void Register(Type type, object id)
        {
            MessageTypeAttribute mta = new MessageTypeAttribute();

            mta.mIDType = this.IDType;
            mta.SetID(id);
            mta.Type = type;
            mNameTypes[mta.ID.ToString()] = mta;
            mTypeNames[type] = mta;
        }
Пример #2
0
        public void Register(params Assembly[] assemblies)
        {
            foreach (Assembly assembly in assemblies)
            {
                foreach (Type type in assembly.GetTypes())
                {
                    MessageTypeAttribute mta = type.GetTypeInfo().GetCustomAttribute <MessageTypeAttribute>();

                    if (mta != null)
                    {
                        if (mta.mIDType == this.IDType)
                        {
                            mta.SetID(type.Name);
                            mta.Type = type;
                            mNameTypes[mta.ID.ToString()] = mta;
                            mTypeNames[type] = mta;
                        }
                    }
                }
            }
        }
Пример #3
0
        public void WriteType(object data, PipeStream stream)
        {
            MessageTypeAttribute mta = GetMTA(data.GetType());

            switch (mta.mIDType)
            {
            case MessageIDType.BYTE:
                stream.Write((byte)mta.ID);
                break;

            case MessageIDType.INT:
                stream.Write((int)mta.ID);
                break;

            case MessageIDType.SHORT:
                stream.Write((short)mta.ID);
                break;

            case MessageIDType.STRING:
                stream.WriteShortUTF((string)mta.ID);
                break;
            }
        }