Example #1
0
        /// <summary>
        /// Gets the information about a type that would help serializer.
        /// Fetches the data from a dictionary if they were processed before.
        /// </summary>
        /// <param name="type">The type to be processed.</param>
        /// <returns>The processed data about the type passed as argument.</returns>
        public static TypeInfoPreprocessed GetTypeInfo(Type type)
        {
            if (TypeInfoDictionary.ContainsKey(type))
            {
                return(TypeInfoDictionary[type]);
            }

            var typeInfo = new TypeInfoPreprocessed(type);

            TypeInfoDictionary.Add(type, typeInfo);
            return(typeInfo);
        }
Example #2
0
        /// <summary>
        /// Gets the information about a type that would help serializer.
        /// Fetches the data from a dictionary if they were processed before.
        /// </summary>
        /// <param name="type">The type to be processed.</param>
        /// <returns>The processed data about the type passed as argument.</returns>
        public static TypeInfoPreprocessed GetTypeInfo(Type type)
        {
            TypeInfoPreprocessed typeInfo;

            // Need to lock the dictionary since it is a static property and there might be multiple corpus running on the same environment.
            lock (TypeInfoDictionary)
            {
                if (TypeInfoDictionary.ContainsKey(type))
                {
                    return(TypeInfoDictionary[type]);
                }

                typeInfo = new TypeInfoPreprocessed(type);
                TypeInfoDictionary.Add(type, typeInfo);
            }
            return(typeInfo);
        }