private ResolutionProduct CreateResolutionProduct( IReadOnlyList <InstanceProduct> filteredInstanceProducts, DpdtArgumentWrapperTypeEnum wrapperType, ITypeSymbol wrapperSymbol ) { var interfaceProduct = new NamedGeneric1Interface( GN.IResolution, wrapperSymbol ); var interfaceFastProduct = new NamedGeneric1Interface( GN.IResolutionFast, wrapperSymbol ); #region get var getMethodProduct = CreateGetMethod( filteredInstanceProducts, wrapperType, wrapperSymbol ); var getExplicitMethodProduct = CreateExplicitMethod( "Get", getMethodProduct, wrapperType, wrapperSymbol ); var canBeImplicitelyCastedToObject = wrapperSymbol.IsReferenceType; var nonGenericGetProduct = new CreateTupleProduct( new TypeTypePair ( _typeInfoProvider.SystemType(), wrapperSymbol ), new TypeStringPair ( _typeInfoProvider.Func( _typeInfoProvider.GetTypeByMetadataName(typeof(IResolutionRequest).FullName !) !, _typeInfoProvider.Object() ! ), canBeImplicitelyCastedToObject ? getMethodProduct.MethodName : $"(r) => {getMethodProduct.MethodName}(r)" ) ); #endregion #region get all var getAllMethodProduct = CreateGetAllMethod( filteredInstanceProducts, wrapperType, wrapperSymbol ); var getAllExplicitMethodProduct = CreateExplicitMethod( "GetAll", getAllMethodProduct, wrapperType, wrapperSymbol ); var nonGenericGetAllProduct = new CreateTupleProduct( new TypeTypePair ( _typeInfoProvider.SystemType(), wrapperSymbol ), new TypeStringPair ( _typeInfoProvider.Func( _typeInfoProvider.GetTypeByMetadataName(typeof(IResolutionRequest).FullName !) !, _typeInfoProvider.Object() ! ), canBeImplicitelyCastedToObject ? getAllMethodProduct.MethodName : $"(r) => {getAllMethodProduct.MethodName}(r)" ) ); #endregion #region get fast var getFastMethodProduct = MethodProductFactory.Create( nameof(IResolutionFast <object> .GetFast), new TypeMethodResult(wrapperSymbol), (methodName, returnType) => { return($@" {GN.AggressiveInlining} public {returnType} {methodName}({returnType} unused) {{ return {getMethodProduct.MethodName}( null ); }} "); } ); #endregion var resolutionProduct = new ResolutionProduct( interfaceProduct, interfaceFastProduct, getMethodProduct, getExplicitMethodProduct, nonGenericGetProduct, getAllMethodProduct, getAllExplicitMethodProduct, nonGenericGetAllProduct, getFastMethodProduct ); return(resolutionProduct); }
private ResolutionProduct CreateResolutionProduct( IReadOnlyList <InstanceProduct> filteredInstanceProducts, DpdtArgumentWrapperTypeEnum wrapperType, ITypeSymbol wrapperSymbol ) { var interfaceProduct = new InterfaceProduct( $"{nameof(IResolution<object>)}<{wrapperSymbol.ToDisplayString()}>" ); var interfaceFastProduct = new InterfaceProduct( $"{nameof(IResolutionFast<object>)}<{wrapperSymbol.ToDisplayString()}>" ); #region get var getMethodProduct = CreateGetMethod( filteredInstanceProducts, wrapperType, wrapperSymbol ); var getExplicitMethodProduct = CreateExplicitMethod( "Get", getMethodProduct, wrapperType, wrapperSymbol ); var nonGenericGetProduct = new CreateTupleProduct( ( _typeInfoProvider.SystemType(), $"typeof({wrapperSymbol.ToDisplayString()})" ), ( _typeInfoProvider.Func( _typeInfoProvider.GetTypeByMetadataName(typeof(IResolutionRequest).FullName !) !, _typeInfoProvider.Object() ! ), getMethodProduct.MethodName ) ); #endregion #region get all var getAllMethodProduct = CreateGetAllMethod( filteredInstanceProducts, wrapperType, wrapperSymbol ); var getAllExplicitMethodProduct = CreateExplicitMethod( "GetAll", getAllMethodProduct, wrapperType, wrapperSymbol ); var nonGenericGetAllProduct = new CreateTupleProduct( ( _typeInfoProvider.SystemType(), $"typeof({wrapperSymbol.ToDisplayString()})" ), ( _typeInfoProvider.Func( _typeInfoProvider.GetTypeByMetadataName(typeof(IResolutionRequest).FullName !) !, _typeInfoProvider.Object() ! ), getAllMethodProduct.MethodName ) ); #endregion #region get fast var getFastMethodProduct = new MethodProduct( nameof(IResolutionFast <object> .GetFast), wrapperSymbol, (methodName, returnType) => { return($@" [MethodImpl(MethodImplOptions.AggressiveInlining)] public {returnType.ToDisplayString()} {methodName}({returnType.ToDisplayString()} unused) {{ return {getMethodProduct.MethodName}( null ); }} "); } ); #endregion var resolutionProduct = new ResolutionProduct( interfaceProduct, interfaceFastProduct, getMethodProduct, getExplicitMethodProduct, nonGenericGetProduct, getAllMethodProduct, getAllExplicitMethodProduct, nonGenericGetAllProduct, getFastMethodProduct ); return(resolutionProduct); }