@@ -61,88 +61,89 @@ class HandlerFactory : IHttpHandlerFactory
6161
6262 public IHttpHandler GetHandler ( HttpContext context , string requestType , string url , string pathTranslated )
6363 {
64- IHttpHandler handlerToReturn ;
64+ IHttpHandler handlerToReturn ;
6565
6666 string relativeURL = context . Request . AppRelativeCurrentExecutionFilePath ;
6767 string fname = relativeURL . Substring ( relativeURL . LastIndexOf ( '~' ) + 2 ) ;
68- String cname1 = ( fname . Contains ( "." ) ) ? fname . Substring ( 0 , fname . LastIndexOf ( '.' ) ) : fname ;
68+ string cname1 = ( fname . Contains ( "." ) ) ? fname . Substring ( 0 , fname . LastIndexOf ( '.' ) ) : fname ;
6969 string cname0 = cname1 . ToLower ( ) ;
70- string actualPath = "" ;
71-
70+ string mainNamespace ;
71+ string assemblyName , cname ;
72+ string actualPath ;
7273 if ( cname0 == "gxoauthlogout" )
7374 {
74- return new GeneXus . Http . GXOAuthLogout ( ) ;
75+ return new GXOAuthLogout ( ) ;
7576 }
7677 else if ( cname0 == "gxoauthuserinfo" )
7778 {
78- return new GeneXus . Http . GXOAuthUserInfo ( ) ;
79+ return new GXOAuthUserInfo ( ) ;
7980 }
8081 else if ( cname0 == "gxoauthaccesstoken" )
8182 {
82- return new GeneXus . Http . GXOAuthAccessToken ( ) ;
83+ return new GXOAuthAccessToken ( ) ;
8384 }
8485 else if ( cname0 == "gxmulticall" )
8586 {
86- return new GeneXus . Http . GXMultiCall ( ) ;
87+ return new GXMultiCall ( ) ;
8788 }
88- string assemblyName , cname ;
89- if ( GXAPIModule . serviceInPath ( pathTranslated , actualPath : out actualPath ) )
89+ else if ( HttpHelper . GamServicesInternalName . Contains ( cname0 ) )
9090 {
91- string nspace ;
92- Config . GetValueOf ( "AppMainNamespace" , out nspace ) ;
93- String objClass = GXAPIModule . servicesBase [ actualPath ] ;
94- //
95- String objectName = GetObjFromPath ( cname0 , actualPath ) ;
96- String objectNameUp = GetObjFromPath ( cname1 , actualPath ) ;
97- //
98- Dictionary < string , object > routeParms ;
99- if ( GXAPIModule . servicesMapData . ContainsKey ( actualPath ) && GetSMap ( actualPath , objectName , objectNameUp , requestType , out string mapName , out routeParms ) )
91+ mainNamespace = HttpHelper . GAM_NSPACE ;
92+ }
93+ else
94+ {
95+ if ( ! Config . GetValueOf ( "AppMainNamespace" , out mainNamespace ) )
96+ mainNamespace = "GeneXus.Programs." ;
97+
98+ if ( GXAPIModule . serviceInPath ( pathTranslated , actualPath : out actualPath ) )
10099 {
101- if ( ! String . IsNullOrEmpty ( mapName ) && GXAPIModule . servicesMap [ actualPath ] . TryGetValue ( mapName , out SingleMap value ) )
100+ string nspace ;
101+ Config . GetValueOf ( "AppMainNamespace" , out nspace ) ;
102+ string objClass = GXAPIModule . servicesBase [ actualPath ] ;
103+ //
104+ string objectName = GetObjFromPath ( cname0 , actualPath ) ;
105+ string objectNameUp = GetObjFromPath ( cname1 , actualPath ) ;
106+ //
107+ Dictionary < string , object > routeParms ;
108+ if ( GXAPIModule . servicesMapData . ContainsKey ( actualPath ) && GetSMap ( actualPath , objectName , objectNameUp , requestType , out string mapName , out routeParms ) )
102109 {
103- String tmpController = objClass ;
104- String asssemblycontroller = tmpController ;
105- if ( objClass . Contains ( "\\ " ) )
110+ if ( ! String . IsNullOrEmpty ( mapName ) && GXAPIModule . servicesMap [ actualPath ] . TryGetValue ( mapName , out SingleMap value ) )
106111 {
107- tmpController = objClass . Substring ( objClass . LastIndexOf ( "\\ " ) + 1 ) ;
108- String addNspace = objClass . Substring ( 0 , objClass . LastIndexOf ( "\\ " ) ) . Replace ( "\\ " , "." ) ;
109- asssemblycontroller = addNspace + "." + tmpController ;
110- nspace += "." + addNspace ;
111- }
112- GxContext gxContext = GxContext . CreateDefaultInstance ( ) ;
113- object handler = ClassLoader . FindInstance ( asssemblycontroller , nspace , tmpController , new Object [ ] { gxContext } , null ) ;
112+ String tmpController = objClass ;
113+ String asssemblycontroller = tmpController ;
114+ if ( objClass . Contains ( "\\ " ) )
115+ {
116+ tmpController = objClass . Substring ( objClass . LastIndexOf ( "\\ " ) + 1 ) ;
117+ String addNspace = objClass . Substring ( 0 , objClass . LastIndexOf ( "\\ " ) ) . Replace ( "\\ " , "." ) ;
118+ asssemblycontroller = addNspace + "." + tmpController ;
119+ nspace += "." + addNspace ;
120+ }
121+ GxContext gxContext = GxContext . CreateDefaultInstance ( ) ;
122+ object handler = ClassLoader . FindInstance ( asssemblycontroller , nspace , tmpController , new Object [ ] { gxContext } , null ) ;
114123
115- gxContext . HttpContext = context ;
116- GxRestWrapper restWrapper = new Application . GxRestWrapper ( handler as GXBaseObject , context , gxContext , value . ServiceMethod , value . VariableAlias , routeParms ) ;
117- return restWrapper ;
124+ gxContext . HttpContext = context ;
125+ GxRestWrapper restWrapper = new Application . GxRestWrapper ( handler as GXBaseObject , context , gxContext , value . ServiceMethod , value . VariableAlias , routeParms ) ;
126+ return restWrapper ;
127+ }
118128 }
119- }
120- else
121- {
122- if ( requestType . Equals ( HttpMethod . Options . Method ) && ! String . IsNullOrEmpty ( actualPath ) && GXAPIModule . servicesMapData . ContainsKey ( actualPath ) )
129+ else
123130 {
124- return new OptionsApiObjectRequestHandler ( actualPath , objectName ) ;
131+ if ( requestType . Equals ( HttpMethod . Options . Method ) && ! String . IsNullOrEmpty ( actualPath ) && GXAPIModule . servicesMapData . ContainsKey ( actualPath ) )
132+ {
133+ return new OptionsApiObjectRequestHandler ( actualPath , objectName ) ;
134+ }
125135 }
136+ return null ;
126137 }
127- return null ;
128138 }
129- else
139+ assemblyName = cname0 ;
140+ cname = cname0 ;
141+ if ( cname . EndsWith ( "_bc_ws" ) )
130142 {
131- {
132- assemblyName = cname0 ;
133- cname = cname0 ;
134- }
135- if ( cname . EndsWith ( "_bc_ws" ) )
136- {
137- cname = cname . Substring ( 0 , cname . Length - 3 ) ;
138- assemblyName = cname ;
139- }
143+ cname = cname . Substring ( 0 , cname . Length - 3 ) ;
144+ assemblyName = cname ;
140145 }
141- string mainNamespace , className ;
142- if ( Config . GetValueOf ( "AppMainNamespace" , out mainNamespace ) )
143- className = mainNamespace + "." + cname ;
144- else
145- className = "GeneXus.Programs." + cname ;
146+ string className = mainNamespace + "." + cname ;
146147
147148 Type objType = GetHandlerType ( assemblyName , className ) ;
148149 if ( objType == null )
@@ -160,9 +161,9 @@ public IHttpHandler GetHandler(HttpContext context, string requestType, string u
160161 }
161162 }
162163 }
163- if ( objType != null )
164- {
165- if ( ! typeof ( IHttpHandler ) . IsAssignableFrom ( objType ) )
164+ if ( objType != null )
165+ {
166+ if ( ! typeof ( IHttpHandler ) . IsAssignableFrom ( objType ) )
166167 {
167168 context . Response . StatusCode = ( int ) HttpStatusCode . NotFound ;
168169 handlerToReturn = null ;
@@ -183,17 +184,17 @@ public IHttpHandler GetHandler(HttpContext context, string requestType, string u
183184 }
184185 }
185186 else
186- {
187- handlerToReturn = ( IHttpHandler ) System . Web . UI . PageParser . GetCompiledPageInstance ( url , pathTranslated , context ) ;
188- }
187+ {
188+ handlerToReturn = System . Web . UI . PageParser . GetCompiledPageInstance ( url , pathTranslated , context ) ;
189+ }
189190 return handlerToReturn ;
190191 }
191192
192193 public string GetObjFromPath ( string cname , string apath )
193194 {
194195 if ( cname . LastIndexOf ( "/" ) == ( cname . Length - 1 ) )
195196 cname = cname . Substring ( 0 , cname . Length - 1 ) ;
196- String objectName = cname . Remove ( 0 , apath . Length ) ;
197+ string objectName = cname . Remove ( 0 , apath . Length ) ;
197198 return objectName ;
198199 }
199200
@@ -290,7 +291,7 @@ internal static Type GetHandlerType(string assemblyName, string className)
290291 try
291292 {
292293
293- objType = GeneXus . Metadata . ClassLoader . FindType ( assemblyName , className , null ) ;
294+ objType = ClassLoader . FindType ( assemblyName , className , null ) ;
294295 if ( objType == null )
295296 objType = Assembly . Load ( assemblyName ) . GetType ( className ) ;
296297 }
0 commit comments