Exemple #1
0
 /// <summary>
 /// The component is being initialized
 /// </summary>
 public void InitializeComponent(IBuildComponentHost host)
 {
     _host             = host;
     _resultsCache     = (IResultsCache)(_host.GetComponent(BuildComponentType.ResultsCache));
     _configCache      = (IConfigCache)(_host.GetComponent(BuildComponentType.ConfigCache));
     _testDataProvider = (ITestDataProvider)(_host.GetComponent(BuildComponentType.TestDataProvider));
 }
Exemple #2
0
        /// <summary>
        /// Cleanup
        /// </summary>
        public void ShutdownComponent()
        {
            // If the processor thread is still there then signal it to go away
            // Wait for QAMockHost.globalTimeOut seconds for the thread to go away or complete. If not then abort it.
            if (!this.processorThreadExited)
            {
                this.processorThreadExit.Set();
                if (!this.processorThread.Join(QAMockHost.globalTimeOut))
                {
                    this.processorThread.Abort();
                }

                this.processorThread = null;
            }

            // dispose all the definition object here.
            foreach (RequestDefinition definition in this.definitions.Values)
            {
                definition.Dispose();
            }

            this.definitions.Clear();
            this.newResults.Clear();
            this.newRequests.Clear();
            this.newConfigurations.Clear();
            this.newRequests        = null;
            this.newResults         = null;
            this.newConfigurations  = null;
            this.configurationCache = null;
            this.resultsCache       = null;
        }
Exemple #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MockHost(BuildParameters buildParameters)
        {
            _buildParameters = buildParameters;

            _buildParameters.ProjectRootElementCache = new ProjectRootElementCache(false);

            _configCache = new ConfigCache();
            ((IBuildComponent)_configCache).InitializeComponent(this);

            // We are a logging service
            _loggingService = this;

            _legacyThreadingData = new LegacyThreadingData();

            _requestEngine = new BuildRequestEngine();
            ((IBuildComponent)_requestEngine).InitializeComponent(this);

            _resultsCache = new ResultsCache();
            ((IBuildComponent)_resultsCache).InitializeComponent(this);

            _requestBuilder = new Microsoft.Build.UnitTests.BackEnd.BuildRequestEngine_Tests.MockRequestBuilder();
            ((IBuildComponent)_requestBuilder).InitializeComponent(this);

            _targetBuilder = new TestTargetBuilder();
            ((IBuildComponent)_targetBuilder).InitializeComponent(this);
        }
 /// <summary>
 /// Call the actual implementation
 /// </summary>
 public QAResultsCache()
 {
     _resultCache = new ResultsCache();
     _addCount = 0;
     _getCount = 0;
     _clearedCount = 0;
 }
 /// <summary>
 /// The component is being initialized
 /// </summary>
 public void InitializeComponent(IBuildComponentHost host)
 {
     this.host             = host;
     this.resultsCache     = (IResultsCache)(this.host.GetComponent(BuildComponentType.ResultsCache));
     this.configCache      = (IConfigCache)(this.host.GetComponent(BuildComponentType.ConfigCache));
     this.testDataProvider = (ITestDataProvider)(this.host.GetComponent(BuildComponentType.TestDataProvider));
 }
Exemple #6
0
        private void CleanupCaches()
        {
            IConfigCache configCache = _componentFactories.GetComponent(BuildComponentType.ConfigCache) as IConfigCache;

            if (null != configCache)
            {
                configCache.ClearConfigurations();
            }

            IResultsCache resultsCache = _componentFactories.GetComponent(BuildComponentType.ResultsCache) as IResultsCache;

            if (null != resultsCache)
            {
                resultsCache.ClearResults();
            }

            if (Environment.GetEnvironmentVariable("MSBUILDCLEARXMLCACHEONCHILDNODES") == "1")
            {
                // Optionally clear out the cache. This has the advantage of releasing memory,
                // but the disadvantage of causing the next build to repeat the load and parse.
                // We'll experiment here and ship with the best default.
                s_projectRootElementCache = null;
            }

            // Since we aren't going to be doing any more work, lets clean up all our memory usage.
            GC.Collect();
        }
