コード例 #1
0
        static IEntityView BuildEntityView(int entityID, Dictionary <Type, ITypeSafeList> entityViewsByType,
                                           Type entityViewType, IEntityViewBuilder entityViewBuilder)
        {
            ITypeSafeList entityViewsList;

            var entityViewsPoolWillBeCreated =
                entityViewsByType.TryGetValue(entityViewType, out entityViewsList) == false;

            IEntityView entityViewObjectToFill;

            //passing the undefined entityViewsByType inside the entityViewBuilder will allow
            //it to be created with the correct type and casted back to the undefined list.
            //that's how the list will be eventually of the target type.
            entityViewBuilder.BuildEntityViewAndAddToList(ref entityViewsList, entityID, out entityViewObjectToFill);

            if (entityViewsPoolWillBeCreated)
            {
                entityViewsByType.Add(entityViewType, entityViewsList);
            }

            return(entityViewObjectToFill as IEntityView);
        }