コード例 #1
0
        internal Page(WebItemGeneralData generalData, EntitySetup entitySetup)
        {
            this.generalData   = generalData;
            requiredParameters = generalData.ReadParametersFromCode(false);
            optionalParameters = generalData.ReadParametersFromCode(true);
            this.entitySetup   = entitySetup;

            // NOTE: Blow up if there is a name collision between parameters and entitySetup.Parameters.
        }
コード例 #2
0
        internal Page( WebItemGeneralData generalData, EntitySetup entitySetup )
        {
            this.generalData = generalData;
            requiredParameters = generalData.ReadParametersFromCode( false );
            optionalParameters = generalData.ReadParametersFromCode( true );
            this.entitySetup = entitySetup;

            // NOTE: Blow up if there is a name collision between parameters and entitySetup.Parameters.
        }
コード例 #3
0
        private static void generateCodeForWebItemsInFolder(
            TextWriter writer, string webProjectPath, string folderPathRelativeToProject, WebProject webProjectConfiguration)
        {
            var folderPath = EwlStatics.CombinePaths( webProjectPath, folderPathRelativeToProject );

            // Generate code for the entity setup if one exists in this folder.
            var entitySetupFileName = "";
            foreach( var fileName in new[] { "EntitySetup.ascx", "EntitySetup.cs" } ) {
                if( File.Exists( EwlStatics.CombinePaths( folderPath, fileName ) ) ) {
                    entitySetupFileName = fileName;
                    break;
                }
            }
            EntitySetup entitySetup = null;
            if( entitySetupFileName.Length > 0 ) {
                var filePathRelativeToProject = Path.Combine( folderPathRelativeToProject, entitySetupFileName );
                entitySetup = new EntitySetup( new WebItemGeneralData( webProjectPath, filePathRelativeToProject, false, webProjectConfiguration ) );
                entitySetup.GenerateCode( writer );
            }

            // Generate code for files in the current folder.
            foreach( var fileName in IoMethods.GetFileNamesInFolder( folderPath ) ) {
                if( !folderPathRelativeToProject.Any() && ( fileName.Contains( ".csproj" ) || fileName == AppStatics.StandardLibraryFilesFileName ) )
                    continue;
                var fileExtension = Path.GetExtension( fileName ).ToLowerInvariant();
                if( new[] { ".cs", ".asax", ".master", ".config", ".svc" }.Contains( fileExtension ) )
                    continue;

                var filePathRelativeToProject = Path.Combine( folderPathRelativeToProject, fileName );
                if( fileExtension == ".aspx" )
                    new Page( new WebItemGeneralData( webProjectPath, filePathRelativeToProject, false, webProjectConfiguration ), entitySetup ).GenerateCode( writer );
                else if( fileExtension == ".ascx" ) {
                    if( fileName != entitySetupFileName )
                        new UserControl( new WebItemGeneralData( webProjectPath, filePathRelativeToProject, false, webProjectConfiguration ) ).GenerateCode( writer );
                }
                else
                    new StaticFile( new WebItemGeneralData( webProjectPath, filePathRelativeToProject, true, webProjectConfiguration ) ).GenerateCode( writer );
            }

            // Delve into sub folders.
            foreach( var subFolderName in IoMethods.GetFolderNamesInFolder( folderPath ) ) {
                var subFolderPath = Path.Combine( folderPathRelativeToProject, subFolderName );
                if( subFolderPath == "bin" || subFolderPath == "obj" )
                    continue;
                generateCodeForWebItemsInFolder( writer, webProjectPath, subFolderPath, webProjectConfiguration );
            }
        }