示例#1
0
文件: Router.cs 项目: fuding/yupi
        private void LoadComposers()
        {
            Outgoing = new Dictionary <Type, IComposer>();

            IEnumerable <Type> composers = GetImplementing <IComposer>();

            foreach (Type composerType in composers)
            {
                short id = library.GetOutgoingId(composerType.Name);

                if (id > 0)
                {
                    IComposer composer = (IComposer)Activator.CreateInstance(composerType);
                    composer.Init(id, pool);

                    // TODO Remove one Add
                    Outgoing.Add(composerType, composer);
                    if (composerType.BaseType.Namespace.StartsWith("Yupi.Messages.Contracts") &&
                        !composerType.BaseType.Name.StartsWith("AbstractComposer"))
                    {
                        Outgoing.Add(composerType.BaseType, composer);
                    }
                }
            }
        }