Exemple #7
0
 /// <summary>
 /// Call the actual implementation
 /// </summary>
 public QAResultsCache()
 {
     _resultCache  = new ResultsCache();
     _addCount     = 0;
     _getCount     = 0;
     _clearedCount = 0;
 }
 /// <summary>
 /// Call the actual implementation
 /// </summary>
 public QAResultsCache()
 {
     this.resultCache  = new ResultsCache();
     this.addCount     = 0;
     this.getCount     = 0;
     this.clearedCount = 0;
 }
 /// <summary>
 /// Call the actual implementation
 /// </summary>
 public QAResultsCache()
 {
     this.resultCache = new ResultsCache();
     this.addCount = 0;
     this.getCount = 0;
     this.clearedCount = 0;
 }
Exemple #10
0
        /// <summary>
        /// Creates and caches a built result.
        /// </summary>
        private BuildResult CacheBuildResult(BuildRequest request, string target, WorkUnitResult workUnitResult)
        {
            BuildResult   result       = CreateBuildResult(request, target, workUnitResult);
            IResultsCache resultsCache = _host.GetComponent(BuildComponentType.ResultsCache) as IResultsCache;

            resultsCache.AddResult(result);
            return(result);
        }
Exemple #11
0
 public OracleDbConn(string connStr
                     , IResultsCache aResultsCache
                     , bool commitAtFinalizing
                     , bool debugPrint
                     , ILogger logger)
     : base(connStr, aResultsCache, commitAtFinalizing, debugPrint, logger)
 {
 }
Exemple #12
0
 public TrendService(IIndexManager indexManager,
                     IPostCountsCache postCountsCache,
                     IStoryCountCache storyCountCache,
                     IResultsCache resultsCache)
 {
     this.indexManager    = indexManager ?? throw new ArgumentNullException(nameof(indexManager));
     this.postCountsCache = postCountsCache ?? throw new ArgumentNullException(nameof(postCountsCache));
     this.storyCountCache = storyCountCache ?? throw new ArgumentNullException(nameof(storyCountCache));
     this.resultsCache    = resultsCache ?? throw new ArgumentNullException(nameof(resultsCache));
 }
Exemple #13
0
 public TrendService(IConnectionFactory connectionFactory,
                     IPostCountsCache postCountsCache,
                     IStoryCountCache storyCountCache,
                     IResultsCache resultsCache)
 {
     this.connectionFactory = connectionFactory;
     this.postCountsCache   = postCountsCache ?? throw new ArgumentNullException(nameof(postCountsCache));
     this.storyCountCache   = storyCountCache ?? throw new ArgumentNullException(nameof(storyCountCache));
     this.resultsCache      = resultsCache ?? throw new ArgumentNullException(nameof(resultsCache));
 }
 /// <summary>
 /// Constructor that takes in nothing.
 /// </summary>
 public QARequestBuilder()
 {
     _host = null;
     _configCache = null;
     _resultsCache = null;
     _builderThread = null;
     _requestedEntry = null;
     _cancelEvent = new AutoResetEvent(false);
     _continueEvent = new AutoResetEvent(false);
     _threadStarted = new ManualResetEvent(false);
     _currentProjectDefinition = null;
 }
 /// <summary>
 /// Constructor that takes in nothing.
 /// </summary>
 public QARequestBuilder()
 {
     this.host                     = null;
     this.configCache              = null;
     this.resultsCache             = null;
     this.builderThread            = null;
     this.requestedEntry           = null;
     this.cancelEvent              = new AutoResetEvent(false);
     this.continueEvent            = new AutoResetEvent(false);
     this.threadStarted            = new ManualResetEvent(false);
     this.currentProjectDefinition = null;
 }
Exemple #16
0
 public DbConn(string connStr
               , IResultsCache aResultsCache
               , bool commitAtFinalizing
               , bool debugPrint
               , ILogger logger)
 {
     _connStr            = connStr;
     _aResultsCache      = aResultsCache;
     _commitAtFinalizing = commitAtFinalizing;
     _debugPrint         = debugPrint;
     _logger             = logger;
     //次状態への遷移
     this.GoToNextState(NoConnection.GetInstance());
 }
