private void validateSearchAndReturn() { if (!units.Keys.Contains(tbSearch.Text)) { lblError.Visible = true; } else { ResultType = units[tbSearch.Text]; this.DialogResult = DialogResult.OK; } }
/// <summary> /// Recursively fills the units dictionary with a TypeVisualisationUnit of the Guid - typeNodeId. /// </summary> /// <param name="typeNodeId"></param> /// <param name="units"></param> /// <param name="ignoreTypeNames"></param> private void GetTypeVisualUnitsRecursive(Guid typeNodeId, IDictionary <String, TypeVisualUnit> units, ICollection <string> ignoreTypeNames) { TypeVisualUnit unit = null; string typeName = null; ICollection <TypeVisualProperty> scalarProperties = new List <TypeVisualProperty>(); ICollection <TypeVisualProperty> nonScalarProperties = new List <TypeVisualProperty>(); if (!typeNodeId.Equals(Guid.Empty)) { var typeNode = provider.GetNode(typeNodeId, NodeAccess.Read); typeName = TypeVisualUtilities.GetTypeNameFromAssemblyName((string)typeNode.Data); if (!ignoreTypeNames.Contains(typeName)) { ignoreTypeNames.Add(typeName); foreach (var edge in typeNode.Edges.Values) { if (edge.Data.Semantic.Equals(EdgeType.Property)) { //setting name and type bool isScalar; var nodeProperty = provider.GetNode(edge.ToNodeId, NodeAccess.Read); var nodePropertyType = provider.GetNode(nodeProperty.Edges.Values[0].ToNodeId, NodeAccess.Read); string propertyTypeName = TypeVisualUtilities.GetTypeNameFromAssemblyName((string)nodePropertyType.Data); string collectionKey, collectionValue; PropertyCollectionType collectionType = TypeVisualUtilities.CheckIfCollectionOrDictionary(propertyTypeName, out collectionKey, out collectionValue); //checking if property is a collection and if property is scalar. if (collectionType != PropertyCollectionType.NotACollection) { if (!typesService.IsSupportedScalarTypeName(collectionValue)) { Guid genericArgumentTypeId = GetIdFromTypeName(collectionValue); if (!genericArgumentTypeId.Equals(Guid.Empty)) { //ignoreTypeNames.Add(typeName); GetTypeVisualUnitsRecursive(genericArgumentTypeId, units, ignoreTypeNames); } isScalar = false; } else { isScalar = true; } propertyTypeName = collectionValue; } else if (!typesService.IsSupportedScalarTypeName(propertyTypeName)) { //ignoreTypeNames.Add(typeName); GetTypeVisualUnitsRecursive(nodeProperty.Edges.Values[0].ToNodeId, units, ignoreTypeNames); isScalar = false; } else { isScalar = true; } //setting additional property attributes bool isImmutable, isPrimaryKey; PropertyAttribute propAttribute; isImmutable = edge.Data.Flags.Equals(EdgeFlags.Permanent); isPrimaryKey = nodeProperty.Values.ContainsKey(Constants.TypeMemberPrimaryKeyId); if (isImmutable && isPrimaryKey) { propAttribute = PropertyAttribute.PrimaryKeyAndImmutableProperty; } else if (isImmutable) { propAttribute = PropertyAttribute.ImmutableProperty; } else if (isPrimaryKey) { propAttribute = PropertyAttribute.PrimaryKeyProperty; } else { propAttribute = PropertyAttribute.None; } //adding the property to either scalar or non-scalar lists. TypeVisualProperty property = new TypeVisualProperty((string)nodeProperty.Data, propertyTypeName, propAttribute, collectionType, collectionKey); if (isScalar) { scalarProperties.Add(property); } else { nonScalarProperties.Add(property); } } else if (edge.Data.Semantic.Equals(EdgeType.Contains)) { var nodeProperty = provider.GetNode(edge.ToNodeId, NodeAccess.Read); TypeVisualProperty property = new TypeVisualProperty((string)nodeProperty.Data, TypeVisualProperty.EnumType, PropertyAttribute.None, PropertyCollectionType.NotACollection, ""); scalarProperties.Add(property); } } unit = new TypeVisualUnit(typeName, scalarProperties, nonScalarProperties); units.Add(unit.Name, unit); } } }
private void changeCurrentTypeAndRefreshLists(TypeVisualUnit currentType) { CurrentType = currentType; tbCurrentType.Text = CurrentType.ToString(); fillListBoxes(); }