示例#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");
        }
示例#2
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");
        }