Subversion Repositories DevTools

Rev

Rev 2931 | Rev 3987 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2931 Rev 3967
Line 264... Line 264...
264
 
264
 
265
    #
265
    #
266
    #   Ensure that the .cs file also exists
266
    #   Ensure that the .cs file also exists
267
    #
267
    #
268
    (my $csfile = $src) =~ s~\.resx$~.cs~;
268
    (my $csfile = $src) =~ s~\.resx$~.cs~;
269
    Error ("$toolset_name toolset: Resx File without a .cs file",
269
    (my $designerfile = $src) =~ s~\.resx$~.Designer.cs~;
-
 
270
 
270
           "File: $src") unless ( -f $csfile );
271
    $csfile = $designerfile if ( -f $designerfile );
271
 
272
 
-
 
273
    Warning ("$toolset_name toolset: Resx File without a .cs or Designer.cs file",
-
 
274
           "File: $src") unless ( -f $csfile );
272
 
275
 
273
    #
276
    #
274
    #   Scan the .resx file looking for the ThisName element
277
    #   Scan the .resx file looking for the ThisName element
275
    #   A very simple and crude parser
278
    #   A very simple and crude parser
276
    #
279
    #
277
    my $ThisName;
280
    my $ThisName;
-
 
281
    my $ThisNameGuess;
278
    open ( SCAN, '<', $src ) || Error ("Cannot open file for reading: $!", "File: $src" );
282
    open ( SCAN, '<', $src ) || Error ("Cannot open file for reading: $!", "File: $src" );
279
    while ( <SCAN> )
283
    while ( <SCAN> )
280
    {
284
    {
281
        if ( m~\<data name=\"\$this\.Name\"\>~ )
285
        if ( m~\<data name=\"\$this\.Name\"\>~ )
282
        {
286
        {
Line 295... Line 299...
295
    #   Name not found
299
    #   Name not found
296
    #   Use a default. Filename with any .aspx, .asax, .ascx removed
300
    #   Use a default. Filename with any .aspx, .asax, .ascx removed
297
    #
301
    #
298
    unless ( $ThisName )
302
    unless ( $ThisName )
299
    {
303
    {
-
 
304
        $ThisNameGuess = $ThisName;
300
        $ThisName = StripDirExt($src);
305
        $ThisNameGuess = StripDirExt($src);
301
        $ThisName =~ s~\.as[pac]x~~i;
306
        $ThisNameGuess =~ s~\.as[pac]x~~i;
302
    }
307
    }
303
 
308
 
304
    #
309
    #
305
    #   Scan the.cs file looking for the namespace
310
    #   Scan the.cs file looking for the namespace and class
306
    #   A very simple and crude parser
311
    #   A very simple and crude parser
307
    #
312
    #
308
    my $NameSpace;
313
    my $NameSpace;
-
 
314
    my $ClassName;
-
 
315
 
309
    open ( SCAN, '<', $csfile ) || Error ("Cannot open file for reading: $!", "File: $csfile" );
316
    open ( SCAN, '<', $csfile ) || Error ("Cannot open file for reading: $!", "File: $csfile" );
310
    while ( <SCAN> )
317
    while ( <SCAN> )
311
    {
318
    {
-
 
319
        next if ( m ~\s*//~);
-
 
320
 
312
        if ( m~namespace\s+(\S+)~ )
321
        if ( m~namespace\s+(\S+)~ ) {
313
        {
-
 
314
            $NameSpace = $1;
322
            $NameSpace = $1;
-
 
323
 
-
 
324
        } elsif ( m~\s+class\s+(\S+)~ ) {
315
            last;
325
            $ClassName = $1;
-
 
326
 
316
        }
327
        }
-
 
328
        last if ( defined($NameSpace) && defined($ClassName) );
-
 
329
 
317
    }
330
    }
318
    close SCAN;
331
    close SCAN;
319
    Error ("$toolset_name toolset: Resx parsing: NameSpace not found", "File: $csfile") unless $NameSpace;
332
    Error ("$toolset_name toolset: Resx parsing: NameSpace not found", "File: $csfile") unless $NameSpace;
320
 
333
 
321
    #
334
    #
322
    #   Need to create an output file name that is a function of the FQN
335
    #   Need to create an output file name that is a function of the FQN
-
 
336
    #   To be backwardly compatible
-
 
337
    #       Use the ClassName - if it was found
-
 
338
    #       Else Use the ThisName - if it was found
-
 
339
    #       Else Use the Guessed ThisName
323
    #
340
    #
-
 
341
    if ( !defined($ClassName)) {
324
    my $root = "$NameSpace.$ThisName.resources";
342
        $ClassName = $ThisName;
-
 
343
        if ( !defined($ClassName)) {
325
    my $resource = $subdir . '/' . $root;
344
            $ClassName = $ThisNameGuess;
-
 
345
        }
-
 
346
    }
326
 
347
 
-
 
348
    my $root = "$NameSpace.$ClassName.resources";
-
 
349
    my $resource = $subdir . '/' . $root;
327
    $resource_files{$resource}{src} = $src;
350
    $resource_files{$resource}{src} = $src;
328
    $resource_files{$resource}{root} = $root;
351
    $resource_files{$resource}{root} = $root;
329
 
352
 
330
    return $resource, $csfile;
353
    return $resource, $csfile;
331
}
354
}