Ejemplo n.º 1
0
        /// <summary>
        /// Gets information about the remote host.
        /// Automatically creates and initializes a new instance of the HostInformation class when
        /// it is necessary.
        /// </summary>
        public HostInformation this[string uri]
        {
            get
            {
                lock (this.SyncRoot)
                {
                    HostInformation hostInformation = this.Get(uri);

                    if (hostInformation == null)
                    {
                        hostInformation = new HostInformation(uri, this.ITransportContext);
                        this.UpdateHost(uri, hostInformation);

                        // set a reasonable start up lifetime property value
                        int expiration = GenuineUtility.ConvertToMilliseconds(this.ITransportContext.IParameterProvider[GenuineParameter.ConnectTimeout]);
                        hostInformation.Renew(expiration, true);

                        // LOG:
                        BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter;
                        if (binaryLogWriter != null && binaryLogWriter[LogCategory.HostInformation] > 0)
                        {
                            binaryLogWriter.WriteEvent(LogCategory.HostInformation, "KnownHosts.this[string]",
                                                       LogMessageType.HostInformationCreated, null, null, hostInformation,
                                                       null,
                                                       GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name,
                                                       null, null, -1, 0, 0, 0, null, null, null, null,
                                                       "The HostInformation has been created for the remote host: {0}.", uri);
                        }
                    }
                    return(hostInformation);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Renews the host information.
        /// </summary>
        /// <param name="uriOrUrl">Uri or Url of the remote host.</param>
        /// <param name="timeSpan">The time period specified in milliseconds to renew host-related information.</param>
        /// <param name="canMakeShorter">Indicates whether this call may reduce the host expiration time.</param>
        public void Renew(string uriOrUrl, int timeSpan, bool canMakeShorter)
        {
            HostInformation hostInformation = null;

            hostInformation = this.Get(uriOrUrl);

            if (hostInformation != null)
            {
                hostInformation.Renew(timeSpan, canMakeShorter);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets information about the remote host.
        /// Automatically creates and initializes a new instance of the HostInformation class when
        /// it is necessary.
        /// </summary>
        public HostInformation this[string uri]
        {
            get
            {
                lock (this.SyncRoot)
                {
                    HostInformation hostInformation = this.Get(uri);

                    if (hostInformation == null)
                    {
                        hostInformation = new HostInformation(uri, this.ITransportContext);
                        this.UpdateHost(uri, hostInformation);

                        // set a reasonable start up lifetime property value
                        int expiration = GenuineUtility.ConvertToMilliseconds(this.ITransportContext.IParameterProvider[GenuineParameter.ConnectTimeout]);
                        hostInformation.Renew(expiration, true);

                        // LOG:
                        BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter;
                        if ( binaryLogWriter != null && binaryLogWriter[LogCategory.HostInformation] > 0 )
                            binaryLogWriter.WriteEvent(LogCategory.HostInformation, "KnownHosts.this[string]",
                                LogMessageType.HostInformationCreated, null, null, hostInformation,
                                null,
                                GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name,
                                null, null, -1, 0, 0, 0, null, null, null, null,
                                "The HostInformation has been created for the remote host: {0}.", uri);
                    }
                    return hostInformation;
                }
            }
        }