private static bool Validate(Type type)
 {
     if (type == null)
     {
         return(false);
     }
     if (type.IsArray)
     {
         MessageHandlerFactory.Validate(type.GetElementType());
     }
     else if (type.IsGenericType)
     {
         Type[] genericArguments = type.GetGenericArguments();
         int    i   = 0;
         int    num = genericArguments.Length;
         while (i < num)
         {
             MessageHandlerFactory.Validate(genericArguments[i]);
             i++;
         }
     }
     else if (type.GetType() == typeof(SerializeReader.UnknownType))
     {
         return(false);
     }
     return(true);
 }
 private void ProcessTypeConverter(object message, object tag)
 {
     MessageHandlerFactory.TypeConverter typeConverter = (MessageHandlerFactory.TypeConverter)message;
     if (typeConverter.Dictionary == null)
     {
         throw new ArgumentException("Dictionary is null.", "converter");
     }
     foreach (KeyValuePair <int, Type> keyValuePair in typeConverter.Dictionary)
     {
         int  key   = keyValuePair.Key;
         Type value = keyValuePair.Value;
         if (MessageHandlerFactory.Validate(value))
         {
             typeof(ClassInfo <>).MakeGenericType(new Type[]
             {
                 value
             }).GetProperty("CategoryId").SetValue(null, key, null);
             MessageHandlerFactory.Category category;
             MessageHandlerFactory.Handler  handler;
             if (this.categoryDict.TryGetValue(key, out category))
             {
                 if (!(category.type == value))
                 {
                     throw new InvalidOperationException(string.Format("CategoryId '{0}' is already used.", key));
                 }
             }
             else if (this.handlerDict.TryGetValue(value, out handler))
             {
                 if (!value.IsSealed || handler.packetHandler == null)
                 {
                     throw new InvalidOperationException(string.Format("'{0}' is not sealed.", value.AssemblyQualifiedName));
                 }
                 this.categoryDict.Add(key, new MessageHandlerFactory.Category
                 {
                     type          = value,
                     packetHandler = handler.packetHandler
                 });
             }
         }
     }
 }