internal ServiceInstance(ServiceConfiguration configuration, ServiceEnvironment environment, ServiceInstance parentInstance)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (configuration.ConfigurationLevel == ServiceConfigurationLevel.Instance)
            {
                throw new ArgumentException("Cannot use an existing instance-level configuration to create a new instance. Use instance.Configuration.GetBaseConfiguration(..) instead.", "configuration");
            }

            ThrowExceptionOnError = false;

            this.Environment = environment;
            this.InstanceID  = Guid.NewGuid();
            if (parentInstance != null)
            {
                this.Configuration  = configuration.Derive(ServiceConfigurationLevel.Instance, parentInstance.Configuration);
                this.ParentInstance = parentInstance;
            }
            else
            {
                this.Configuration = configuration.Derive(ServiceConfigurationLevel.Instance, null);
            }

            if (String.IsNullOrEmpty(this.Configuration.HostName))
            {
                this.Configuration.HostName = Environment.EnvironmentConfiguration.DefaultHostName;
            }

            //((ILockable)this.Configuration).Lock();
        }
예제 #2
0
        public ServiceConfiguration DeriveConfiguration(ServiceConfiguration configuration)
        {
            if (configuration.ConfigurationLevel == ServiceConfigurationLevel.Instance)
            {
                throw new ServiceConfigurationException("Cannot derive from a service instance configuration.");
            }
            if (configuration.ConfigurationLevel == ServiceConfigurationLevel.Profile && configuration.Profile != this)
            {
                throw new ServiceConfigurationException("Cannot derive from the configuration because it is associated with a different profile. Derive from configuration.TemplateConfiguration instead.");
            }

            return(configuration.Derive(ServiceConfigurationLevel.Profile, this));
        }