Beispiel #1
0
        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);
            }
        }