Ejemplo n.º 1
0
        public override int GetHashCode()
        {
            int hash = 1;

            hash ^= ObjectAddress.GetHashCode();
            hash ^= Status.GetHashCode();
            hash ^= ServiceHash.GetHashCode();
            hash ^= MethodId.GetHashCode();
            return(hash);
        }
Ejemplo n.º 2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (objectAddress_ != null)
            {
                hash ^= ObjectAddress.GetHashCode();
            }
            if (Status != 0)
            {
                hash ^= Status.GetHashCode();
            }
            if (ServiceHash != 0)
            {
                hash ^= ServiceHash.GetHashCode();
            }
            if (MethodId != 0)
            {
                hash ^= MethodId.GetHashCode();
            }
            return(hash);
        }
        public InterfaceHash AddInterface(ServiceHash serviceHash, Type iface)
        {
            // Hash all methods
            var methodHashes = iface.GetMethods()
                               .Select(m => new { Method = m, Hash = HashMethod(m) })
                               .ToList();

            // Hash all inherited interfaces
            var interfaceHashes = iface.GetInterfaces()
                                  .Select(i => new { Interface = i, Hash = AddInterface(serviceHash, i) });

            // Hash this interface, based on our methods and interfaces
            var interfaceHash = HashInterface(iface,
                                              methodHashes.Select(m => m.Hash),
                                              interfaceHashes.Select(i => i.Hash)
                                              );

            var descriptor = new RemoteProcedureDescriptor
            {
                ServiceHash   = serviceHash,
                InterfaceHash = interfaceHash
            };

            foreach (var method in methodHashes)
            {
                descriptor.MethodName      = method.Hash.Name;
                descriptor.MethodSignature = method.Hash.Signature;

                // We only need to add it once
                if (!_methods.ContainsKey(descriptor.ToGuid()))
                {
                    _methods.Add(descriptor.ToGuid(), Tuple.Create(iface, method.Method));
                }
            }

            Interfaces.Add(Tuple.Create(interfaceHash, iface));
            return(interfaceHash);
        }
Ejemplo n.º 4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ServiceName.Length != 0)
            {
                hash ^= ServiceName.GetHashCode();
            }
            if (MethodName.Length != 0)
            {
                hash ^= MethodName.GetHashCode();
            }
            if (FixedCallCost != 0)
            {
                hash ^= FixedCallCost.GetHashCode();
            }
            if (FixedPacketSize != 0)
            {
                hash ^= FixedPacketSize.GetHashCode();
            }
            if (VariableMultiplier != 0F)
            {
                hash ^= VariableMultiplier.GetHashCode();
            }
            if (Multiplier != 0F)
            {
                hash ^= Multiplier.GetHashCode();
            }
            if (RateLimitCount != 0)
            {
                hash ^= RateLimitCount.GetHashCode();
            }
            if (RateLimitSeconds != 0)
            {
                hash ^= RateLimitSeconds.GetHashCode();
            }
            if (MaxPacketSize != 0)
            {
                hash ^= MaxPacketSize.GetHashCode();
            }
            if (MaxEncodedSize != 0)
            {
                hash ^= MaxEncodedSize.GetHashCode();
            }
            if (Timeout != 0F)
            {
                hash ^= Timeout.GetHashCode();
            }
            if (CapBalance != 0)
            {
                hash ^= CapBalance.GetHashCode();
            }
            if (IncomePerSecond != 0F)
            {
                hash ^= IncomePerSecond.GetHashCode();
            }
            if (ServiceHash != 0)
            {
                hash ^= ServiceHash.GetHashCode();
            }
            if (MethodId != 0)
            {
                hash ^= MethodId.GetHashCode();
            }
            return(hash);
        }
 public InterfaceHash AddInterface <TInterface>(ServiceHash serviceHash)
 => AddInterface(serviceHash, typeof(TInterface));