Отражение с Powershell

Вы можете использовать привязку для простоты, здесь полный пример кода

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage){
        GridPane gridPane = new GridPane();
        AnchorPane anchorPane = new AnchorPane();

        // Set image with url
        Image image = new Image("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR-524e2cCaY9TUn8vglN3nqqOlT0jIJIIty-Z81S49q9Np6Yws");
        ImageView imageView = new ImageView(image);

        // Bind the imageView width property to gridPane width property
        // So, if width of gridPane change, the width of imageView automatically will be change
        imageView.fitWidthProperty().bind(gridPane.widthProperty());

        // Make the ratio same with original image
        imageView.setPreserveRatio(true);

        anchorPane.getChildren().add(imageView);
        gridPane.getChildren().add(anchorPane);
        Scene scene = new Scene(gridPane, 600, 400);
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(scene);
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}

Fullscreen

Not fullscreen [114 ]

5
задан starblue 18 April 2009 в 09:27
поделиться

2 ответа

Вот маленькая функция, которую вы, возможно, захотите попробовать .. (я еще не проверял ее, так как у меня нет критериев, чтобы легко проверить это ..)

Ее можно использовать, указав пути (один или несколько полных или относительные пути, разделенные запятыми) в командной строке, например,

CheckForAbstractClassInheritance -Abstract System.Object -Assembly c:\assemblies\assemblytotest.dll, assemblytotest2.dll

или из конвейера

'c:\assemblies\assemblytotest.dll','assemblytotest2.dll' | CheckForAbstractClassInheritance -Abstract System.Object

, или с объектами fileinfo из Get-Childitem (dir)

dir c:\assemblies *.dll | CheckForAbstractClassInheritance -Abstract System.Object

.

function CheckForAbstractClassInheritance()
{
    param ([string]$AbstractClassName, [string[]]$AssemblyPath = $null)
    BEGIN
    {
        if ($AssemblyPath -ne $null)
        {
            $AssemblyPath | Load-AssemblyForReflection
        }
    }
    PROCESS
    {
        if ($_ -ne $null)
        {
            if ($_ -is [FileInfo])
            {
                $path = $_.fullname
            }
            else
            {
                $path = (resolve-path $_).path
            }
            $types = ([system.reflection.assembly]::ReflectionOnlyLoadFrom($path)).GetTypes()
            foreach ($type in $types)
            {
                if ($type.IsSubClassOf($AbstractClassName))
                {
                    #If the type is a subclass of the requested type, 
                    #write it to the pipeline
                    $type
                }
            }

        }
    }
}
3
ответ дан 15 December 2019 в 06:35
поделиться

Тот же путь, поскольку Вы делаете это с c#, но с синтаксисом PowerShell.
Смотрите на блок. GetTypes и Тип. IsSubclassOf.

0
ответ дан 15 December 2019 в 06:35
поделиться
Другие вопросы по тегам:

Похожие вопросы: