Exemple #1
0
        /// <summary>Returns a resource type as specified by the test.</summary>
        /// <param name="metadata">The DSPMetadata to use.</param>
        /// <param name="typeSpecification">The type specification. If it's a string, then it means the name of the type to get. If it's a Type it means
        /// to return a primitive resource type of that type.</param>
        /// <returns>The ResourceType specified by the test.</returns>
        public static providers.ResourceType GetResourceTypeFromTestSpecification(this DSPMetadata metadata, object typeSpecification)
        {
            if (metadata == null)
            {
                return(null);
            }

            if (typeSpecification is Type)
            {
                return(providers.ResourceType.GetPrimitiveResourceType(typeSpecification as Type));
            }
            else
            {
                string typeName             = typeSpecification as string;
                providers.ResourceType type = metadata.GetResourceType(typeName);
                if (type == null)
                {
                    metadata.TryResolveResourceType(typeName, out type);
                }

                if (type == null)
                {
                    type = UnitTestsUtil.GetPrimitiveResourceTypes().FirstOrDefault(rt => rt.FullName == typeName);
                }

                if (type == null)
                {
                    type = UnitTestsUtil.GetPrimitiveResourceTypes().FirstOrDefault(rt => rt.Name == typeName);
                }

                return(type);
            }
        }
Exemple #2
0
        /// <summary>Returns list of all primitive resource types.</summary>
        /// <returns>All primitive resource types.</returns>
        public static IEnumerable <ResourceType> GetPrimitiveResourceTypes()
        {
            if (primitiveResourceTypes == null)
            {
                primitiveResourceTypes = UnitTestsUtil.GetPrimitiveResourceTypes();
            }

            return(primitiveResourceTypes);
        }