System.Net.Configuration.SmtpNetworkElement.PostDeserialize C# (CSharp) Method

PostDeserialize() protected method

protected PostDeserialize ( ) : void
return void
        protected override void PostDeserialize()
        {
            // Perf optimization. If the configuration is coming from machine.config
            // It is safe and we don't need to check for permissions.
            if (EvaluationContext.IsMachineLevel)
                return;

            PropertyInformation portPropertyInfo = ElementInformation.Properties[ConfigurationStrings.Port];

            if (portPropertyInfo.ValueOrigin == PropertyValueOrigin.SetHere &&
                (int)portPropertyInfo.Value != (int)portPropertyInfo.DefaultValue)
            {
                try {
                    (new SmtpPermission(SmtpAccess.ConnectToUnrestrictedPort)).Demand();
                } catch (Exception exception) {
                    throw new ConfigurationErrorsException(
                                  SR.GetString(SR.net_config_property_permission, 
                                               portPropertyInfo.Name),
                                  exception);
                }
            }
        }