Esempio n. 1
0
        public async Task Bind(Core.MigrationTarget migrationTarget)
        {
            if (this.TargetTreeView == null)
            {
                throw new ArgumentException("MigrationTarget Property must be provided.");
            }

            this.TargetTreeView.LogProvider.WriteLog("PropertyPanel Bind", "Start");

            this.Clear();

            if (migrationTarget.ApiVersion == null || migrationTarget.ApiVersion == String.Empty)
            {
                migrationTarget.DefaultApiVersion(this.TargetTreeView.TargetSubscription);
            }

            this._MigrationTarget     = migrationTarget;
            this.ResourceText         = migrationTarget.ToString();
            this.ResourceImage        = imageList1.Images[migrationTarget.ImageKey];
            this.lblResourceType.Text = migrationTarget.FriendlyObjectName;

            if (migrationTarget.GetType() == typeof(VirtualNetworkGateway))
            {
                VirtualNetworkGatewayProperties properties = new VirtualNetworkGatewayProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((VirtualNetworkGateway)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(LocalNetworkGateway))
            {
                LocalNetworkGatewayProperties properties = new LocalNetworkGatewayProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((LocalNetworkGateway)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(VirtualNetworkGatewayConnection))
            {
                VirtualNetworkConnectionProperties properties = new VirtualNetworkConnectionProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((VirtualNetworkGatewayConnection)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(VirtualMachine))
            {
                VirtualMachineProperties properties = new VirtualMachineProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                await properties.Bind((VirtualMachine)migrationTarget, _TargetTreeView);

                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(NetworkSecurityGroup))
            {
                NetworkSecurityGroupProperties properties = new NetworkSecurityGroupProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((NetworkSecurityGroup)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            if (migrationTarget.GetType() == typeof(VirtualNetwork))
            {
                VirtualNetworkProperties properties = new VirtualNetworkProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((VirtualNetwork)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(Subnet))
            {
                SubnetProperties properties = new SubnetProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((Subnet)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(StorageAccount))
            {
                StorageAccountProperties properties = new StorageAccountProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((StorageAccount)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(AvailabilitySet))
            {
                AvailabilitySetProperties properties = new AvailabilitySetProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((AvailabilitySet)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(PublicIp))
            {
                PublicIpProperties properties = new PublicIpProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((PublicIp)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(RouteTable))
            {
                RouteTableProperties properties = new RouteTableProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((RouteTable)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(NetworkInterface))
            {
                NetworkInterfaceProperties properties = new NetworkInterfaceProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                await properties.Bind((NetworkInterface)migrationTarget, _TargetTreeView);

                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(ResourceGroup))
            {
                ResourceGroupProperties properties = new ResourceGroupProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                await properties.Bind((ResourceGroup)migrationTarget, _TargetTreeView);

                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(LoadBalancer))
            {
                LoadBalancerProperties properties = new LoadBalancerProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                await properties.Bind((LoadBalancer)migrationTarget, _TargetTreeView);

                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(Disk))
            {
                DiskProperties properties = new DiskProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                await properties.Bind((Disk)migrationTarget, _TargetTreeView);

                this.PropertyDetailControl = properties;
            }
            //else if (migrationTarget.GetType() == typeof(VirtualMachineImage))
            //{
            //    VirtualMachineImageProperties properties = new VirtualMachineImageProperties();
            //    properties.PropertyChanged += Properties_PropertyChanged;
            //    properties.Bind(_TargetTreeView, (VirtualMachineImage)migrationTarget, _TargetTreeView);
            //    this.PropertyDetailControl = properties;
            //}

            Arm.ProviderResourceType targetProvider = this.TargetTreeView.GetTargetProvider(migrationTarget);
            if (targetProvider != null)
            {
                lblTargetAPIVersion.Visible = true;
                cmbApiVersions.Visible      = true;

                foreach (string apiVersion in targetProvider.ApiVersions)
                {
                    cmbApiVersions.Items.Add(apiVersion);
                }

                if (migrationTarget.ApiVersion != null && migrationTarget.ApiVersion != String.Empty)
                {
                    cmbApiVersions.SelectedIndex = cmbApiVersions.FindStringExact(migrationTarget.ApiVersion);
                }
            }

            this.TargetTreeView.LogProvider.WriteLog("PropertyPanel Bind", "End");
        }
Esempio n. 2
0
        public async Task Bind(TreeNode migrationTargetNode)
        {
            this.Clear();
            this._BoundTreeNode = migrationTargetNode;

            if (this.AzureContext == null)
            {
                throw new ArgumentException("AzureContext Property must be set on Property Panel before Binding.");
            }

            if (this.LogProvider == null)
            {
                throw new ArgumentException("LogProvider Property must be set on Property Panel before Binding.");
            }

            if (migrationTargetNode != null && migrationTargetNode.Tag != null)
            {
                this.ResourceText = migrationTargetNode.Tag.ToString();

                if (migrationTargetNode.Tag.GetType() == typeof(Azure.MigrationTarget.VirtualMachine))
                {
                    this.ResourceImage = imageList1.Images["VirtualMachine"];

                    VirtualMachineProperties properties = new VirtualMachineProperties();
                    properties.AllowManangedDisk = false;
                    properties.PropertyChanged  += Properties_PropertyChanged;
                    await properties.Bind(this.AzureContext, _TargetTreeView, (Azure.MigrationTarget.VirtualMachine) migrationTargetNode.Tag);

                    this.PropertyDetailControl = properties;
                }
                else if (migrationTargetNode.Tag.GetType() == typeof(Azure.MigrationTarget.NetworkSecurityGroup))
                {
                    this.ResourceImage = imageList1.Images["NetworkSecurityGroup"];

                    NetworkSecurityGroupProperties properties = new NetworkSecurityGroupProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind((Azure.MigrationTarget.NetworkSecurityGroup)migrationTargetNode.Tag);
                    this.PropertyDetailControl = properties;
                }
                if (migrationTargetNode.Tag.GetType() == typeof(Azure.MigrationTarget.VirtualNetwork))
                {
                    this.ResourceImage = imageList1.Images["VirtualNetwork"];

                    VirtualNetworkProperties properties = new VirtualNetworkProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind((Azure.MigrationTarget.VirtualNetwork)migrationTargetNode.Tag);
                    this.PropertyDetailControl = properties;
                }
                else if (migrationTargetNode.Tag.GetType() == typeof(Azure.MigrationTarget.Subnet))
                {
                    this.ResourceImage = imageList1.Images["VirtualNetwork"];

                    SubnetProperties properties = new SubnetProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind((Azure.MigrationTarget.Subnet)migrationTargetNode.Tag);
                    this.PropertyDetailControl = properties;
                }
                else if (migrationTargetNode.Tag.GetType() == typeof(Azure.MigrationTarget.StorageAccount))
                {
                    this.ResourceImage = imageList1.Images["StorageAccount"];

                    StorageAccountProperties properties = new StorageAccountProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind(this.AzureContext, (Azure.MigrationTarget.StorageAccount)migrationTargetNode.Tag);
                    this.PropertyDetailControl = properties;
                }
                else if (migrationTargetNode.Tag.GetType() == typeof(Azure.MigrationTarget.Disk))
                {
                    Azure.MigrationTarget.Disk migrationDisk = (Azure.MigrationTarget.Disk)migrationTargetNode.Tag;

                    this.ResourceImage = imageList1.Images["Disk"];

                    DiskProperties properties = new DiskProperties();
                    properties.AllowManangedDisk = false;
                    properties.PropertyChanged  += Properties_PropertyChanged;
                    properties.Bind(this.AzureContext, _TargetTreeView, (Azure.MigrationTarget.Disk)migrationTargetNode.Tag);
                    this.PropertyDetailControl = properties;
                }
                else if (migrationTargetNode.Tag.GetType() == typeof(Azure.MigrationTarget.AvailabilitySet))
                {
                    this.ResourceImage = imageList1.Images["AvailabilitySet"];

                    AvailabilitySetProperties properties = new AvailabilitySetProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind(migrationTargetNode);
                    this.PropertyDetailControl = properties;
                }
                else if (migrationTargetNode.Tag.GetType() == typeof(Azure.MigrationTarget.NetworkInterface))
                {
                    this.ResourceImage = imageList1.Images["NetworkInterface"];

                    NetworkInterfaceProperties properties = new NetworkInterfaceProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    await properties.Bind(this.AzureContext, _TargetTreeView, (Azure.MigrationTarget.NetworkInterface) migrationTargetNode.Tag);

                    this.PropertyDetailControl = properties;
                }
                else if (migrationTargetNode.Tag.GetType() == typeof(Azure.MigrationTarget.ResourceGroup))
                {
                    this.ResourceImage = imageList1.Images["ResourceGroup"];

                    ResourceGroupProperties properties = new ResourceGroupProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    await properties.Bind(AzureContext, (Azure.MigrationTarget.ResourceGroup) migrationTargetNode.Tag);

                    this.PropertyDetailControl = properties;
                }
                else if (migrationTargetNode.Tag.GetType() == typeof(Azure.MigrationTarget.LoadBalancer))
                {
                    this.ResourceImage = imageList1.Images["LoadBalancer"];

                    LoadBalancerProperties properties = new LoadBalancerProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    await properties.Bind((Azure.MigrationTarget.LoadBalancer) migrationTargetNode.Tag);

                    this.PropertyDetailControl = properties;
                }
                else if (migrationTargetNode.Tag.GetType() == typeof(Azure.MigrationTarget.PublicIp))
                {
                    this.ResourceImage = imageList1.Images["PublicIp"];

                    PublicIpProperties properties = new PublicIpProperties();
                    properties.PropertyChanged += Properties_PropertyChanged;
                    properties.Bind((Azure.MigrationTarget.PublicIp)migrationTargetNode.Tag);
                    this.PropertyDetailControl = properties;
                }
            }
        }
Esempio n. 3
0
        public async Task Bind(Core.MigrationTarget migrationTarget)
        {
            if (this.TargetTreeView == null)
            {
                throw new ArgumentException("MigrationTarget Property must be provided.");
            }

            this.TargetTreeView.LogProvider.WriteLog("PropertyPanel Bind", "Start");

            this.Clear();
            this._MigrationTarget     = migrationTarget;
            this.ResourceText         = migrationTarget.ToString();
            this.ResourceImage        = imageList1.Images[migrationTarget.ImageKey];
            this.lblResourceType.Text = migrationTarget.FriendlyObjectName;

            if (migrationTarget.GetType() == typeof(VirtualNetworkGateway))
            {
                VirtualNetworkGatewayProperties properties = new VirtualNetworkGatewayProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((VirtualNetworkGateway)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(LocalNetworkGateway))
            {
                LocalNetworkGatewayProperties properties = new LocalNetworkGatewayProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((LocalNetworkGateway)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(VirtualNetworkGatewayConnection))
            {
                VirtualNetworkConnectionProperties properties = new VirtualNetworkConnectionProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((VirtualNetworkGatewayConnection)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(VirtualMachine))
            {
                VirtualMachineProperties properties = new VirtualMachineProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                await properties.Bind((VirtualMachine)migrationTarget, _TargetTreeView);

                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(NetworkSecurityGroup))
            {
                NetworkSecurityGroupProperties properties = new NetworkSecurityGroupProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((NetworkSecurityGroup)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            if (migrationTarget.GetType() == typeof(VirtualNetwork))
            {
                VirtualNetworkProperties properties = new VirtualNetworkProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((VirtualNetwork)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(Subnet))
            {
                SubnetProperties properties = new SubnetProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((Subnet)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(StorageAccount))
            {
                StorageAccountProperties properties = new StorageAccountProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((StorageAccount)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(AvailabilitySet))
            {
                AvailabilitySetProperties properties = new AvailabilitySetProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((AvailabilitySet)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(PublicIp))
            {
                PublicIpProperties properties = new PublicIpProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((PublicIp)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(RouteTable))
            {
                RouteTableProperties properties = new RouteTableProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                properties.Bind((RouteTable)migrationTarget, _TargetTreeView);
                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(NetworkInterface))
            {
                NetworkInterfaceProperties properties = new NetworkInterfaceProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                await properties.Bind((NetworkInterface)migrationTarget, _TargetTreeView);

                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(ResourceGroup))
            {
                ResourceGroupProperties properties = new ResourceGroupProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                await properties.Bind((ResourceGroup)migrationTarget, _TargetTreeView);

                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(LoadBalancer))
            {
                LoadBalancerProperties properties = new LoadBalancerProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                await properties.Bind((LoadBalancer)migrationTarget, _TargetTreeView);

                this.PropertyDetailControl = properties;
            }
            else if (migrationTarget.GetType() == typeof(Disk))
            {
                DiskProperties properties = new DiskProperties();
                properties.PropertyChanged += Properties_PropertyChanged;
                await properties.Bind((Disk)migrationTarget, _TargetTreeView);

                this.PropertyDetailControl = properties;
            }
            //else if (migrationTarget.GetType() == typeof(VirtualMachineImage))
            //{
            //    VirtualMachineImageProperties properties = new VirtualMachineImageProperties();
            //    properties.PropertyChanged += Properties_PropertyChanged;
            //    properties.Bind(_TargetTreeView, (VirtualMachineImage)migrationTarget, _TargetTreeView);
            //    this.PropertyDetailControl = properties;
            //}

            this.TargetTreeView.LogProvider.WriteLog("PropertyPanel Bind", "End");
        }