Exemplo n.º 1
0
        public static Type Load(string typeNameString)
        {
            TypeName typeName = null;

            try {
                typeName = TypeNameParser.Parse(typeNameString);
            }
            catch (Exception) {
                throw new PersistenceException(String.Format(
                                                   "Could not parse type string \"{0}\"",
                                                   typeNameString));
            }

            try {
                // try to load type normally
                return(LoadInternal(typeName));
            }
            catch (PersistenceException) {
                #region Mono Compatibility
                // if that fails, try to convert to the corresponding Mono or .NET type
                if (MonoInstalled)
                {
                    typeName = GetMonoType(typeName);
                    Logger.Info(String.Format(@"Trying to load Mono type ""{0}"" instead of .NET type ""{1}""",
                                              typeName, typeNameString));
                }
                else
                {
                    typeName = GetDotNetType(typeName);
                    Logger.Info(String.Format(@"Trying to load .NET type ""{0}"" instead of Mono type ""{1}""",
                                              typeName, typeNameString));
                }
                return(LoadInternal(typeName));

                #endregion
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get an assembly qualified name withough version information.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <returns>A full type name without version information.</returns>
 public static string VersionInvariantName(this Type type)
 {
     return(TypeNameParser.Parse(type.AssemblyQualifiedName).ToString(false));
 }