Пример #1
0
 public Container(
     string id,
     string handle,
     IContainerUser user,
     IContainerDirectory directory,
     IContainerPropertyService propertyService,
     ILocalTcpPortManager tcpPortManager,
     JobObject jobObject,
     IContainerDiskQuota containerDiskQuota,
     IProcessRunner processRunner,
     IProcessRunner constrainedProcessRunner,
     ProcessHelper processHelper,
     Dictionary <string, string> defaultEnvironment,
     ContainerHostDependencyHelper dependencyHelper,
     BindMount[] bindMounts
     )
 {
     this.id                       = id;
     this.handle                   = handle;
     this.user                     = user;
     this.directory                = directory;
     this.propertyService          = propertyService;
     this.tcpPortManager           = tcpPortManager;
     this.jobObject                = jobObject;
     this.containerDiskQuota       = containerDiskQuota;
     this.processRunner            = processRunner;
     this.constrainedProcessRunner = constrainedProcessRunner;
     this.processHelper            = processHelper;
     this.dependencyHelper         = dependencyHelper;
     this.defaultEnvironment       = defaultEnvironment ?? new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
     this.currentState             = ContainerState.Active;
     this.bindMounts               = bindMounts;
 }
Пример #2
0
 public IContainer CreateContainer(string id,
                                   string handle,
                                   IContainerUser user,
                                   IContainerDirectory directory,
                                   IContainerPropertyService propertyService,
                                   ILocalTcpPortManager tcpPortManager,
                                   JobObject jobObject,
                                   IContainerDiskQuota containerDiskQuota,
                                   IProcessRunner processRunner,
                                   IProcessRunner constrainedProcessRunner,
                                   ProcessHelper processHelper,
                                   Dictionary <string, string> defaultEnvironment,
                                   ContainerHostDependencyHelper dependencyHelper,
                                   BindMount[] bindMounts)
 {
     return(new Container(
                id,
                handle,
                user,
                directory,
                propertyService,
                tcpPortManager,
                jobObject,
                containerDiskQuota,
                processRunner,
                constrainedProcessRunner,
                processHelper,
                defaultEnvironment,
                dependencyHelper,
                bindMounts
                ));
 }
            public IContainer CreateContainer(string id,
                                              string handle,
                                              IContainerUser user,
                                              IContainerDirectory directory,
                                              IContainerPropertyService propertyService,
                                              ILocalTcpPortManager tcpPortManager,
                                              JobObject jobObject,
                                              IContainerDiskQuota containerDiskQuota,
                                              IProcessRunner processRunner,
                                              IProcessRunner constrainedProcessRunner,
                                              ProcessHelper processHelper,
                                              Dictionary <string, string> defaultEnvironment,
                                              ContainerHostDependencyHelper dependencyHelper,
                                              BindMount[] bindMounts)
            {
                if (handle == "KnownBadHandle")
                {
                    var badContainer = Substitute.For <IContainer>();
                    badContainer.Handle.Returns("KnownBadHandle");
                    badContainer.When(x => x.Destroy()).Do(x => { if (destroyCount++ == 0)
                                                                  {
                                                                      throw new Exception();
                                                                  }
                                                           });

                    return(badContainer);
                }
                else
                {
                    return(new Container(
                               id,
                               handle,
                               user,
                               directory,
                               propertyService,
                               tcpPortManager,
                               jobObject,
                               containerDiskQuota,
                               processRunner,
                               constrainedProcessRunner,
                               processHelper,
                               defaultEnvironment,
                               dependencyHelper,
                               bindMounts
                               ));
                }
            }