Ejemplo n.º 1
0
 public void RegisterAllOnce_Ok()
 {
     ComponentResolver componentResolver=new ComponentResolver();
     componentResolver.RegisterAll(new MySynchInstaller());
     var publisher = componentResolver.Resolve<IPublisher>("IPublisher.Local");
     Assert.IsInstanceOf(typeof(ChangePublisher),publisher);
 }
        public ProjectTreeControl(Configuration configuration, ISettings settings, IDataLayer dataLayer, [Named("Projects")] ComponentResolver<IParentWindow> parentWindowResolver) 
                : base(parentWindowResolver, dataLayer) {
            InitializeComponent();

            this.configuration = configuration;
            this.settings = settings;
            this.parentWindowResolver = parentWindowResolver;

            tvProjects.AfterSelect += tvProjects_AfterSelect;
            btnRefresh.Click += btnRefresh_Click;
            
            VisibleChanged += (sender, e) => RefreshProperties();
            CursorChanged += (sender, e) => RefreshProperties();
            Enter += (sender, e) => RefreshProperties();
        }
Ejemplo n.º 3
0
        public ProjectTreeControl(Configuration configuration, ISettings settings, IDataLayer dataLayer, [Named("Projects")] ComponentResolver <IParentWindow> parentWindowResolver)
            : base(parentWindowResolver, dataLayer)
        {
            InitializeComponent();

            this.configuration        = configuration;
            this.settings             = settings;
            this.parentWindowResolver = parentWindowResolver;

            tvProjects.AfterSelect += tvProjects_AfterSelect;
            btnRefresh.Click       += btnRefresh_Click;

            VisibleChanged += (sender, e) => RefreshProperties();
            CursorChanged  += (sender, e) => RefreshProperties();
            Enter          += (sender, e) => RefreshProperties();
        }
Ejemplo n.º 4
0
        private void InitializeDistributor()
        {
            LoggingManager.Debug("Initializing distributor with map:" + _distributorMapFile);
            _distributor = new Core.Distributor.Distributor();
            _timer = new Timer();
            _timer.Interval = 60000;
            ComponentResolver componentResolver = new ComponentResolver();
            componentResolver.RegisterAll(new MySynchInstaller());

            _distributor.InitiateDistributionMap(_distributorMapFile, componentResolver);
            _timer.Elapsed += timer_Elapsed;
            _timer.Enabled = true;
            _timer.Start();

            _serviceHosts.Add(CreateAndConfigureServiceHost<IDistributorMonitor>(_distributor, new Uri(string.Format("http://{0}:{1}/distributor/{2}/",
            System.Net.Dns.GetHostName(), _instancePort, Guid.NewGuid().ToString()))));
            LoggingManager.Debug("Distributor initialized.");
        }
        protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
        {
            var csharpMemberProvider = ComponentResolver.GetComponent <ICsharpMemberProvider>(_dataProvider);
            var selectedElement      = _dataProvider.GetSelectedElement <IObjectCreationExpression>(false, false);
            var argumentList         = selectedElement.ArgumentList;
            var @class                 = (IClass)selectedElement.TypeReference?.Resolve().DeclaredElement;
            var parameterCount         = selectedElement.ArgumentList?.Arguments.Count(x => x.Kind != ParameterKind.UNKNOWN);
            var constructor            = @class.Constructors.ToArray().FirstOrDefault(x => !x.IsParameterless && x.Parameters.Count > parameterCount);
            var parameters             = csharpMemberProvider.GetConstructorParameters(constructor.ToString()).ToArray();
            var parameterNumber        = csharpMemberProvider.GetCurrentParameterNumber(selectedElement, _dataProvider);
            var shortName              = constructor.Parameters[parameterNumber].ShortName;
            var currentParam           = parameters[parameterNumber];
            var block                  = _dataProvider.GetSelectedElement <IBlock>();
            var localVariableStatement = _dataProvider.ElementFactory.CreateStatement("var $0 = new Mock<$1>();", (object)shortName, currentParam);

            block.AddStatementBefore(localVariableStatement, selectedElement.GetContainingStatement());

            return(csharpMemberProvider.FillCurrentParameterWithMock(shortName, argumentList, selectedElement, parameterNumber, _dataProvider));
        }
        public override bool IsAvailable(IUserDataHolder cache)
        {
            var testProjectProvider = ComponentResolver.GetComponent <ITestProjectProvider>(_dataProvider);

            if (!testProjectProvider.IsTestProject(_dataProvider.PsiModule))
            {
                return(false);
            }

            _csharpMemberProvider = ComponentResolver.GetComponent <ICsharpMemberProvider>(_dataProvider);
            _selectedElement      = _dataProvider.GetSelectedElement <IObjectCreationExpression>(false, false);
            _block            = _dataProvider.GetSelectedElement <IBlock>();
            _classBody        = _dataProvider.GetSelectedElement <IClassBody>();
            _classDeclaration = _classBody?.GetContainingTypeDeclaration() as IClassLikeDeclaration;

            if (_classDeclaration == null || _block == null || _selectedElement == null)
            {
                return(false);
            }

            if (!(_selectedElement.TypeReference?.Resolve().DeclaredElement is IClass c))
            {
                return(false);
            }

            var parameterCount = _selectedElement.ArgumentList?.Arguments.Count(x => x.Kind != ParameterKind.UNKNOWN);

            _constructor = c.Constructors.ToArray().FirstOrDefault(x => !x.IsParameterless && x.Parameters.Count > parameterCount);
            if (_constructor == null)
            {
                return(false);
            }

            var previousTokenType = _dataProvider.TokenBeforeCaret?.NodeType as ITokenNodeType;
            var nextTokenType     = _dataProvider.TokenAfterCaret?.NodeType as ITokenNodeType;

            if (previousTokenType == null || nextTokenType == null)
            {
                return(false);
            }

            if (previousTokenType.TokenRepresentation == " ")
            {
                previousTokenType = _dataProvider.PsiFile.FindTokenAt(_dataProvider.TokenBeforeCaret.GetTreeStartOffset() - 1)?.NodeType as ITokenNodeType;
            }

            if (nextTokenType.TokenRepresentation == " ")
            {
                nextTokenType = _dataProvider.PsiFile.FindTokenAt(_dataProvider.TokenBeforeCaret.GetTreeEndOffset() + 1)?.NodeType as ITokenNodeType;
            }

            if (previousTokenType == null || nextTokenType == null)
            {
                return(false);
            }

            var isAvailable = false;

            if (previousTokenType.TokenRepresentation == "(")
            {
                isAvailable = nextTokenType.TokenRepresentation == ")" || nextTokenType.TokenRepresentation == ",";
            }

            else if (previousTokenType.TokenRepresentation == ",")
            {
                isAvailable = !nextTokenType.IsIdentifier;
            }

            if (!isAvailable)
            {
                return(false);
            }

            _parameterNumber = _csharpMemberProvider.GetCurrentParameterNumber(_selectedElement, _dataProvider);
            var parameter = _constructor.Parameters[_parameterNumber];

            if (!_csharpMemberProvider.IsAbstractOrInterface(parameter))
            {
                return(false);
            }

            cache.PutKey(AnchorKey.FillParamWithMockContextActionKey);

            return(true);
        }
