private void AddCustomElementsOnElementCreate(SemanticModel_I semanticModel, TTypeElement element, Type type) { // put all of this into semantic model code base. object[] categorizedAttributes = XTypes.GetCustomAttributes(type); for (int i = 0; i < categorizedAttributes.Length; i++) { var categorizedAttribute = categorizedAttributes[i]; var attributeType = categorizedAttribute.GetType(); var attributeClass = (SemanticAttributeClass)semanticModel.GetOrCreateElement(attributeType); if (!attributeClass.ImplementingTypes.ContainsKey(element.TypeId.Value)) { attributeClass.ImplementingTypes.Add(element.TypeId.Value, element); } if (element.IsClass()) { if (!attributeClass.ImplementingClasses.ContainsKey(element.TypeId.Value)) { attributeClass.ImplementingClasses.Add(element.TypeId.Value, (SemanticClass_I)element); } } if (element.IsInterface()) { if (!attributeClass.ImplementingInterfaces.ContainsKey(element.TypeId.Value)) { attributeClass.ImplementingInterfaces.Add(element.TypeId.Value, (SemanticInterface_I)element); } } SemanticAttributeTypeMapping mapping = XNew.New <SemanticAttributeTypeMapping>(); mapping.ImplementingType = element; mapping.AttributeClass = attributeClass; mapping.Instance = categorizedAttribute; attributeClass.Instances.Add(mapping); } }
private void AddInterface(SemanticModel_I semanticModel, SemanticType_I implementingTypeSymbol, Type interfaceType) { var interfaceElement = (SemanticInterface_I)semanticModel.GetOrCreateElement(interfaceType); if (implementingTypeSymbol != null) { if (implementingTypeSymbol.IsClass()) { if (!interfaceElement.ImplementingClasses.TryGetValue(implementingTypeSymbol.TypeId.Value, out SemanticClass_I classSymbol)) { classSymbol = (SemanticClass_I)implementingTypeSymbol; interfaceElement.ImplementingClasses.Add(classSymbol.TypeId.Value, classSymbol); } } if (!interfaceElement.ImplementingTypes.TryGetValue(implementingTypeSymbol.TypeId.Value, out SemanticType_I existingTypeSymbol)) { interfaceElement.ImplementingTypes.Add(implementingTypeSymbol.TypeId.Value, implementingTypeSymbol); } } }