예제 #1
0
        private void SerializeValueWithType(ValueWithType valueWithType)
        {
            string typeName = SystemExtensions.RemoveAssemblyInfo(valueWithType.TypeFullName);

            this.writer.Write(typeName);
            this.Serialize(valueWithType.Value, valueWithType.Type);
        }
예제 #2
0
        /// <summary>
        ///   <para>
        ///     Looks up the specified full type name in all loaded assemblies,
        ///     ignoring assembly version.
        ///   </para>
        ///   <para>
        ///     In order to understand how to access generic types,
        ///     see http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx.
        ///   </para>
        /// </summary>
        /// <param name="fullName">Full name of the type to find.</param>
        /// <returns>Type with the specified name.</returns>
        /// <exception cref="TypeLoadException">If the type couldn't be found.</exception>
        public static Type FindType(string fullName)
        {
            if (string.IsNullOrEmpty(fullName))
            {
                return(null);
            }

            // Split type name from .dll version.
            fullName = SystemExtensions.RemoveAssemblyInfo(fullName);

            Type t = Type.GetType(fullName);

            if (t != null)
            {
                return(t);
            }

            foreach (Assembly asm in AssemblyUtils.GetLoadedAssemblies())
            {
                t = asm.GetType(fullName);
                if (t != null)
                {
                    return(t);
                }
            }

            throw new TypeLoadException(string.Format("Unable to find type {0}.", fullName));
        }