Esempio n. 1
0
        private void ReadAssemblyResolutionPath(XmlReader reader)
        {
            ValidateArg.NotNull <XmlReader>(reader, "reader");

            // Expected format of the xml is: -
            //
            // <AssemblyResolution>
            //     <Directory path= "% HOMEDRIVE %\direvtory "includeSubDirectories = "true" />
            //     <Directory path= "C:\windows" includeSubDirectories = "false" />
            //     <Directory path= ".\DirectoryName" />  ...// by default includeSubDirectories is false
            // </AssemblyResolution>
            bool empty = reader.IsEmptyElement;

            reader.Read();

            if (!empty)
            {
                while (reader.NodeType == XmlNodeType.Element)
                {
                    if (string.Compare("Directory", reader.Name, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        string recursiveAttribute = reader.GetAttribute("includeSubDirectories");

                        // read the path specified
                        string path = reader.GetAttribute("path");

                        if (!string.IsNullOrEmpty(path))
                        {
                            // Do we have to look in sub directory for dependent dll.
                            var includeSubDirectories = string.Compare(recursiveAttribute, "true", StringComparison.OrdinalIgnoreCase) == 0;
                            this.SearchDirectories.Add(new RecursiveDirectoryPath(path, includeSubDirectories));
                        }
                    }
                    else
                    {
                        string message = string.Format(CultureInfo.CurrentCulture, Resource.InvalidSettingsXmlElement, reader.Name, "AssemblyResolution");
                        throw new SettingsException(message);
                    }

                    // Move to the next element under tag AssemblyResolution
                    reader.Read();
                }
            }

            // go to the end of the element.
            reader.ReadEndElement();
        }
Esempio n. 2
0
        /// <summary>
        /// Sends the event to all data collectors and fires a callback on the sender, letting it
        /// know when all plugins have completed processing the event
        /// </summary>
        /// <param name="args">The context information for the event</param>
        private void SendEvent(DataCollectionEventArgs args)
        {
            ValidateArg.NotNull(args, nameof(args));

            if (!this.isDataCollectionEnabled)
            {
                if (EqtTrace.IsErrorEnabled)
                {
                    EqtTrace.Error("DataCollectionManger:SendEvent: SendEvent called when no collection is enabled.");
                }

                return;
            }

            // do not send events multiple times
            this.events.RaiseEvent(args);
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GenericAmmo"/> class.
        /// </summary>
        /// <param name="defName"> Def Name. </param>
        /// <param name="description"> Description for this def. </param>
        /// <param name="label"> Label to display. </param>
        /// <param name="thingClass"> Type of Thing that this def defines. </param>
        /// <param name="ammoDefs"> A list of ammo defs. </param>
        public GenericAmmo(string defName, string description, string label, Type thingClass, IEnumerable <AmmoDef> ammoDefs)
            : base(defName, description, label, thingClass, ammoDefs.SelectMany(t => t.thingCategories).Distinct(), null)
        {
            ValidateArg.NotNull(ammoDefs, nameof(ammoDefs));

            this.statBases = new List <StatModifier>()
            {
                new StatModifier()
                {
                    stat = StatDefOf.Mass, value = ammoDefs.Average(t => t.GetStatValueAbstract(StatDefOf.Mass)),
                },
                new StatModifier()
                {
                    stat = CE_StatDefOf.Bulk, value = ammoDefs.Average(t => t.GetStatValueAbstract(CE_StatDefOf.Bulk)),
                },
            };
        }
Esempio n. 4
0
        private void OnTestCaseEnd(object sender, TestCaseEndEventArgs e)
        {
            ValidateArg.NotNull(e, "TestCaseEndEventArgs");

            Debug.Assert(e.Context != null, "Context is null");
            Debug.Assert(e.Context.HasTestCase, "Context is not for a test case");

            if (EqtTrace.IsVerboseEnabled)
            {
                EqtTrace.Verbose(
                    "EventLogDataCollector: TestCaseEnd received for test '{0}' with Test Outcome: {1}.",
                    e.TestCaseName,
                    e.TestOutcome);
            }

            this.WriteCollectedEventLogEntries(e.Context, false, TimeSpan.MaxValue, DateTime.Now);
        }
Esempio n. 5
0
        /// <summary>
        /// Match test case with filter criteria.
        /// </summary>
        public bool MatchTestCase(TestCase testCase, Func <string, Object> propertyValueProvider)
        {
            ValidateArg.NotNull(testCase, "testCase");
            ValidateArg.NotNull(propertyValueProvider, "propertyValueProvider");
            if (!this.validForMatch)
            {
                return(false);
            }

            if (null == this.filterWrapper)
            {
                // can be null when parsing error occurs. Invalid filter results in no match.
                return(false);
            }

            return(this.filterWrapper.Evaluate(propertyValueProvider));
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ThingGroupSelector"/> class.
        /// </summary>
        /// <param name="other"> Copy <paramref name="other"/> to this selector. </param>
        public ThingGroupSelector(ThingGroupSelector other)
        {
            ValidateArg.NotNull(other, nameof(other));

            this.GroupID           = LoadoutManager.ThingGroupSelectorID;
            this.AllowedStackCount = other.AllowedStackCount;
            this.AllowedThing      = other.AllowedThing;
            _bottomThresholdCount  = other._bottomThresholdCount;
            _useBottomThreshold    = other._useBottomThreshold;

            foreach (ThingSelector thingSelector in other._selectors)
            {
                Type          selectorType = thingSelector.GetType();
                ThingSelector newSelector  = (ThingSelector)Activator.CreateInstance(selectorType, new object[] { thingSelector });
                this.Add(newSelector);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Registers to receive events from the provided test run request.
        /// These events will then be broadcast to any registered loggers.
        /// </summary>
        /// <param name="testRunRequest">The run request to register for events on.</param>
        public void RegisterTestRunEvents(ITestRunRequest testRunRequest)
        {
            ValidateArg.NotNull <ITestRunRequest>(testRunRequest, "testRunRequest");

            this.CheckDisposed();

            // Keep track of the run requests so we can unregister for the
            // events when disposed.
            this.runRequest = testRunRequest;

            // Redirect the events to the InternalTestLoggerEvents
            testRunRequest.TestRunMessage        += this.TestRunMessageHandler;
            testRunRequest.OnRunStart            += this.TestRunStartHandler;
            testRunRequest.OnRunStatsChange      += this.TestRunStatsChangedHandler;
            testRunRequest.OnRunCompletion       += this.TestRunCompleteHandler;
            testRunRequest.DataCollectionMessage += this.DataCollectionMessageHandler;
        }
        /// <summary>
        /// Returns whether the parameter project is a test project or not.
        /// </summary>
        public static bool IsTestProject(this IVsProject project, Guid projectGuid)
        {
            // Overload IsTestProject method to check if we should use this test adapter
            // at all. This is much less error prone than adding this check to all locations
            // where this method is called.
            if (!IsTestAdapaterEnabled())
            {
                return(false);
            }

            ValidateArg.NotNull(project, "project");

            var projectTypeGuids = project.GetAggregateProjectTypeGuids();

            // Currently we assume that all matching projects are test projects.
            return(projectTypeGuids.IndexOf(projectGuid.ToString(), StringComparison.OrdinalIgnoreCase) >= 0);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AwesomeInventoryLoadout"/> class.
        /// </summary>
        /// <param name="pawn"> Initialize <see cref="AwesomeInventoryLoadout"/> with items on this <paramref name="pawn"/>. </param>
        public AwesomeInventoryLoadout(Pawn pawn)
        {
            ValidateArg.NotNull(pawn, nameof(pawn));

            this.AddItems(pawn.equipment?.AllEquipmentListForReading);
            this.AddItems(pawn.apparel?.WornApparel);
            this.AddItems(pawn.inventory?.innerContainer);

            this.uniqueId = Current.Game.outfitDatabase.AllOutfits.Max(o => o.uniqueId) + 1;
            CompAwesomeInventoryLoadout compLoadout = pawn.TryGetComp <CompAwesomeInventoryLoadout>();

            this.label = compLoadout?.Loadout == null
                ? AwesomeInventoryLoadout.GetDefaultLoadoutName(pawn)
                : LoadoutManager.GetIncrementalLabel(compLoadout.Loadout.label);

            pawn.SetLoadout(this);
        }
Esempio n. 10
0
        /// <inheritdoc />
        public override void Update(StatEntryModel model)
        {
            ValidateArg.NotNull(model, nameof(model));

            if (model == _lastModel)
            {
                return;
            }

            if (model.StatDef == _lastModel.StatDef && model.Selected == _lastModel.Selected)
            {
                return;
            }

            _lastModel     = new StatEntryModel(model);
            this.NeedBuild = true;
        }
Esempio n. 11
0
        /// <summary>
        /// Add pickup option to context menu when right-click on items on map.
        /// </summary>
        /// <param name="clickPos"> Position of the mouse when right-click. </param>
        /// <param name="pawn"> Currently focused pawn. </param>
        /// <param name="opts"> Options displayed in context menu. </param>
        public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            ValidateArg.NotNull(pawn, nameof(pawn));
            ValidateArg.NotNull(opts, nameof(opts));

            if (pawn.IsQuestLodger())
            {
                return;
            }

            IntVec3      position = IntVec3.FromVector3(clickPos);
            List <Thing> items    = position.GetThingList(pawn.Map);

            if (!PickUpAndHaulUtility.IsActive)
            {
                foreach (Thing item in items)
                {
                    if (item.def.category == ThingCategory.Item)
                    {
                        int count = MassUtility.CountToPickUpUntilOverEncumbered(pawn, item);
                        if (count == 0)
                        {
                            continue;
                        }

                        count = Math.Min(count, item.stackCount);

                        string displayText = UIText.Pickup.Translate(item.LabelNoCount + " x" + count);
                        var    option      = FloatMenuUtility.DecoratePrioritizedTask(
                            new FloatMenuOption(
                                displayText
                                , () =>
                        {
                            Job job              = JobMaker.MakeJob(JobDefOf.TakeInventory, item);
                            job.count            = count;
                            job.checkEncumbrance = true;
                            pawn.jobs.TryTakeOrderedJob(job);
                        })
                            , pawn
                            , item);
                        opts.Add(option);
                    }
                }
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Runs only the tests specified by parameter 'tests'.
        /// </summary>
        /// <param name="tests">Tests to be run.</param>
        /// <param name="runContext">Context to use when executing the tests.</param>
        /// <param name="frameworkHandle">Handle to the framework to record results and to do framework operations.</param>
        public void RunTests(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            ValidateArg.NotNull(tests, nameof(tests));
            ValidateArg.NotNull(frameworkHandle, nameof(frameworkHandle));

            ICollection <Guid> runningTests = tests.Select(t => t.Id).ToList();

            if (!Client.Connected)
            {
                Client.Start();
            }

            List <string> sources = tests.Select(t => t.Source).ToList();

            sources.ForEach((source) => { bool result = Client.CheckAssemblyHash(source, out _, out _); });
            Client.DiscoverTests(sources);
            this.RunTestsInternal(runningTests, frameworkHandle);
        }
        /// <summary>
        /// Creates singleton instance of DataCollectionRequestHandler.
        /// </summary>
        /// <param name="communicationManager">
        /// Handles socket communication.
        /// </param>
        /// <param name="messageSink">
        /// Message sink for sending messages to execution process.
        /// </param>
        /// <returns>
        /// The instance of <see cref="DataCollectionRequestHandler"/>.
        /// </returns>
        public static DataCollectionRequestHandler Create(ICommunicationManager communicationManager, IMessageSink messageSink)
        {
            if (Instance == null)
            {
                ValidateArg.NotNull(communicationManager, nameof(communicationManager));
                ValidateArg.NotNull(messageSink, nameof(messageSink));

                lock (syncObject)
                {
                    if (Instance == null)
                    {
                        Instance = new DataCollectionRequestHandler(communicationManager, messageSink, DataCollectionManager.Create(messageSink), new DataCollectionTestCaseEventHandler());
                    }
                }
            }

            return(Instance);
        }
Esempio n. 14
0
        /// <summary>
        /// This is the equivalent of "RunAll" functionality
        /// </summary>
        /// <param name="sources">Refers to the list of test sources passed to the test adapter from the client.  (Client could be VS or command line)</param>
        public void RunTests(IEnumerable <string> sources, ITestDiscoverer discoverer)
        {
            ValidateArg.NotNull(sources, nameof(sources));
            ValidateArg.NotNull(discoverer, nameof(discoverer));

            this.cancelRequested.Reset();

            var receiver = new TestReceiver();

            discoverer.DiscoverTests(sources, this.runContext, this.frameworkHandle, receiver);

            if (this.cancelRequested.WaitOne(0))
            {
                return;
            }

            this.RunTests(receiver.Tests);
        }
Esempio n. 15
0
        private void OnTestCaseStart(object sender, TestCaseStartEventArgs e)
        {
            ValidateArg.NotNull(e, "TestCaseStartEventArgs");
            ValidateArg.NotNull(e.Context, "TestCaseStartEventArgs.Context");

            if (!e.Context.HasTestCase)
            {
                Debug.Fail("Context is not for a test case");
                throw new ArgumentNullException("TestCaseStartEventArgs.Context.HasTestCase");
            }

            if (EqtTrace.IsVerboseEnabled)
            {
                EqtTrace.Verbose("EventLogDataCollector: TestCaseStart received for test '{0}'.", e.TestCaseName);
            }

            this.StartCollectionForContext(e.Context, false);
        }
Esempio n. 16
0
        /// <summary>
        /// This is the equivalent of "Run Selected Tests" functionality.
        /// </summary>
        /// <param name="tests">The list of TestCases selected to run</param>
        public void RunTests(IEnumerable <TestCase> tests)
        {
            ValidateArg.NotNull(tests, nameof(tests));
            this.cancelRequested.Reset();

            var testFramework = tests.First().GetPropertyValue(JavaScriptTestCaseProperties.TestFramework, defaultValue: TestFrameworkDirectories.ExportRunnerFrameworkName);

            if (string.Equals(testFramework, TestFrameworkDirectories.AngularFrameworkName, StringComparison.OrdinalIgnoreCase))
            {
                // Every angular run initializes karma, browser, caching, etc,
                // so is preferable to let the test adapter handle any optimization.
                RunAllTests(tests);
            }
            else
            {
                RunTestsByFile(tests);
            }
        }
Esempio n. 17
0
        public static IXPathNavigable Import(string settingsFile, IXPathNavigable defaultRunSettings, Architecture architecture, FrameworkVersion frameworkVersion)
        {
            ValidateArg.NotNull(settingsFile, "settingsFile");
            ValidateArg.NotNull(defaultRunSettings, "defaultRunSettings");

            if (IsLegacyTestSettingsFile(settingsFile) == false)
            {
                throw new XmlException(string.Format(CultureInfo.CurrentCulture, UtilitiesResources.UnExpectedSettingsFile));
            }

            var navigator = defaultRunSettings.CreateNavigator();

            if (!navigator.MoveToChild(Constants.RunSettingsName, string.Empty))
            {
                throw new XmlException(UtilitiesResources.NoRunSettingsNodeFound);
            }

            var settingsNode = GenerateMSTestXml(settingsFile);

            settingsNode.MoveToRoot();
            navigator.PrependChild(settingsNode);

            // Adding RunConfig
            if (!navigator.MoveToChild(Constants.RunConfigurationSettingsName, string.Empty))
            {
                var doc = new XmlDocument();
                var runConfigurationNode = doc.CreateElement(Constants.RunConfigurationSettingsName);

                var targetPlatformNode = doc.CreateElement("TargetPlatform");
                targetPlatformNode.InnerXml = architecture.ToString();
                runConfigurationNode.AppendChild(targetPlatformNode);

                var targetFrameworkVersionNode = doc.CreateElement("TargetFrameworkVersion");
                targetFrameworkVersionNode.InnerXml = frameworkVersion.ToString();
                runConfigurationNode.AppendChild(targetFrameworkVersionNode);

                var runConfigNodeNavigator = runConfigurationNode.CreateNavigator();
                runConfigNodeNavigator.MoveToRoot();
                navigator.PrependChild(runConfigNodeNavigator);
            }

            navigator.MoveToRoot();
            return(navigator);
        }
Esempio n. 18
0
        /// <summary>
        /// Called when a test result is received.
        /// </summary>
        private void TestResultHandler(object sender, TestResultEventArgs e)
        {
            ValidateArg.NotNull <object>(sender, "sender");
            ValidateArg.NotNull <TestResultEventArgs>(e, "e");

            // Update the test count statistics based on the result of the test.
            this.testsTotal++;

            string name = null;

            name = !string.IsNullOrEmpty(e.Result.DisplayName) ? e.Result.DisplayName : e.Result.TestCase.FullyQualifiedName;

            if (e.Result.Outcome == TestOutcome.Skipped)
            {
                this.testsSkipped++;
                string output = string.Format(CultureInfo.CurrentCulture, CommandLineResources.SkippedTestIndicator, name);
                Output.WriteLine(output, OutputLevel.Information);
                DisplayFullInformation(e.Result);
            }
            else if (e.Result.Outcome == TestOutcome.Failed)
            {
                this.testOutcome = TestOutcome.Failed;
                this.testsFailed++;
                string output = string.Format(CultureInfo.CurrentCulture, CommandLineResources.FailedTestIndicator, name);
                Output.WriteLine(output, OutputLevel.Information);
                DisplayFullInformation(e.Result);
            }
            else if (e.Result.Outcome == TestOutcome.Passed)
            {
                if (!this.verbosityLevel.Equals(Verbosity.Minimal))
                {
                    string output = string.Format(CultureInfo.CurrentCulture, CommandLineResources.PassedTestIndicator, name);
                    Output.WriteLine(output, OutputLevel.Information);
                }
                this.testsPassed++;
            }
            else
            {
                string output = string.Format(CultureInfo.CurrentCulture, CommandLineResources.NotRunTestIndicator, name);
                Output.WriteLine(output, OutputLevel.Information);
                DisplayFullInformation(e.Result);
            }
        }
Esempio n. 19
0
        /// <inheritdoc />
        public override Rect Draw(StatPanelModel model, Vector2 position)
        {
            ValidateArg.NotNull(model, nameof(model));

            _title.Draw(model, position);

            Rect outRect  = new Rect(_statList.Offset + position, new Vector2(this.Size.x, _statList.Size.y + GenUI.ScrollBarWidth));
            Rect viewRect = new Rect(_statList.Offset + position, _statList.Size);

            Widgets.ScrollHorizontal(outRect, ref _listScrollPos, viewRect);
            Widgets.BeginScrollView(outRect, ref _listScrollPos, viewRect);

            _statList.Draw(model.StatCacheKeys.Keys, position);
            Widgets.EndScrollView();

            _statButton.Draw(model, position);

            return(new Rect(position, this.Size));
        }
Esempio n. 20
0
        public void RemoveWatch(string path)
        {
            ValidateArg.NotNull(path, "path");

            if (!String.IsNullOrEmpty(path))
            {
                FileSystemWatcher watcher;

                if (_fileWatchers.TryGetValue(path, out watcher))
                {
                    watcher.EnableRaisingEvents = false;

                    _fileWatchers.Remove(path);

                    watcher.Changed -= OnChanged;
                    watcher.Dispose();
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Dialog_ManageLoadouts"/> class.
        /// </summary>
        /// <param name="loadout"> Selected loadout. </param>
        /// <param name="pawn"> Selected pawn. </param>
        public Dialog_ManageLoadouts(AwesomeInventoryLoadout loadout, Pawn pawn)
        {
            ValidateArg.NotNull(loadout, nameof(loadout));
            _pawn = pawn ?? throw new ArgumentNullException(nameof(pawn));

            float width = GenUI.GetWidthCached(UIText.TenCharsString.Times(11));

            _initialSize = new Vector2(width, Verse.UI.screenHeight / 2f);

            _currentLoadout = loadout;
            _resettables.Add(this);
            _resettables.Add(new WhiteBlacklistView());

            doCloseX   = true;
            forcePause = true;
            absorbInputAroundWindow = false;
            closeOnClickedOutside   = false;
            closeOnAccept           = false;
        }
Esempio n. 22
0
        public void RunTests(IEnumerable <string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            ValidateArg.NotNull(sources, "sources");
            ValidateArg.NotNull(runContext, "runContext");
            ValidateArg.NotNull(frameworkHandle, "frameworkHandle");

            _cancelRequested.Reset();

            var receiver = new TestReceiver();

            TestDiscoverer.DiscoverTests(sources, frameworkHandle, receiver, runContext.RunSettings);

            if (_cancelRequested.WaitOne(0))
            {
                return;
            }

            RunTestCases(receiver.Tests, runContext, frameworkHandle);
        }
Esempio n. 23
0
        public TestContainerDiscoverer(IServiceProvider serviceProvider,
                                       SolutionEventsListener solutionListener,
                                       IOperationState operationState)
        {
            ValidateArg.NotNull(serviceProvider, "serviceProvider");
            ValidateArg.NotNull(solutionListener, "solutionListener");
            ValidateArg.NotNull(operationState, "operationState");

            _projectInfo = new Dictionary <PythonProject, ProjectInfo>();

            _serviceProvider = serviceProvider;

            _solutionListener = solutionListener;
            _solutionListener.ProjectLoaded    += OnProjectLoaded;
            _solutionListener.ProjectUnloading += OnProjectUnloaded;
            _solutionListener.ProjectClosing   += OnProjectUnloaded;

            _firstLoad = true;
        }
        /// <summary>
        /// Updates with code coverage settings if not configured.
        /// </summary>
        /// <param name="runSettingsDocument"> The run settings document. </param>
        public static void UpdateWithCodeCoverageSettingsIfNotConfigured(IXPathNavigable runSettingsDocument)
        {
            ValidateArg.NotNull <IXPathNavigable>(runSettingsDocument, "runSettingsDocument");
            var runSettingsNavigator = runSettingsDocument.CreateNavigator();

            bool codeCoverageConfigured = XmlRunSettingsUtilities.ContainsDataCollector(runSettingsNavigator, DynamicCodeCoverageDataDiagnosticAdaterUriString) ||
                                          XmlRunSettingsUtilities.ContainsDataCollector(runSettingsNavigator, StaticCodeCoverageDataDiagnosticAdaterUriString);

            if (codeCoverageConfigured == false)
            {
                var existingPath = string.Empty;
                var xpaths       = new string[]
                {
                    string.Join(xPathSeperator, nodeNames, 0, 1),
                    string.Join(xPathSeperator, nodeNames, 0, 2),
                    string.Join(xPathSeperator, nodeNames, 0, 3)
                };

                foreach (var xpath in xpaths)
                {
                    if (runSettingsNavigator.SelectSingleNode(xpath) != null)
                    {
                        existingPath = xpath;
                    }
                    else
                    {
                        break;
                    }
                }

                // If any nodes are missing to add code coverage deafult settings, add the missing xml nodes.
                XPathNavigator dataCollectorsNavigator;
                if (existingPath.Equals(xpaths[2]) == false)
                {
                    dataCollectorsNavigator = runSettingsNavigator.SelectSingleNode(existingPath);
                    var missingNodesText = GetMissingNodesTextIfAny(existingPath, xpaths[2]);
                    dataCollectorsNavigator.AppendChild(missingNodesText);
                }

                dataCollectorsNavigator = runSettingsNavigator.SelectSingleNode(xpaths[2]);
                dataCollectorsNavigator.AppendChild(codeCoverageCollectorSettingsTemplate);
            }
        }
Esempio n. 25
0
        public static void Postfix(bool value, Pawn_DraftController __instance)
        {
            ValidateArg.NotNull(__instance, nameof(__instance));

            if (!value)
            {
                CompAwesomeInventoryLoadout comp = __instance.pawn.TryGetComp <CompAwesomeInventoryLoadout>();
                if (comp != null && comp.HotswapState != CompAwesomeInventoryLoadout.HotSwapState.Inactive && comp.HotSwapCostume != null && comp.Loadout == comp.HotSwapCostume)
                {
                    if (comp.LoadoutBeforeHotSwap != null && comp.LoadoutBeforeHotSwap != comp.HotSwapCostume)
                    {
                        ApparelOptionUtility.StopDressingJobs(__instance.pawn);
                        __instance.pawn.SetLoadout(comp.LoadoutBeforeHotSwap);
                        comp.LoadoutBeforeHotSwap = null;
                        comp.HotswapState         = CompAwesomeInventoryLoadout.HotSwapState.Inactive;
                    }
                }
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Stop an unload job.
        /// </summary>
        /// <param name="pawn"> Looks for unload jobs on this pawn. </param>
        /// <param name="thing"> Thing that is assigned to an unload job. </param>
        /// <remarks> Safe to call if thing is null or thing is not assigned an unload job. </remarks>
        public static void StopJob(Pawn pawn, Thing thing)
        {
            ValidateArg.NotNull(pawn, nameof(pawn));

            if (pawn.CurJob.def == AwesomeInventory_JobDefOf.AwesomeInventory_Unload && pawn.CurJob.targetA.Thing == thing)
            {
                pawn.jobs.EndCurrentJob(JobCondition.InterruptForced);
            }
            else
            {
                Job job = pawn.jobs.jobQueue.FirstOrDefault(
                    j => j.job.def == AwesomeInventory_JobDefOf.AwesomeInventory_Unload &&
                    j.job.targetA == thing).job;

                if (job != null)
                {
                    pawn.jobs.EndCurrentOrQueuedJob(job, JobCondition.InterruptForced);
                }
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Check if conditions are met to take actions.
        /// </summary>
        /// <param name="pawn"> Pawn to check. </param>
        /// <returns> Returns true if <paramref name="pawn"/>'s inventory needs to restock. </returns>
        protected override bool Satisfied(Pawn pawn)
        {
            ValidateArg.NotNull(pawn, nameof(pawn));

            bool needRestock = base.Satisfied(pawn) &&
                               ((pawn.TryGetComp <CompAwesomeInventoryLoadout>()?.NeedRestock ?? false)
                                ||
                                (pawn.equipment.Primary == null && AwesomeInventoryMod.Settings.AutoEquipWeapon));

#if DEBUG
            Log.Message(
                string.Format(
                    System.Globalization.CultureInfo.InvariantCulture,
                    "[{0}] {1}:: Need restock: {2}",
                    DateTime.Now.ToLongTimeString(),
                    nameof(ThinkNode_AwesomeInventory_Core),
                    needRestock));
#endif
            return(needRestock);
        }
Esempio n. 28
0
        /// <summary>
        /// If test run parameter exists already it will override with new value otherwise this will add new test run parameter.
        /// </summary>
        /// <param name="runSettingsProvider"></param>
        /// <param name="match"></param>
        public static void UpdateTestRunParameterSettingsNode(this IRunSettingsProvider runSettingsProvider, Match match)
        {
            ValidateArg.NotNull(runSettingsProvider, nameof(runSettingsProvider));

            var     xmlDocument          = runSettingsProvider.GetRunSettingXmlDocument();
            XmlNode testRunParameterNode = GetXmlNode(xmlDocument, Constants.TestRunParametersName) ?? xmlDocument.CreateElement(Constants.TestRunParametersName);
            var     attrName             = match.Groups[AttributeNameString].Value;
            var     attrValue            = match.Groups[AttributeValueString].Value;

            if (!TryOverrideAttributeValue(testRunParameterNode, attrName, attrValue))
            {
                XmlElement element = xmlDocument.CreateElement(ParameterString);
                element.SetAttribute(NameString, attrName);
                element.SetAttribute(ValueString, attrValue);
                testRunParameterNode.AppendChild(element);
                xmlDocument.DocumentElement.AppendChild(testRunParameterNode);
            }

            runSettingsProvider.UpdateRunSettings(xmlDocument.OuterXml);
        }
        public IXPathNavigable AddRunSettings(IXPathNavigable inputRunSettingDocument, IRunSettingsConfigurationInfo configurationInfo, ILogger log)
        {
            ValidateArg.NotNull(inputRunSettingDocument, "inputRunSettingDocument");
            ValidateArg.NotNull(configurationInfo, "configurationInfo");

            var navigator = inputRunSettingDocument.CreateNavigator();

            if (navigator.MoveToChild("RunSettings", ""))
            {
                if (navigator.MoveToChild(AdapterConstants.SettingsName, ""))
                {
                    navigator.DeleteSelf();
                }

                navigator.AppendChild(SerializeSettings());
            }

            navigator.MoveToRoot();
            return(navigator);
        }
Esempio n. 30
0
        private bool Deploy(string source, IRunContext runContext, ITestExecutionRecorder testExecutionRecorder, IList <DeploymentItem> deploymentItems, TestRunDirectories runDirectories)
        {
            ValidateArg.NotNull(runDirectories, "runDirectories");
            if (EqtTrace.IsInfoEnabled)
            {
                EqtTrace.Info("MSTestExecutor: Found that deployment items for source {0} are: ", source);
                foreach (var item in deploymentItems)
                {
                    EqtTrace.Info("MSTestExecutor: SourcePath: - {0}", item.SourcePath);
                }
            }

            // Do the deployment.
            EqtTrace.InfoIf(EqtTrace.IsInfoEnabled, "MSTestExecutor: Using deployment directory {0} for source {1}.", runDirectories.OutDirectory, source);
            var warnings = this.Deploy(new List <DeploymentItem>(deploymentItems), source, runDirectories.OutDirectory, this.GetTestResultsDirectory(runContext));

            // Log warnings
            LogWarnings(testExecutionRecorder, warnings);
            return(deploymentItems != null && deploymentItems.Count > 0);
        }