Exemple #17
0
            /// <summary>
            /// Constructor
            ///
            /// UNDONE: Refactor this, and the other MockHosts, to use a common base implementation.  The duplication of the
            /// logging implementation alone is unfortunate.
            /// </summary>
            public MockHost()
            {
                _buildParameters     = new BuildParameters();
                _legacyThreadingData = new LegacyThreadingData();

                _configCache = new ConfigCache();
                ((IBuildComponent)_configCache).InitializeComponent(this);

                _loggingService = this;

                _resultsCache = new ResultsCache();
                ((IBuildComponent)_resultsCache).InitializeComponent(this);

                _requestBuilder = new RequestBuilder();
                ((IBuildComponent)_requestBuilder).InitializeComponent(this);

                _targetBuilder = new TargetBuilder();
                ((IBuildComponent)_targetBuilder).InitializeComponent(this);

                _sdkResolverService = new MockSdkResolverService();
                ((IBuildComponent)_sdkResolverService).InitializeComponent(this);
            }
Exemple #18
0
        /// <summary>
        /// Constructor allows you to set the filname, toolsversion, targets to build, build properties and execution time.
        /// Following are the defaults:
        /// ToolsVersion = "ToolsVersion"
        /// GlobalProperties = new BuildPropertyGroup()
        /// ExecutionTime = 0;
        /// Targets to build = "target1"
        /// </summary>
        public RequestDefinition(string fileName, string toolsVersion, string[] targets, PropertyDictionary <ProjectPropertyInstance> properties, int executionTime, RequestDefinition[] childDefinitions, IBuildComponentHost host, bool noTargetsToBuild)
        {
            if (noTargetsToBuild || targets == null)
            {
                this.targetsToBuild = new string[] { };
            }
            else
            {
                this.targetsToBuild = targets;
            }

            this.globalProperties = ((properties == null) ? new PropertyDictionary <ProjectPropertyInstance>() : properties);
            this.toolsVersion     = ((toolsVersion == null) ? RequestDefinition.defaultToolsVersion : toolsVersion);
            this.fileName         = fileName;
            if (childDefinitions != null)
            {
                this.childDefinitions = new List <RequestDefinition>(childDefinitions);
                foreach (RequestDefinition bd in childDefinitions)
                {
                    this.childDefinitions.Add(bd);
                }
            }
            else
            {
                this.childDefinitions = new List <RequestDefinition>();
            }

            this.testProjectCompletedEvent = new AutoResetEvent(false);
            this.executionTime             = executionTime;
            this.requestEngine             = (IBuildRequestEngine)host.GetComponent(BuildComponentType.RequestEngine);
            this.testDataProvider          = (ITestDataProvider)host.GetComponent(BuildComponentType.TestDataProvider);
            this.resultsCache = (IResultsCache)host.GetComponent(BuildComponentType.ResultsCache);
            this.testDataProvider.AddDefinition(this);
            this.projectDefinition = new ProjectDefinition(this.fileName);
            this.waitForCancel     = false;
        }
Exemple #19
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MockHost(BuildParameters buildParameters)
        {
            _buildParameters = buildParameters;

            _buildParameters.ProjectRootElementCache = new ProjectRootElementCache(false);

            _configCache = new ConfigCache();
            ((IBuildComponent)_configCache).InitializeComponent(this);

            // We are a logging service
            _loggingService = this;

            _legacyThreadingData = new LegacyThreadingData();

            _requestEngine = new BuildRequestEngine();
            ((IBuildComponent)_requestEngine).InitializeComponent(this);

            _resultsCache = new ResultsCache();
            ((IBuildComponent)_resultsCache).InitializeComponent(this);

            _requestBuilder = new Microsoft.Build.UnitTests.BackEnd.BuildRequestEngine_Tests.MockRequestBuilder();
            ((IBuildComponent)_requestBuilder).InitializeComponent(this);

            _targetBuilder = new TestTargetBuilder();
            ((IBuildComponent)_targetBuilder).InitializeComponent(this);
        }
