Пример #1
0
        public bool Equals(IContainerInstance instance)
        {
            if (!ReferenceEquals(null, instance) && instance is ContainerInstance container)
            {
                return(this.EqualsInternal(container));
            }

            return(false);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DependencyResolverContainer"/> class.
        /// </summary>
        public DependencyResolverContainer()
        {
            this.Behavior = new DependencyResolverContainerBehavior();

            // Self register
            using (var registration = this.Registration())
            {
                (this.currentInstanceContainer = registration.Register(typeof(IDependencyResolverContainer)))
                .And <DependencyResolverContainer>().AsSingleton(this);
            }
        }
Пример #3
0
        private static IEnumerable <IOperation> Mirror(IContainerInstance left, IContainerInstance right, ISyncContext context)
        {
            // Add new and modified Left objects to Right
            foreach (var leftObject in left.GetObjects(context))
            {
                var rightObject = right.FindObject(leftObject, context);

                if (rightObject == null)
                {
                    foreach (var operation in right.AddObject(leftObject, context))
                    {
                        yield return(operation);
                    }
                }
                else
                {
                    foreach (var change in right.GetChanges(leftObject, rightObject, context))
                    {
                        foreach (var operation in right.UpdateObject(rightObject, leftObject, change, context))
                        {
                            yield return(operation);
                        }
                    }
                }
            }

            // Remove objects that exist in Right but do not exist in Left
            foreach (var rightObject in right.GetObjects(context))
            {
                var leftObject = left.FindObject(rightObject, context);

                if (leftObject == null)
                {
                    foreach (var operation in right.RemoveObject(rightObject, context))
                    {
                        yield return(operation);
                    }
                }
            }
        }
Пример #4
0
 public PairInstance(IPair pair, IExecutionContext context)
 {
     Left  = InstantiateContainer(pair.Left, context);
     Right = InstantiateContainer(pair.Right, context);
 }
Пример #5
0
        internal void RefreshContainersList()
        {
            IsRefreshEnabled = false;

            try
            {
                IContainerInstance selectedContainer = SelectedContainerInstance;
                SelectedContainerInstance = null;

                StatusText = UIResources.SearchingStatusText;
                ContainerInstances?.Clear();

                IEnumerable <IContainerInstance> containers;

                if (SelectedConnection is LocalConnectionViewModel)
                {
                    containers = DockerHelper.GetLocalDockerContainers(Hostname);
                }
                else
                {
                    StatusText = UIResources.SSHConnectingStatusText;
                    var connection = SelectedConnection.Connection;
                    if (connection == null)
                    {
                        StatusText = UIResources.SSHConnectionFailedStatusText;
                        return;
                    }
                    containers = DockerHelper.GetRemoteDockerContainers(connection, Hostname);
                }

                ContainerInstances = new ObservableCollection <IContainerInstance>(containers);
                OnPropertyChanged(nameof(ContainerInstances));

                if (ContainerInstances.Count() > 0)
                {
                    StatusText = UIResources.ContainersFoundStatusText.FormatCurrentCultureWithArgs(ContainerInstances.Count());
                    if (selectedContainer != null)
                    {
                        var found = ContainerInstances.FirstOrDefault(c => selectedContainer.Equals(c));
                        if (found != null)
                        {
                            SelectedContainerInstance = found;
                            return;
                        }
                    }
                    SelectedContainerInstance = ContainerInstances[0];
                }
                else
                {
                    StatusText = String.Empty;
                }
            }
            catch (Exception ex)
            {
                StatusText    = UIResources.ErrorStatusTextFormat.FormatCurrentCultureWithArgs(ex.Message);
                StatusIsError = true;
                return;
            }
            finally
            {
                IsRefreshEnabled = true;
            }
        }