Esempio n. 1
0
        public MessageDefinition GetDefinition(Type type)
        {
            var result            = new MessageDefinition();
            var messageDefinition = type.GetTypeInfo().GetCustomAttribute <MessageAttribute>();

            if (messageDefinition != null)
            {
                result.MessageId = !string.IsNullOrWhiteSpace(messageDefinition.MessageId) ? messageDefinition.MessageId : type.Name;
            }
            if (messageDefinition != null)
            {
                result.AccessGroup = messageDefinition.Group;
            }
            return(result);
        }
Esempio n. 2
0
        public long CreateMessageHash(MessageDefinition messageDefinition)
        {
            var messageId = messageDefinition.MessageId;

            if (string.IsNullOrWhiteSpace(messageId))
            {
                return(0);
            }
            long result = messageId[0];

            for (int i = 1; i < messageId.Length; i++)
            {
                var w = hashTable[i % hashTable.Length];
                result ^= (messageId[i] % w) * (messageId[i - 1] * w);
            }
            return(result);
        }