Exemple #20
0
        /// <summary>
        /// データベースに接続する
        /// </summary>
        /// <param name="dbms">DBMSの種別</param>
        /// <param name="connStr">接続文字列</param>
        /// <param name="dbParams">設定情報</param>
        public Db(SqlBuilder.DbmsType dbms
                  , string connStr
                  , DbParameters dbParams = null)
        {
            _dbms = dbms;

            _connStr = connStr;
            if (dbParams == null)
            {
                _params = new DbParameters();
            }
            else
            {
                _params = (DbParameters)dbParams.Clone();
            }

            //プールするDB接続を用意する
            _connections = new List <DbConn>();
            for (int i = 0; i <= _params.ConnectionPool; i++)
            {
                _connections.Add(this.CreateDbConn());
            }

            //キャッシュテーブルの作成
            if (_params.Cache == DbParameters.CacheType.Null)
            {
                _aResultsCache = new NullResultsCache();
            }
            else if (_params.Cache == DbParameters.CacheType.LRU)
            {
                _aResultsCache = new LruResultsCache(_params.CacheSize);
            }
            else if (_params.Cache == DbParameters.CacheType.MarkovLRU)
            {
                _aResultsCache = new MarkovResultsCache(
                    new LruResultsCache(_params.CacheSize),
                    this);
            }
            else
            {
                throw new InvalidEnumArgumentException("Undefined CacheType is used");
            }

            //キャスターの生成
            _aCaster = this.CreateCaster();
            //SqlPodファクトリの生成
            _aSqlPodFactory = new SqlPodFactory(_params.SqlPodsDir, _dbms);
            //テーブル情報の生成
            _aTableInfoSet = new TableInfoSet(this);
            //レコードとテーブルのマッピング情報の生成
            _aRecordViewTableMapFactory = new RecordViewTableMapFactory(this);

            //ロックマネージャの生成
            //SQLiteの場合は、必ずSqliteLockManagerを使うこと
            if (_dbms == SqlBuilder.DbmsType.Sqlite)
            {
                _aLockManager = new SqliteLockManager();
            }
            else if (_params.LockData == DbParameters.LockDataType.Memory)
            {
                _aLockManager = new MemLockManager(_aRecordViewTableMapFactory, _aCaster);
            }
            else if (_params.LockData == DbParameters.LockDataType.Db)
            {
                _aLockManager = new DbLockManager(_aRecordViewTableMapFactory, this);
            }
            else if (_params.LockData == DbParameters.LockDataType.Sqlite)
            {
                _aLockManager = new SqliteLockManager();
            }
            else if (_params.LockData == DbParameters.LockDataType.Null)
            {
                _aLockManager = new NullLockManager();
            }
            else
            {
                throw new InvalidEnumArgumentException("Undefined LockDataType is used");
            }

            //SQL文発行ログの出力メソッドの作成
            if (_params.Logger == DbParameters.LoggerType.Null)
            {
                _aLogger = new NullLogger();
            }
            else if (_params.Logger == DbParameters.LoggerType.WindowsEventLog)
            {
                _aLogger = new WindowsEventLogger();
            }
            else if (_params.Logger == DbParameters.LoggerType.Console)
            {
                _aLogger = new ConsoleLogger();
            }
            else
            {
                throw new InvalidEnumArgumentException("Undefined LoggerType is used");
            }
        }
Exemple #21
0
 /// <summary>
 /// Initializes the component with the specified component host.
 /// </summary>
 /// <param name="host">The component host.</param>
 public void InitializeComponent(IBuildComponentHost host)
 {
     _componentHost = host;
     _resultsCache = (IResultsCache)_componentHost.GetComponent(BuildComponentType.ResultsCache);
     _configCache = (IConfigCache)_componentHost.GetComponent(BuildComponentType.ConfigCache);
 }
Exemple #22
0
 /// <summary>
 /// Save the configuration cache information from the host
 /// </summary>
 public void InitializeComponent(IBuildComponentHost host)
 {
     this.configurationCache = (IConfigCache)host.GetComponent(BuildComponentType.ConfigCache);
     this.resultsCache       = (IResultsCache)host.GetComponent(BuildComponentType.ResultsCache);
 }
