Ejemplo n.º 1
0
        public static Implement.TypeMapper GetMessageMapping()
        {
            if (mTypeMapper == null)
            {
                mTypeMapper = new Implement.TypeMapper();

                LoadAssembly(a =>
                {
                    foreach (Type type in a.GetTypes())
                    {
                        MessageIDAttribute[] msgid = IKendeCore.GetTypeAttributes <MessageIDAttribute>(type, false);
                        if (msgid.Length > 0)
                        {
                            mTypeMapper.Register(msgid[0].ID, type);
                            Type lstType = Type.GetType("System.Collections.Generic.List`1");
                            if (lstType != null)
                            {
                                Type gLstType = lstType.MakeGenericType(type);
                                mTypeMapper.Register((short)(0 - msgid[0].ID), gLstType);
                            }
                        }
                        foreach (TypeMappingAttribute tm in IKendeCore.GetTypeAttributes <TypeMappingAttribute>(type, false))
                        {
                            mTypeMapper.Register(tm.MessageID, tm.Type);
                        }
                    }
                });
            }
            return(mTypeMapper);
        }