/// <summary> /// Queries the human readable name of the <see cref="DatatypeDefinition"/> /// </summary> /// <param name="datatypeDefinition"> /// The subject <see cref="DatatypeDefinition"/> /// </param> /// <returns> /// A human readable name (Boolean, Date, Enumeration, Integer, Real, String, XHTML). /// </returns> /// <exception cref="InvalidOperationException"> /// thrown when the specified <see cref="DatatypeDefinition"/> is not supported /// </exception> public static string QueryDatatypeName(this DatatypeDefinition datatypeDefinition) { switch (datatypeDefinition) { case DatatypeDefinitionBoolean: return("Boolean"); case DatatypeDefinitionDate: return("Date"); case DatatypeDefinitionEnumeration: return("Enumeration"); case DatatypeDefinitionInteger: return("Integer"); case DatatypeDefinitionReal: return("Real"); case DatatypeDefinitionString: return("String"); case DatatypeDefinitionXHTML: return("XHTML"); default: throw new InvalidOperationException(""); } }
/// <summary> /// Initializes a new instance of the <see cref="DatatypeDefinitionMap"/> class /// </summary> /// <param name="datatypeDef">The <see cref="DatatypeDef"/></param> /// <param name="parameterType">The <see cref="AttributeDefinitionMapKind"/> specifying the king of mapping of the <see cref="DatatypeDef"/></param> /// <param name="enumValueMap">The <see cref="EnumValue"/> map</param> public DatatypeDefinitionMap(DatatypeDefinition datatypeDef, ParameterType parameterType, IReadOnlyDictionary <EnumValue, EnumerationValueDefinition> enumValueMap) { this.DatatypeDef = datatypeDef; this.ParameterType = parameterType; this.EnumValueMap = enumValueMap != null?enumValueMap.ToDictionary(x => x.Key, x => x.Value) : new Dictionary <EnumValue, EnumerationValueDefinition>(); }
public void Setup() { this.session = new Mock <ISession>(); this.dialogNavigationService = new Mock <IDialogNavigationService>(); this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>(); this.permissionService = new Mock <IPermissionService>(); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.assembler = new Assembler(this.uri); this.sitedir = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri); this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri); this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri) { RequiredRdl = this.srdl }; this.sitedir.SiteReferenceDataLibrary.Add(this.srdl); this.modelsetup.RequiredRdl.Add(this.mrdl); this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri) { IterationSetup = this.iterationSetup }; this.sitedir.Model.Add(this.modelsetup); this.modelsetup.IterationSetup.Add(this.iterationSetup); this.sitedir.Domain.Add(this.domain); this.model.Iteration.Add(this.iteration); this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri); this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri) { Person = this.person }; this.sitedir.Person.Add(this.person); this.modelsetup.Participant.Add(this.participant); this.pt = new BooleanParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri); this.srdl.ParameterType.Add(this.pt); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant) } }); this.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration)); this.reqIf = new ReqIF(); this.reqIf.Lang = "en"; var corecontent = new ReqIFContent(); this.reqIf.CoreContent.Add(corecontent); this.datatypedef = new DatatypeDefinitionString(); this.spectype = new SpecificationType(); this.specobjecttype = new SpecObjectType(); corecontent.DataTypes.Add(this.datatypedef); corecontent.SpecTypes.Add(this.spectype); corecontent.SpecTypes.Add(this.specobjecttype); this.importMappingManager = new ReqIfImportMappingManager( this.reqIf, this.session.Object, this.iteration, this.domain, this.dialogNavigationService.Object, this.thingDialogNavigationService.Object); }
protected override void SetDatatypeDefinition(DatatypeDefinition datatypeDefinition) { throw new NotImplementedException(); }
/// <summary> /// Queries the <see cref="AttributeDefinition"/>s that are referencing the <see cref="DatatypeDefinition"/> /// </summary> /// <param name="datatypeDefinition"> /// The subject <see cref="DatatypeDefinition"/> /// </param> /// <returns> /// An <see cref="IEnumerable{AttributeDefinition}"/> that are referencing the <see cref="DatatypeDefinition"/> /// </returns> public static IEnumerable <AttributeDefinition> QueryReferencingAttributeDefinitions(this DatatypeDefinition datatypeDefinition) { var result = new HashSet <AttributeDefinition>(); var spectypes = datatypeDefinition.ReqIFContent.SpecTypes; foreach (var spectype in spectypes) { var attributeDefinitions = spectype.SpecAttributes.Where(x => x.DatatypeDefinition == datatypeDefinition); foreach (var attributeDefinition in attributeDefinitions) { result.Add(attributeDefinition); } } return(result); }
/// <summary> /// Sets the <see cref="DatatypeDefinition"/> /// </summary> /// <param name="datatypeDefinition"> /// The instance of <see cref="DatatypeDefinition"/> that is to be set. /// </param> protected abstract void SetDatatypeDefinition(DatatypeDefinition datatypeDefinition);