Example #1
0
        public SemanticType_I GetOrCreateElement(SemanticModel_I model, Type type)
        {
            //SemanticType_I typeSymbol;

            if (XTypes.IsClass(type))
            {
                // Get the long id associated with the type handle; by having this abstraction the semantic model can be built without having to
                // rely on runtime types.  Runtime types though can still be mapped to the semantic model.
                return(Classes.GetOrCreateElement(model, type));
            }
            else if (XTypes.IsInterface(type))
            {
                // Get the long id associated with the type handle; by having this abstraction the semantic model can be built without having to
                // rely on runtime types.  Runtime types though can still be mapped to the semantic model.
                return(Interfaces.GetOrCreateElement(model, type));
            }
            else if (XTypes.IsEnum(type))
            {
                // Get the long id associated with the type handle; by having this abstraction the semantic model can be built without having to
                // rely on runtime types.  Runtime types though can still be mapped to the semantic model.
                return(Enums.GetOrCreateElement(model, type));
            }
            else if (XTypes.IsValueType(type))
            {
                // Get the long id associated with the type handle; by having this abstraction the semantic model can be built without having to
                // rely on runtime types.  Runtime types though can still be mapped to the semantic model.
                return(ValueTypes.GetOrCreateElement(model, type));
            }
            else if (XTypes.IsDelegate(type))
            {
                // Get the long id associated with the type handle; by having this abstraction the semantic model can be built without having to
                // rely on runtime types.  Runtime types though can still be mapped to the semantic model.
                return(Delegates.GetOrCreateElement(model, type));
            }
            else if (XTypes.IsArray(type))
            {
                // Get the long id associated with the type handle; by having this abstraction the semantic model can be built without having to
                // rely on runtime types.  Runtime types though can still be mapped to the semantic model.
                return(Arrays.GetOrCreateElement(model, type));
            }
            else if (XTypes.IsPointer(type))
            {
                // Get the long id associated with the type handle; by having this abstraction the semantic model can be built without having to
                // rely on runtime types.  Runtime types though can still be mapped to the semantic model.
                return(Pointers.GetOrCreateElement(model, type));
            }
            else
            {
                XLog.LogWarning(new CannotMatchQualifiedNameToClassLogMessage()
                {
                    Message = new Message()
                    {
                        Value = $"Could not match type '{type.AssemblyQualifiedName}' to an class, interface, enum, struct, delegate, array or pointer.  Could not add it to the semantic model on scan."
                    }
                });

                return(null);
            }
        }