Ejemplo n.º 7
0
        public void SetUp()
        {
            if (File.Exists("backup.xml"))
            {
                File.Copy("backup.xml", "backup1.xml", true);
                File.Delete("backup.xml");
            }

            _componentResolver=new ComponentResolver();
            _componentResolver.RegisterAll(new TestInstaller());
        }
Ejemplo n.º 8
0
        private void InitializeDistributor()
        {
            ComponentResolver componentResolver = new ComponentResolver();
            componentResolver.RegisterAll(new MySynchInstaller());

            _distributor.InitiateDistributionMap(_distributorMapFile, componentResolver);
            serviceHosts.Add(new ServiceHost(_distributor));
        }
Ejemplo n.º 9
0
 /// <inheritdoc />
 protected override IEnumerable <Type> ResolveRoutableComponents()
 {
     return(AssemblySource.Assemblies.SelectMany(p => ComponentResolver.GetComponents(p)));
 }
Ejemplo n.º 10
0
 public override bool IsAvailable(IUserDataHolder cache)
 {
     _csharpMemberProvider = ComponentResolver.GetComponent <ICsharpMemberProvider>(_dataProvider);
     return(cache.HasKey(AnchorKey.FillWithMockContextActionKey));
 }
        public WorkitemTreeControl(Configuration configuration, ISettings settings, IDataLayer dataLayer, [Named("Workitems")] ComponentResolver <IParentWindow> parentWindowResolver)
            : base(parentWindowResolver, dataLayer)
        {
            InitializeComponent();

            this.configuration = configuration;
            this.settings      = settings;

            btnOnlyMyTasks.Checked = settings.ShowMyTasks;

            tvWorkitems.SelectionChanged += tvWorkitems_SelectionChanged;
            btnSave.Click    += toolBtnSave_Click;
            btnRefresh.Click += toolBtnRefresh_Click;
            btnOnlyMyTasks.CheckedChanged += btnShowMyTasks_CheckedChanged;

            miSave.Click                  += miSave_Click;
            miRevert.Click                += miRevert_Click;
            miSignup.Click                += miSignup_Click;
            miQuickClose.Click            += miQuickClose_Click;
            miClose.Click                 += miClose_Click;
            miNewTask.Click               += AddTask_Click;
            miNewDefect.Click             += AddDefect_Click;
            miNewTest.Click               += AddTest_Click;
            tvWorkitems.ContextMenu.Popup += ContextMenu_Popup;

            btnAddTask.Click   += AddTask_Click;
            btnAddDefect.Click += AddDefect_Click;
            btnAddTest.Click   += AddTest_Click;

            VisibleChanged += (sender, e) => RefreshProperties();
            CursorChanged  += (sender, e) => RefreshProperties();
            Enter          += (sender, e) => RefreshProperties();

            waitCursor = GetWaitCursor();

            tvWorkitems.AsyncExpanding = true;
            tvWorkitems.LoadOnDemand   = true;
            tvWorkitems.Expanding     += tvWorkitems_Expanding;
            tvWorkitems.Expanded      += tvWorkitems_Expanded;
        }