@@ -98,48 +98,36 @@ public interface ICachedEntityFactory<Initializer, Entity> where Entity : ICache
9898 public static class ICachedEntityFactoryExtensions
9999 {
100100 public static Entity CreateEntity < Entity , T1 , T2 > ( this ICachedEntityFactory < ( T1 , T2 ) , Entity > factory , Context cx , T1 t1 , T2 t2 )
101- where Entity : ICachedEntity
102- {
103- return factory . CreateEntity ( cx , ( t1 , t2 ) ) ;
104- }
101+ where Entity : ICachedEntity => factory . CreateEntity2 ( cx , ( t1 , t2 ) ) ;
105102
106103 public static Entity CreateEntity < Entity , T1 , T2 , T3 > ( this ICachedEntityFactory < ( T1 , T2 , T3 ) , Entity > factory , Context cx , T1 t1 , T2 t2 , T3 t3 )
107- where Entity : ICachedEntity
108- {
109- return factory . CreateEntity ( cx , ( t1 , t2 , t3 ) ) ;
110- }
104+ where Entity : ICachedEntity => factory . CreateEntity2 ( cx , ( t1 , t2 , t3 ) ) ;
111105
112106 public static Entity CreateEntity < Entity , T1 , T2 , T3 , T4 > ( this ICachedEntityFactory < ( T1 , T2 , T3 , T4 ) , Entity > factory , Context cx , T1 t1 , T2 t2 , T3 t3 , T4 t4 )
113- where Entity : ICachedEntity
114- {
115- return factory . CreateEntity ( cx , ( t1 , t2 , t3 , t4 ) ) ;
116- }
107+ where Entity : ICachedEntity => factory . CreateEntity2 ( cx , ( t1 , t2 , t3 , t4 ) ) ;
117108
118109 /// <summary>
119- /// Creates a new entity or returns the existing one from the cache.
110+ /// Creates and populates a new entity, or returns the existing one from the cache.
120111 /// </summary>
121112 /// <typeparam name="Type">The symbol type used to construct the entity.</typeparam>
122113 /// <typeparam name="Entity">The type of the entity to create.</typeparam>
123114 /// <param name="cx">The extractor context.</param>
124115 /// <param name="factory">The factory used to construct the entity.</param>
125- /// <param name="t ">The initializer for the entity.</param>
126- /// <returns></returns>
116+ /// <param name="init ">The initializer for the entity, which may not be null .</param>
117+ /// <returns>The entity. </returns>
127118 public static Entity CreateEntity < Type , Entity > ( this ICachedEntityFactory < Type , Entity > factory , Context cx , Type init )
128- where Entity : ICachedEntity
129- {
130- using ( cx . StackGuard )
131- {
132- var entity = factory . Create ( cx , init ) ;
133- if ( cx . GetOrAddCachedLabel ( entity ) )
134- return entity ;
135-
136- if ( ! entity . NeedsPopulation )
137- return entity ;
138-
139- cx . Populate ( init as ISymbol , entity ) ;
140-
141- return entity ;
142- }
143- }
119+ where Entity : ICachedEntity => cx . CreateEntity ( factory , init ) ;
120+
121+ /// <summary>
122+ /// Creates and populates a new entity, but uses a different cache.
123+ /// </summary>
124+ /// <typeparam name="Type">The symbol type used to construct the entity.</typeparam>
125+ /// <typeparam name="Entity">The type of the entity to create.</typeparam>
126+ /// <param name="cx">The extractor context.</param>
127+ /// <param name="factory">The factory used to construct the entity.</param>
128+ /// <param name="init">The initializer for the entity, which may be null.</param>
129+ /// <returns>The entity.</returns>
130+ public static Entity CreateEntity2 < Type , Entity > ( this ICachedEntityFactory < Type , Entity > factory , Context cx , Type init )
131+ where Entity : ICachedEntity => cx . CreateEntity2 ( factory , init ) ;
144132 }
145133}
0 commit comments