Ejemplo n.º 1
0
        public int Register(Type type)
        {
            var typeName = type.AssemblyQualifiedName;

            if (PacketInfo.TryGetValue(typeName, out var info))
            {
                return(info.Id);
            }
            else
            {
                var newId   = Interlocked.Increment(ref _lastId);
                var newInfo = new PacketTypeInfo()
                {
                    Id   = newId,
                    Type = type
                };

                PacketInfo[type.AssemblyQualifiedName] = newInfo;
                PacketLookup[newId] = newInfo;
                return(newId);
            }
        }