コード例 #1
0
 /// <summary>
 /// Creates a new default instance.
 /// </summary>
 public BrokerServiceLocator(Uri brokerServiceUri = null, IHashingHelper hashingHelper = null)
 {
     _hashingHelper       = hashingHelper ?? new HashingHelper();
     _fabricClient        = new FabricClient();
     _serviceProxyFactory = new ServiceProxyFactory(c => new FabricTransportServiceRemotingClientFactory());
     _brokerServiceUri    = brokerServiceUri;
 }
コード例 #2
0
 /// <summary>
 /// Creates a new default instance.
 /// </summary>
 public BrokerServiceLocator(Uri brokerServiceUri = null, IHashingHelper hashingHelper = null, IProxyFactories proxyFactories = null)
 {
     _hashingHelper    = hashingHelper ?? new HashingHelper();
     _fabricClient     = new FabricClient();
     _proxyFactories   = proxyFactories ?? new ProxyFactories();
     _brokerServiceUri = brokerServiceUri;
 }
コード例 #3
0
        /// <summary>
        /// Creates a new default instance.
        /// </summary>
        public BrokerServiceLocator(bool useRemotingV2 = false, IHashingHelper hashingHelper = null)
        {
            _hashingHelper = hashingHelper ?? new HashingHelper();
            _fabricClient  = new FabricClient();

#if NETSTANDARD2_0
            _serviceProxyFactory = new ServiceProxyFactory(c => new FabricTransportServiceRemotingClientFactory());
#else
            if (useRemotingV2)
            {
                _serviceProxyFactory = new ServiceProxyFactory(c => new FabricTransportServiceRemotingClientFactory());
            }
            else
            {
                _serviceProxyFactory = new ServiceProxyFactory();
            }
#endif
        }
コード例 #4
0
        /// <summary>
        /// Add fields to fingerprint
        /// </summary>
        public void AddFingerprint(IHashingHelper fingerprinter)
        {
            if (!string.IsNullOrEmpty(FingerprintSalt))
            {
                fingerprinter.Add(nameof(FingerprintSalt), FingerprintSalt);
            }

            if (SearchPathToolsHash.HasValue)
            {
                fingerprinter.Add(nameof(SearchPathToolsHash), SearchPathToolsHash.Value);
            }

            if (!MaskUntrackedAccesses)
            {
                fingerprinter.Add(nameof(MaskUntrackedAccesses), -1);
            }

            if (!NormalizeReadTimestamps)
            {
                fingerprinter.Add(nameof(NormalizeReadTimestamps), -1);
            }

            if (PipWarningsPromotedToErrors)
            {
                fingerprinter.Add(nameof(PipWarningsPromotedToErrors), 1);
            }

            if (ValidateDistribution)
            {
                fingerprinter.Add(nameof(ValidateDistribution), 1);
            }

            if (!string.IsNullOrEmpty(RequiredKextVersionNumber))
            {
                fingerprinter.Add(nameof(RequiredKextVersionNumber), RequiredKextVersionNumber);
            }

            if (ExplicitlyReportDirectoryProbes)
            {
                fingerprinter.Add(nameof(ExplicitlyReportDirectoryProbes), 1);
            }

            fingerprinter.Add(nameof(FingerprintVersion), (int)FingerprintVersion);
        }
コード例 #5
0
 public SignupModel(IHttpClientFactory clientFactory, IHashingHelper hashingHelper)
 {
     this.clientFactory = clientFactory;
     this.hashingHelper = hashingHelper;
     FormData           = new SignUpViewModel();
 }
コード例 #6
0
        /// <summary>
        /// Resolves the <see cref="ServicePartitionKey"/> to send the message to, based on message type.
        /// </summary>
        /// <param name="message">The message to publish</param>
        /// <param name="brokerServiceName"></param>
        /// <returns></returns>
        public static async Task <ServicePartitionKey> GetPartitionForMessageAsync(object message, Uri brokerServiceName, IHashingHelper hashingHelper = null)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (brokerServiceName == null)
            {
                throw new ArgumentNullException(nameof(brokerServiceName));
            }
            if (hashingHelper == null)
            {
                hashingHelper = new HashingHelper();
            }

            string messageTypeName = message.GetType().FullName;

            if (_cachedPartitions == null)
            {
                var fabricClient = new FabricClient();
                _cachedPartitions = await fabricClient.QueryManager.GetPartitionListAsync(brokerServiceName);
            }
            int hashCode;

            unchecked
            {
                hashCode = (int)hashingHelper.HashString(messageTypeName);
            }
            int index     = Math.Abs(hashCode % _cachedPartitions.Count);
            var partition = _cachedPartitions[index];

            if (partition.PartitionInformation.Kind != ServicePartitionKind.Int64Range)
            {
                throw new InvalidOperationException("Sorry, only Int64 Range Partitions are supported.");
            }

            var info = (Int64RangePartitionInformation)partition.PartitionInformation;
            var resolvedPartition = new ServicePartitionKey(info.LowKey);

            return(resolvedPartition);
        }