Exemple #23
0
 public CacheAggregation(IConfigCache configCache, IResultsCache resultsCache, int lastConfigurationId)
 {
     ConfigCache         = configCache;
     ResultsCache        = resultsCache;
     LastConfigurationId = lastConfigurationId;
 }
        public static string SerializeCaches(IConfigCache configCache, IResultsCache resultsCache, string outputCacheFile)
        {
            ErrorUtilities.VerifyThrowInternalNull(outputCacheFile, nameof(outputCacheFile));

            try
            {
                if (string.IsNullOrWhiteSpace(outputCacheFile))
                {
                    return(ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("EmptyOutputCacheFile"));
                }

                var fullPath = FileUtilities.NormalizePath(outputCacheFile);

                Directory.CreateDirectory(Path.GetDirectoryName(fullPath));

                // Use FileStream constructor (File.OpenWrite should not be used as it doesn't reset the length of the file!)
                using (var fileStream = new FileStream(fullPath, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    var translator = BinaryTranslator.GetWriteTranslator(fileStream);

                    ConfigCache  configCacheToSerialize  = null;
                    ResultsCache resultsCacheToSerialize = null;

                    switch (configCache)
                    {
                    case ConfigCache asConfigCache:
                        configCacheToSerialize = asConfigCache;
                        break;

                    case ConfigCacheWithOverride configCacheWithOverride:
                        configCacheToSerialize = configCacheWithOverride.CurrentCache;
                        break;

                    default:
                        ErrorUtilities.ThrowInternalErrorUnreachable();
                        break;
                    }

                    switch (resultsCache)
                    {
                    case ResultsCache asResultsCache:
                        resultsCacheToSerialize = asResultsCache;
                        break;

                    case ResultsCacheWithOverride resultsCacheWithOverride:
                        resultsCacheToSerialize = resultsCacheWithOverride.CurrentCache;
                        break;

                    default:
                        ErrorUtilities.ThrowInternalErrorUnreachable();
                        break;
                    }

                    translator.Translate(ref configCacheToSerialize);
                    translator.Translate(ref resultsCacheToSerialize);
                }
            }
            catch (Exception e)
            {
                return(ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("ErrorWritingCacheFile", outputCacheFile, e.Message));
            }

            return(null);
        }
 public MarkovResultsCache(IResultsCache resultsCache, Db aDb)
 {
     _resultsCache = resultsCache;
     _aDb          = aDb;
 }
 /// <summary>
 /// The component is being initialized
 /// </summary>
 public void InitializeComponent(IBuildComponentHost host)
 {
     _host = host;
     _resultsCache = (IResultsCache)(_host.GetComponent(BuildComponentType.ResultsCache));
     _configCache = (IConfigCache)(_host.GetComponent(BuildComponentType.ConfigCache));
     _testDataProvider = (ITestDataProvider)(_host.GetComponent(BuildComponentType.TestDataProvider));
 }
Exemple #27
0
        /// <summary>
        /// Builds the specified targets.
        /// </summary>
        /// <param name="loggingContext">The logging context for the project.</param>
        /// <param name="entry">The BuildRequestEntry for which we are building targets.</param>
        /// <param name="callback">The callback to be used to handle new project build requests.</param>
        /// <param name="targetNames">The names of the targets to build.</param>
        /// <param name="baseLookup">The Lookup containing all current items and properties for this target.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> to use when building the targets.</param>
        /// <returns>The target's outputs and result codes</returns>
        public async Task <BuildResult> BuildTargets(ProjectLoggingContext loggingContext, BuildRequestEntry entry, IRequestBuilderCallback callback, string[] targetNames, Lookup baseLookup, CancellationToken cancellationToken)
        {
            ErrorUtilities.VerifyThrowArgumentNull(loggingContext, "projectLoggingContext");
            ErrorUtilities.VerifyThrowArgumentNull(entry, nameof(entry));
            ErrorUtilities.VerifyThrowArgumentNull(callback, "requestBuilderCallback");
            ErrorUtilities.VerifyThrowArgumentNull(targetNames, nameof(targetNames));
            ErrorUtilities.VerifyThrowArgumentNull(baseLookup, nameof(baseLookup));
            ErrorUtilities.VerifyThrow(targetNames.Length > 0, "List of targets must be non-empty");
            ErrorUtilities.VerifyThrow(_componentHost != null, "InitializeComponent must be called before building targets.");

            _requestEntry           = entry;
            _requestBuilderCallback = callback;
            _projectLoggingContext  = loggingContext;
            _cancellationToken      = cancellationToken;

            // Clone the base lookup so that if we are re-entered by another request while this one in blocked, we don't have visibility to
            // their state, and they have no visibility into ours.
            _baseLookup = baseLookup.Clone();

            _targetsToBuild = new ConcurrentStack <TargetEntry>();

            // Get the actual target objects from the names
            BuildRequestConfiguration configuration = _requestEntry.RequestConfiguration;

            bool previousCacheableStatus = configuration.IsCacheable;

            configuration.IsCacheable = false;
            configuration.RetrieveFromCache();
            _projectInstance = configuration.Project;

            // Now get the current results cache entry.
            IResultsCache resultsCache        = (IResultsCache)_componentHost.GetComponent(BuildComponentType.ResultsCache);
            BuildResult   existingBuildResult = resultsCache.GetResultsForConfiguration(_requestEntry.Request.ConfigurationId);

            _buildResult = new BuildResult(entry.Request, existingBuildResult, null);

            if (existingBuildResult == null)
            {
                // Add this result so that if our project gets re-entered we won't rebuild any targets we have already built.
                resultsCache.AddResult(_buildResult);
            }

            List <TargetSpecification> targets = new List <TargetSpecification>(targetNames.Length);

            foreach (string targetName in targetNames)
            {
                var targetExists = _projectInstance.Targets.ContainsKey(targetName);
                if (!targetExists && entry.Request.BuildRequestDataFlags.HasFlag(BuildRequestDataFlags.SkipNonexistentTargets))
                {
                    _projectLoggingContext.LogComment(Framework.MessageImportance.Low,
                                                      "TargetSkippedWhenSkipNonexistentTargets", targetName);

                    continue;
                }

                targets.Add(new TargetSpecification(targetName, targetExists ? _projectInstance.Targets[targetName].Location : _projectInstance.ProjectFileLocation));
            }

            // Push targets onto the stack.  This method will reverse their push order so that they
            // get built in the same order specified in the array.
            await PushTargets(targets, null, baseLookup, false, false, TargetBuiltReason.None);

            // Now process the targets
            ITaskBuilder taskBuilder = _componentHost.GetComponent(BuildComponentType.TaskBuilder) as ITaskBuilder;

            try
            {
                await ProcessTargetStack(taskBuilder);
            }
            finally
            {
                // If there are still targets left on the stack, they need to be removed from the 'active targets' list
                foreach (TargetEntry target in _targetsToBuild)
                {
                    configuration.ActivelyBuildingTargets.Remove(target.Name);
                }

                ((IBuildComponent)taskBuilder).ShutdownComponent();
            }

            if (_cancellationToken.IsCancellationRequested)
            {
                throw new BuildAbortedException();
            }

            // Gather up outputs for the requested targets and return those.  All of our information should be in the base lookup now.
            ComputeAfterTargetFailures(targetNames);
            BuildResult resultsToReport = new BuildResult(_buildResult, targetNames);

            // Return after-build project state if requested.
            if (_requestEntry.Request.BuildRequestDataFlags.HasFlag(BuildRequestDataFlags.ProvideProjectStateAfterBuild))
            {
                resultsToReport.ProjectStateAfterBuild = _projectInstance;
            }

            if (_requestEntry.Request.RequestedProjectState != null)
            {
                resultsToReport.ProjectStateAfterBuild =
                    _projectInstance.FilteredCopy(_requestEntry.Request.RequestedProjectState);
            }

            configuration.IsCacheable = previousCacheableStatus;

            return(resultsToReport);
        }
 public void ShutdownComponent()
 {
     _host = null;
     _cache = null;
 }
 public void InitializeComponent(IBuildComponentHost host)
 {
     _host = host;
     _cache = new ResultsCache();
 }
        /// <summary>
        /// Cleanup
        /// </summary>
        public void ShutdownComponent()
        {
            // If the processor thread is still there then signal it to go away
            // Wait for QAMockHost.globalTimeOut seconds for the thread to go away or complete. If not then abort it.
            if (!this.processorThreadExited)
            {
                this.processorThreadExit.Set();
                if(!this.processorThread.Join(QAMockHost.globalTimeOut))
                {
                    this.processorThread.Abort();
                }

                this.processorThread = null;
            }

            // dispose all the definition object here.
            foreach (RequestDefinition definition in this.definitions.Values)
            {
                definition.Dispose();
            }

            this.definitions.Clear();
            this.newResults.Clear();
            this.newRequests.Clear();
            this.newConfigurations.Clear();
            this.newRequests = null;
            this.newResults = null;
            this.newConfigurations = null;
            this.configurationCache = null;
            this.resultsCache = null;
        }
 /// <summary>
 /// Save the configuration cache information from the host
 /// </summary>
 public void InitializeComponent(IBuildComponentHost host)
 {
     this.configurationCache = (IConfigCache)host.GetComponent(BuildComponentType.ConfigCache);
     this.resultsCache = (IResultsCache)host.GetComponent(BuildComponentType.ResultsCache);
 }
        /// <summary>
        /// Constructor allows you to set the filname, toolsversion, targets to build, build properties and execution time.
        /// Following are the defaults:
        /// ToolsVersion = "ToolsVersion"
        /// GlobalProperties = new BuildPropertyGroup()
        /// ExecutionTime = 0;
        /// Targets to build = "target1"
        /// </summary>
        public RequestDefinition(string fileName, string toolsVersion, string[] targets, PropertyDictionary<ProjectPropertyInstance> properties, int executionTime, RequestDefinition[] childDefinitions, IBuildComponentHost host, bool noTargetsToBuild)
        {
            if (noTargetsToBuild || targets == null)
            {
                _targetsToBuild = new string[] { };
            }
            else
            {
                _targetsToBuild = targets;
            }

            _globalProperties = ((properties == null) ? new PropertyDictionary<ProjectPropertyInstance>() : properties);
            _toolsVersion = ((toolsVersion == null) ? RequestDefinition.defaultToolsVersion : toolsVersion);
            _fileName = fileName;
            if (childDefinitions != null)
            {
                _childDefinitions = new List<RequestDefinition>(childDefinitions);
                foreach (RequestDefinition bd in childDefinitions)
                {
                    _childDefinitions.Add(bd);
                }
            }
            else
            {
                _childDefinitions = new List<RequestDefinition>();
            }

            _testProjectCompletedEvent = new AutoResetEvent(false);
            _executionTime = executionTime;
            _requestEngine = (IBuildRequestEngine)host.GetComponent(BuildComponentType.RequestEngine);
            _testDataProvider = (ITestDataProvider)host.GetComponent(BuildComponentType.TestDataProvider);
            _resultsCache = (IResultsCache)host.GetComponent(BuildComponentType.ResultsCache);
            _testDataProvider.AddDefinition(this);
            _projectDefinition = new ProjectDefinition(_fileName);
            _waitForCancel = false;
        }
 public ResultsCacheWithOverride(IResultsCache @override)
 {
     _override    = @override;
     CurrentCache = new ResultsCache();
 }
            /// <summary>
            /// Constructor
            /// 
            /// UNDONE: Refactor this, and the other MockHosts, to use a common base implementation.  The duplication of the
            /// logging implementation alone is unfortunate.
            /// </summary>
            public MockHost()
            {
                _buildParameters = new BuildParameters();
                _legacyThreadingData = new LegacyThreadingData();

                _configCache = new ConfigCache();
                ((IBuildComponent)_configCache).InitializeComponent(this);

                _loggingService = this;

                _resultsCache = new ResultsCache();
                ((IBuildComponent)_resultsCache).InitializeComponent(this);

                _requestBuilder = new RequestBuilder();
                ((IBuildComponent)_requestBuilder).InitializeComponent(this);

                _targetBuilder = new TargetBuilder();
                ((IBuildComponent)_targetBuilder).InitializeComponent(this);
            }
 public void InitializeComponent(IBuildComponentHost host)
 {
     _host  = host;
     _cache = new ResultsCache();
 }
 public void ShutdownComponent()
 {
     _host  = null;
     _cache = null;
 }
 /// <summary>
 /// The component is being initialized
 /// </summary>
 public void InitializeComponent(IBuildComponentHost host)
 {
     this.host = host;
     this.resultsCache = (IResultsCache)(this.host.GetComponent(BuildComponentType.ResultsCache));
     this.configCache = (IConfigCache)(this.host.GetComponent(BuildComponentType.ConfigCache));
     this.testDataProvider = (ITestDataProvider)(this.host.GetComponent(BuildComponentType.TestDataProvider));
 }