コード例 #1
0
        private void InitSessionThings()
        {
            // Site Directory
            this.siteDirectory = new SiteDirectory(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri);

            this.domain = new DomainOfExpertise(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri)
            {
                Name = "domain"
            };
            this.siteDirectory.Domain.Add(domain);

            this.person = new Person(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri)
            {
                ShortName     = credentials.UserName,
                GivenName     = credentials.UserName,
                Password      = credentials.Password,
                DefaultDomain = domain,
                IsActive      = true
            };
            this.siteDirectory.Person.Add(this.person);

            var participant = new Participant(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri)
            {
                Person = person
            };

            participant.Domain.Add(domain);

            // Site Rld
            var siteReferenceDataLibrary =
                new SiteReferenceDataLibrary(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri)
            {
                ShortName = "Generic_RDL"
            };
            var quantityKindParamType = new SimpleQuantityKind(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri)
            {
                Name      = "m",
                ShortName = "m"
            };

            siteReferenceDataLibrary.ParameterType.Add(quantityKindParamType);

            // Model Rdl
            var modelReferenceDataLibrary =
                new ModelReferenceDataLibrary(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri)
            {
                RequiredRdl = siteReferenceDataLibrary
            };

            this.siteDirectory.SiteReferenceDataLibrary.Add(siteReferenceDataLibrary);

            // Iteration
            this.iteration = new Iteration(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri);
            var iterationSetup = new IterationSetup(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri);

            this.iteration.IterationSetup = iterationSetup;

            // Engineering Model & Setup
            var engineeringModel = new EngineeringModel(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri);

            engineeringModel.Iteration.Add(this.iteration);

            this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.session.Object.Assembler.Cache, this.session.Object.Credentials.Uri)
            {
                EngineeringModelIid = engineeringModel.Iid
            };
            engineeringModel.EngineeringModelSetup = this.engineeringModelSetup;
            this.engineeringModelSetup.RequiredRdl.Add(modelReferenceDataLibrary);
            this.engineeringModelSetup.IterationSetup.Add(iterationSetup);
            this.engineeringModelSetup.Participant.Add(participant);

            this.siteDirectory.Model.Add(engineeringModelSetup);

            this.sessionThings = new Dictionary <Guid, CDP4Common.DTO.Thing>
            {
                { this.siteDirectory.Iid, this.siteDirectory.ToDto() },
                { this.domain.Iid, this.domain.ToDto() },
                { this.person.Iid, this.person.ToDto() },
                { participant.Iid, participant.ToDto() },
                { siteReferenceDataLibrary.Iid, siteReferenceDataLibrary.ToDto() },
                { quantityKindParamType.Iid, quantityKindParamType.ToDto() },
                { modelReferenceDataLibrary.Iid, modelReferenceDataLibrary.ToDto() },
                { this.engineeringModelSetup.Iid, this.engineeringModelSetup.ToDto() },
                { this.iteration.Iid, this.iteration.ToDto() },
                { iterationSetup.Iid, iterationSetup.ToDto() },
                { engineeringModel.Iid, engineeringModel.ToDto() }
            };

            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(this.siteDirectory.Iid, null),
                                                       new Lazy <Thing>(() => this.siteDirectory));
            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(this.domain.Iid, null),
                                                       new Lazy <Thing>(() => this.domain));
            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(this.person.Iid, null),
                                                       new Lazy <Thing>(() => this.person));
            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(participant.Iid, null),
                                                       new Lazy <Thing>(() => participant));
            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(siteReferenceDataLibrary.Iid, null),
                                                       new Lazy <Thing>(() => siteReferenceDataLibrary));
            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(quantityKindParamType.Iid, null),
                                                       new Lazy <Thing>(() => quantityKindParamType));
            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(modelReferenceDataLibrary.Iid, null),
                                                       new Lazy <Thing>(() => modelReferenceDataLibrary));
            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(this.engineeringModelSetup.Iid, null),
                                                       new Lazy <Thing>(() => this.engineeringModelSetup));
            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null),
                                                       new Lazy <Thing>(() => this.iteration));
            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(iterationSetup.Iid, null),
                                                       new Lazy <Thing>(() => iterationSetup));
            this.session.Object.Assembler.Cache.TryAdd(new CacheKey(engineeringModel.Iid, null),
                                                       new Lazy <Thing>(() => engineeringModel));
        }