Пример #1
0
        protected override void Execute(CodeActivityContext context)
        {
            #region Extract Workflow Argument Values

            // The file path of the nuget.exe - if null or empty then
            //  assume nuget is "installed" on the build server and in the path
            var nuGetExeFilePath = NuGetExeFilePath.Get(context);

            // The path of the nuspec file
            var packageLocation = PackageLocation.Get(context);

            // The API Key for pushing
            var apiKey = ApiKey.Get(context);

            // The destination location if deployment is to be done
            var pushDestination = PushDestination.Get(context);

            #endregion

            // Don't assume that DI will have happened.  If the value is null then create the default object.)
            if (NuGetProcess == null)
            {
                NuGetProcess = new NuGetProcess();
            }

            // Call the method that will do the work
            var results = NuGetPublishing(nuGetExeFilePath, packageLocation, pushDestination, apiKey, context);

            // Send the result back to the workflow
            NuGetPushResult.Set(context, results);
        }
Пример #2
0
        /// <exception cref="System.Xml.XPath.XPathException"></exception>
        private void ValidateSingleNode(XmlNode baseNode, string containedNodeXPath, Hl7Errors validationResult)
        {
            XmlNodeList baseTemplateIds = xPathHelper.GetNodes(baseNode, "cda:templateId/@root", PREFIX, NAMESPACE);

            for (int j = 0, jlength = baseTemplateIds.Count; j < jlength; j++)
            {
                string          templateId      = baseTemplateIds.Item(j).Value;
                PackageLocation packageLocation = packagesByOid.SafeGet(templateId);
                if (packageLocation != null && packageLocation.ContainedTemplateConstraints != null && !packageLocation.ContainedTemplateConstraints
                    .IsEmpty())
                {
                    XmlNodeList containedTemplateIds = xPathHelper.GetNodes(baseNode, containedNodeXPath, PREFIX, NAMESPACE);
                    Dictionary <string, Int32?> containedTemplateMap = PopulateContainedTemplateMap(containedTemplateIds);
                    foreach (ContainedTemplate containedTemplate in packageLocation.ContainedTemplateConstraints)
                    {
                        Int32?count = containedTemplateMap.SafeGet(containedTemplate.TemplateOid);
                        if (count == null)
                        {
                            count = 0;
                        }
                        if (!containedTemplate.Cardinality.Contains((int)count))
                        {
                            //Cast for .NET
                            validationResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.CDA_CARDINALITY_CONSTRAINT, "Expected [" + containedTemplate.RawCardinality
                                                                      + "] instances of template " + containedTemplate.TemplateOid + ", but found " + count, baseNode));
                        }
                    }
                }
            }
        }
Пример #3
0
        public void Restore(FilePath project,
                            PackageLocation packageLocation,
                            string verbosity = null)
        {
            string        packageId;
            VersionRange  versionRange;
            string        targetFramework;
            DirectoryPath assetJsonOutput;

            try
            {
                // The mock installer wrote a mock project file containing id;version;framework;stageDirectory
                var contents = _fileSystem.File.ReadAllText(project.Value);
                var tokens   = contents.Split(';');
                if (tokens.Length != 4)
                {
                    throw new ToolPackageException(LocalizableStrings.ToolInstallationRestoreFailed);
                }

                packageId       = tokens[0];
                versionRange    = VersionRange.Parse(tokens[1]);
                targetFramework = tokens[2];
                assetJsonOutput = new DirectoryPath(tokens[3]);
            }
            catch (IOException)
            {
                throw new ToolPackageException(LocalizableStrings.ToolInstallationRestoreFailed);
            }

            if (string.IsNullOrEmpty(packageId))
            {
                throw new ToolPackageException(LocalizableStrings.ToolInstallationRestoreFailed);
            }

            var feedPackage = GetPackage(
                packageId,
                versionRange,
                packageLocation.NugetConfig);

            var packageVersion = feedPackage.Version;

            targetFramework = string.IsNullOrEmpty(targetFramework) ? "targetFramework" : targetFramework;

            var fakeExecutableSubDirectory = Path.Combine(
                packageId.ToLowerInvariant(),
                packageVersion.ToLowerInvariant(),
                "tools",
                targetFramework,
                Constants.AnyRid);
            var fakeExecutablePath = Path.Combine(fakeExecutableSubDirectory, FakeEntrypointName);

            _fileSystem.Directory.CreateDirectory(Path.Combine(assetJsonOutput.Value, fakeExecutableSubDirectory));
            _fileSystem.File.CreateEmptyFile(Path.Combine(assetJsonOutput.Value, fakeExecutablePath));
            _fileSystem.File.WriteAllText(
                assetJsonOutput.WithFile("project.assets.json").Value,
                fakeExecutablePath);
            _fileSystem.File.WriteAllText(
                assetJsonOutput.WithFile(FakeCommandSettingsFileName).Value,
                JsonConvert.SerializeObject(new { Name = feedPackage.ToolCommandName }));
        }
Пример #4
0
        public IToolPackage InstallPackageToExternalManagedLocation(
            PackageLocation packageLocation,
            PackageId packageId,
            VersionRange versionRange = null,
            string targetFramework    = null,
            string verbosity          = null)
        {
            _installCallback?.Invoke();

            var packageDirectory = new DirectoryPath(NuGetGlobalPackagesFolder.GetLocation()).WithSubDirectories(packageId.ToString());

            _fileSystem.Directory.CreateDirectory(packageDirectory.Value);
            var executable = packageDirectory.WithFile("exe");

            _fileSystem.File.CreateEmptyFile(executable.Value);

            MockFeedPackage package = _projectRestorer.GetPackage(
                packageId.ToString(),
                versionRange ?? VersionRange.Parse("*"),
                packageLocation.NugetConfig,
                packageLocation.RootConfigDirectory);

            return(new TestToolPackage
            {
                Id = packageId,
                Version = NuGetVersion.Parse(package.Version),
                Commands = new List <RestoredCommand> {
                    new RestoredCommand(new ToolCommandName(package.ToolCommandName), "runner", executable)
                },
                Warnings = Array.Empty <string>(),
                PackagedShims = Array.Empty <FilePath>()
            });
        }
Пример #5
0
 public virtual bool RemovePackage(PackageLocation packageInfo)
 {
     PackageLocations.Remove(packageInfo);
     if (packageInfo.CacheDirectory.TryDelete())
     {
         PackagesDirectory.GetFile(packageInfo.Package.FullName + ".wrap").Delete();
         return(true);
     }
     return(false);
 }
        public void Invoked_LocatorFindsPackage_PackageLocationSetInConfigurationForUseBySubsequentCommands()
        {
            var package = new PackageLocation<object>();
            var mockFinder = new Mock<IAppInstallationLocator>();
            _finders.Add(mockFinder.Object);

            mockFinder.Setup(x => x.SupportsPathType()).Returns(true);
            mockFinder.Setup(x => x.CanFindPackageAsObject(_instanceConfig.AppName)).Returns(package);

            _cmd.Execute();

            Assert.That(_instanceConfig.PackageLocation, Is.EqualTo(package));
        }
Пример #7
0
            public override bool RemovePackage(PackageLocation packageInfo)
            {
                var packageRef = _loadedPackages.Packages.FirstOrDefault(_ => PackageMatch(packageInfo, _));

                if (packageRef == null)
                {
                    return(false);
                }
                _loadedPackages.Packages.Remove(packageRef);
                base.RemovePackage(packageInfo);
                // ignore failure to remove packages as we now have a list
                return(true);
            }
        public void Invoked_LocatorFindsPackage_LogMessageWritten()
        {
            var package = new PackageLocation<object>();
            var mockFinder = new Mock<IAppInstallationLocator>();
            _finders.Add(mockFinder.Object);

            mockFinder.Setup(x => x.SupportsPathType()).Returns(true);
            mockFinder.Setup(x => x.CanFindPackageAsObject(_instanceConfig.AppName)).Returns(package);

            _cmd.Execute();

            _logger.Verify(x => x.Info("Package found."));
        }
Пример #9
0
        public void Invoked_LocatorFindsPackage_PackageLocationSetInConfigurationForUseBySubsequentCommands()
        {
            var package    = new PackageLocation <object>();
            var mockFinder = new Mock <IAppInstallationLocator>();

            _finders.Add(mockFinder.Object);

            mockFinder.Setup(x => x.SupportsPathType()).Returns(true);
            mockFinder.Setup(x => x.CanFindPackageAsObject(_instanceConfig.AppName, null)).Returns(package);

            _cmd.Execute();

            Assert.That(_instanceConfig.PackageLocation, Is.EqualTo(package));
        }
Пример #10
0
        public void Invoked_LocatorFindsPackage_LogMessageWritten()
        {
            var package    = new PackageLocation <object>();
            var mockFinder = new Mock <IAppInstallationLocator>();

            _finders.Add(mockFinder.Object);

            mockFinder.Setup(x => x.SupportsPathType()).Returns(true);
            mockFinder.Setup(x => x.CanFindPackageAsObject(_instanceConfig.AppName, null)).Returns(package);

            _cmd.Execute();

            Assert.That(_output.ToString(), Is.StringContaining("Found " + package.PackageDetails));
        }
Пример #11
0
        public void Restore(FilePath project,
                            PackageLocation packageLocation,
                            string verbosity = null)
        {
            var argsToPassToRestore = new List <string>();

            argsToPassToRestore.Add(project.Value);
            if (packageLocation.NugetConfig != null)
            {
                argsToPassToRestore.Add("--configfile");
                argsToPassToRestore.Add(packageLocation.NugetConfig.Value.Value);
            }

            argsToPassToRestore.AddRange(new List <string>
            {
                "--runtime",
                Constants.AnyRid,
                "-v:quiet"
            });

            if (_additionalRestoreArguments != null)
            {
                argsToPassToRestore.AddRange(_additionalRestoreArguments);
            }

            var command =
                new DotnetCommand().
                ExecuteWithCapturedOutput(GetSameProductionCommandArguments(argsToPassToRestore));

            if (!string.IsNullOrWhiteSpace(command.StdOut) && (_reporter != null))
            {
                ProjectRestorer.WriteLine(_reporter, command.StdOut, project);
            }

            if (!string.IsNullOrWhiteSpace(command.StdErr) && (_reporter != null))
            {
                ProjectRestorer.WriteLine(_errorReporter, command.StdErr, project);
            }

            if (command.ExitCode != 0)
            {
                throw new ToolPackageException(LocalizableStrings.ToolInstallationRestoreFailed);
            }
        }
Пример #12
0
        public void Restore(FilePath project,
                            PackageLocation packageLocation,
                            string verbosity = null)
        {
            var argsToPassToRestore = new List <string>();

            argsToPassToRestore.Add(project.Value);
            if (packageLocation.NugetConfig != null)
            {
                argsToPassToRestore.Add("--configfile");
                argsToPassToRestore.Add(packageLocation.NugetConfig.Value.Value);
            }

            argsToPassToRestore.AddRange(new List <string>
            {
                "--runtime",
                Constants.AnyRid
            });

            argsToPassToRestore.Add($"--verbosity:{verbosity ?? GetDefaultVerbosity()}");

            if (_additionalRestoreArguments != null)
            {
                argsToPassToRestore.AddRange(_additionalRestoreArguments.Where(arg => !arg.StartsWith("-verbosity")));
            }

            var command = new DotNetCommandFactory(alwaysRunOutOfProc: true)
                          .Create("restore", argsToPassToRestore);

            if (verbosity == null || _forceOutputRedirection)
            {
                command = command
                          .OnOutputLine(line => WriteLine(_reporter, line, project))
                          .OnErrorLine(line => WriteLine(_errorReporter, line, project));
            }

            var result = command.Execute();

            if (result.ExitCode != 0)
            {
                throw new ToolPackageException(LocalizableStrings.ToolInstallationRestoreFailed);
            }
        }
Пример #13
0
            public virtual PackageLocation Publish(IPackageRepository source, string packageFileName, Stream packageStream)
            {
                var wrapFile = PackagesDirectory.GetFile(packageFileName);

                if (wrapFile.Exists)
                {
                    throw new InvalidOperationException(string.Format("Cannot publish package to '{0}' as the file already exists.", wrapFile.Path));
                }

                using (var file = wrapFile.OpenWrite())
                    IO.StreamExtensions.CopyTo(packageStream, file);

                var newPackageCacheDir = _rootCacheDirectory.GetDirectory(wrapFile.NameWithoutExtension);
                var newPackage         = new CachedZipPackage(_parent, wrapFile, newPackageCacheDir);
                var packageLocation    = new PackageLocation(newPackageCacheDir, newPackage);

                PackageLocations.Add(packageLocation);

                return(packageLocation);
            }
Пример #14
0
        private Dictionary <string, Int32?> PopulateContainedTemplateMap(XmlNodeList containedTemplateIds)
        {
            Dictionary <string, Int32?> containedTemplateMap = new Dictionary <string, Int32?>();

            for (int k = 0, klength = containedTemplateIds.Count; k < klength; k++)
            {
                string          containedTemplateId      = containedTemplateIds.Item(k).Value;
                PackageLocation containedPackageLocation = packagesByOid.SafeGet(containedTemplateId);
                while (containedTemplateId != null && containedPackageLocation != null)
                {
                    int count = 1;
                    if (containedTemplateMap.ContainsKey(containedTemplateId))
                    {
                        count += (int)containedTemplateMap.SafeGet(containedTemplateId);
                    }
                    //Cast for .NET
                    containedTemplateMap[containedTemplateId] = count;
                    containedTemplateId      = containedPackageLocation.ImpliedTemplateOid;
                    containedPackageLocation = packagesByOid.SafeGet(containedTemplateId);
                }
            }
            return(containedTemplateMap);
        }
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public override void Validate()
 {
     base.Validate();
     if (PackageLocation == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "PackageLocation");
     }
     if (ConnectVia == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "ConnectVia");
     }
     if (PackageLocation != null)
     {
         PackageLocation.Validate();
     }
     if (ExecutionCredential != null)
     {
         ExecutionCredential.Validate();
     }
     if (ConnectVia != null)
     {
         ConnectVia.Validate();
     }
     if (ProjectParameters != null)
     {
         foreach (var valueElement in ProjectParameters.Values)
         {
             if (valueElement != null)
             {
                 valueElement.Validate();
             }
         }
     }
     if (PackageParameters != null)
     {
         foreach (var valueElement1 in PackageParameters.Values)
         {
             if (valueElement1 != null)
             {
                 valueElement1.Validate();
             }
         }
     }
     if (ProjectConnectionManagers != null)
     {
         foreach (var valueElement2 in ProjectConnectionManagers.Values)
         {
             if (valueElement2 != null)
             {
                 foreach (var valueElement3 in valueElement2.Values)
                 {
                     if (valueElement3 != null)
                     {
                         valueElement3.Validate();
                     }
                 }
             }
         }
     }
     if (PackageConnectionManagers != null)
     {
         foreach (var valueElement4 in PackageConnectionManagers.Values)
         {
             if (valueElement4 != null)
             {
                 foreach (var valueElement5 in valueElement4.Values)
                 {
                     if (valueElement5 != null)
                     {
                         valueElement5.Validate();
                     }
                 }
             }
         }
     }
     if (PropertyOverrides != null)
     {
         foreach (var valueElement6 in PropertyOverrides.Values)
         {
             if (valueElement6 != null)
             {
                 valueElement6.Validate();
             }
         }
     }
     if (LogLocation != null)
     {
         LogLocation.Validate();
     }
 }
Пример #16
0
        public IToolPackage InstallPackage(PackageLocation packageLocation, PackageId packageId,
                                           VersionRange versionRange = null,
                                           string targetFramework    = null,
                                           string verbosity          = null)
        {
            var    packageRootDirectory = _store.GetRootPackageDirectory(packageId);
            string rollbackDirectory    = null;

            return(TransactionalAction.Run <IToolPackage>(
                       action: () =>
            {
                var stageDirectory = _store.GetRandomStagingDirectory();
                _fileSystem.Directory.CreateDirectory(stageDirectory.Value);
                rollbackDirectory = stageDirectory.Value;

                var tempProject = new FilePath(Path.Combine(stageDirectory.Value, ProjectFileName));

                // Write a fake project with the requested package id, version, and framework
                _fileSystem.File.WriteAllText(
                    tempProject.Value,
                    $"{packageId};{versionRange?.ToString("S", new VersionRangeFormatter()) ?? "*"};{targetFramework};{stageDirectory.Value}");

                // Perform a restore on the fake project
                _projectRestorer.Restore(
                    tempProject,
                    packageLocation,
                    verbosity);

                if (_installCallback != null)
                {
                    _installCallback();
                }

                var version = _store.GetStagedPackageVersion(stageDirectory, packageId);
                var packageDirectory = _store.GetPackageDirectory(packageId, version);
                if (_fileSystem.Directory.Exists(packageDirectory.Value))
                {
                    throw new ToolPackageException(
                        string.Format(
                            CommonLocalizableStrings.ToolPackageConflictPackageId,
                            packageId,
                            version.ToNormalizedString()));
                }

                _fileSystem.Directory.CreateDirectory(packageRootDirectory.Value);
                _fileSystem.Directory.Move(stageDirectory.Value, packageDirectory.Value);
                rollbackDirectory = packageDirectory.Value;

                IEnumerable <string> warnings = null;
                _warningsMap.TryGetValue(packageId, out warnings);

                IReadOnlyList <FilePath> packedShims = null;
                _packagedShimsMap.TryGetValue(packageId, out packedShims);

                return new ToolPackageMock(_fileSystem, packageId, version,
                                           packageDirectory, warnings: warnings, packagedShims: packedShims);
            },
                       rollback: () =>
            {
                if (rollbackDirectory != null && _fileSystem.Directory.Exists(rollbackDirectory))
                {
                    _fileSystem.Directory.Delete(rollbackDirectory, true);
                }
                if (_fileSystem.Directory.Exists(packageRootDirectory.Value) &&
                    !_fileSystem.Directory.EnumerateFileSystemEntries(packageRootDirectory.Value).Any())
                {
                    _fileSystem.Directory.Delete(packageRootDirectory.Value, false);
                }
            }));
        }
Пример #17
0
 public Package(SimpleSubrecord <String> EditorID, PackageData Data, PackageLocation Location1, PackageLocation Location2, PackageScheduleData Schedule, PackageTarget Target1, List <Condition> Conditions, SimpleSubrecord <PackageIdleFlags> IdleFlags, SimpleSubrecord <Byte> IdleCount, SimpleSubrecord <Single> IdleTimerSetting, FormArray IdleAnimations, SimpleSubrecord <Byte[]> Unused, RecordReference CombatStyle, SubMarker EatMarker, SimpleSubrecord <UInt32> EscortDistance, SimpleSubrecord <UInt32> FollowDistance_StartLocation_TriggerRadius, SimpleSubrecord <NoYesByte> PatrolIsRepeatable, PackageUseWeaponData UseWeaponData, PackageTarget Target2, SubMarker UseItemMarker, SubMarker AmbushMarker, PackageDialogData DialogData, PackageLocation DummyIgnore, PackageEvent OnBegin, PackageEvent OnEnd, PackageEvent OnChange)
 {
     this.EditorID = EditorID;
     this.Data     = Data;
     this.Schedule = Schedule;
 }
Пример #18
0
        public override void ReadData(ESPReader reader, long dataEnd)
        {
            while (reader.BaseStream.Position < dataEnd)
            {
                string subTag = reader.PeekTag();

                switch (subTag)
                {
                case "EDID":
                    if (EditorID == null)
                    {
                        EditorID = new SimpleSubrecord <String>();
                    }

                    EditorID.ReadBinary(reader);
                    break;

                case "PKDT":
                    if (Data == null)
                    {
                        Data = new PackageData();
                    }

                    Data.ReadBinary(reader);
                    break;

                case "PLDT":
                    if (Location1 == null)
                    {
                        Location1 = new PackageLocation();
                    }

                    Location1.ReadBinary(reader);
                    break;

                case "PLD2":
                    if (Location2 == null)
                    {
                        Location2 = new PackageLocation();
                    }

                    Location2.ReadBinary(reader);
                    break;

                case "PSDT":
                    if (Schedule == null)
                    {
                        Schedule = new PackageScheduleData();
                    }

                    Schedule.ReadBinary(reader);
                    break;

                case "PTDT":
                    if (Target1 == null)
                    {
                        Target1 = new PackageTarget();
                    }

                    Target1.ReadBinary(reader);
                    break;

                case "CTDA":
                    if (Conditions == null)
                    {
                        Conditions = new List <Condition>();
                    }

                    Condition tempCTDA = new Condition();
                    tempCTDA.ReadBinary(reader);
                    Conditions.Add(tempCTDA);
                    break;

                case "IDLF":
                    if (IdleFlags == null)
                    {
                        IdleFlags = new SimpleSubrecord <PackageIdleFlags>();
                    }

                    IdleFlags.ReadBinary(reader);
                    break;

                case "IDLC":
                    if (IdleCount == null)
                    {
                        IdleCount = new SimpleSubrecord <Byte>();
                    }

                    IdleCount.ReadBinary(reader);
                    break;

                case "IDLT":
                    if (IdleTimerSetting == null)
                    {
                        IdleTimerSetting = new SimpleSubrecord <Single>();
                    }

                    IdleTimerSetting.ReadBinary(reader);
                    break;

                case "IDLA":
                    if (IdleAnimations == null)
                    {
                        IdleAnimations = new FormArray();
                    }

                    IdleAnimations.ReadBinary(reader);
                    break;

                case "IDLB":
                    if (Unused == null)
                    {
                        Unused = new SimpleSubrecord <Byte[]>();
                    }

                    Unused.ReadBinary(reader);
                    break;

                case "CNAM":
                    if (CombatStyle == null)
                    {
                        CombatStyle = new RecordReference();
                    }

                    CombatStyle.ReadBinary(reader);
                    break;

                case "PKED":
                    if (EatMarker == null)
                    {
                        EatMarker = new SubMarker();
                    }

                    EatMarker.ReadBinary(reader);
                    break;

                case "PKE2":
                    if (EscortDistance == null)
                    {
                        EscortDistance = new SimpleSubrecord <UInt32>();
                    }

                    EscortDistance.ReadBinary(reader);
                    break;

                case "PKFD":
                    if (FollowDistance_StartLocation_TriggerRadius == null)
                    {
                        FollowDistance_StartLocation_TriggerRadius = new SimpleSubrecord <UInt32>();
                    }

                    FollowDistance_StartLocation_TriggerRadius.ReadBinary(reader);
                    break;

                case "PKPT":
                    if (PatrolIsRepeatable == null)
                    {
                        PatrolIsRepeatable = new SimpleSubrecord <NoYesByte>();
                    }

                    PatrolIsRepeatable.ReadBinary(reader);
                    break;

                case "PKW3":
                    if (UseWeaponData == null)
                    {
                        UseWeaponData = new PackageUseWeaponData();
                    }

                    UseWeaponData.ReadBinary(reader);
                    break;

                case "PTD2":
                    if (Target2 == null)
                    {
                        Target2 = new PackageTarget();
                    }

                    Target2.ReadBinary(reader);
                    break;

                case "PUID":
                    if (UseItemMarker == null)
                    {
                        UseItemMarker = new SubMarker();
                    }

                    UseItemMarker.ReadBinary(reader);
                    break;

                case "PKAM":
                    if (AmbushMarker == null)
                    {
                        AmbushMarker = new SubMarker();
                    }

                    AmbushMarker.ReadBinary(reader);
                    break;

                case "PKDD":
                    if (DialogData == null)
                    {
                        DialogData = new PackageDialogData();
                    }

                    DialogData.ReadBinary(reader);
                    break;

                case "DUMY":
                    if (DummyIgnore == null)
                    {
                        DummyIgnore = new PackageLocation();
                    }

                    DummyIgnore.ReadBinary(reader);
                    break;

                case "POBA":
                    if (OnBegin == null)
                    {
                        OnBegin = new PackageEvent();
                    }

                    OnBegin.ReadBinary(reader);
                    break;

                case "POEA":
                    if (OnEnd == null)
                    {
                        OnEnd = new PackageEvent();
                    }

                    OnEnd.ReadBinary(reader);
                    break;

                case "POCA":
                    if (OnChange == null)
                    {
                        OnChange = new PackageEvent();
                    }

                    OnChange.ReadBinary(reader);
                    break;

                default:
                    throw new Exception();
                }
            }
        }
Пример #19
0
 /// <summary>
 /// REQUIRED. The location of the parcel at the pickup location.
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public PickupFluent <T> PackageLocation(PackageLocation p)
 {
     _pickup.PackageLocation = p;
     return(this);
 }
Пример #20
0
        public override void ReadDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("EditorID", false, out subEle))
            {
                if (EditorID == null)
                {
                    EditorID = new SimpleSubrecord <String>();
                }

                EditorID.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Data", false, out subEle))
            {
                if (Data == null)
                {
                    Data = new PackageData();
                }

                Data.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Location1", false, out subEle))
            {
                if (Location1 == null)
                {
                    Location1 = new PackageLocation();
                }

                Location1.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Location2", false, out subEle))
            {
                if (Location2 == null)
                {
                    Location2 = new PackageLocation();
                }

                Location2.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Schedule", false, out subEle))
            {
                if (Schedule == null)
                {
                    Schedule = new PackageScheduleData();
                }

                Schedule.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Target1", false, out subEle))
            {
                if (Target1 == null)
                {
                    Target1 = new PackageTarget();
                }

                Target1.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Conditions", false, out subEle))
            {
                if (Conditions == null)
                {
                    Conditions = new List <Condition>();
                }

                foreach (XElement e in subEle.Elements())
                {
                    Condition tempCTDA = new Condition();
                    tempCTDA.ReadXML(e, master);
                    Conditions.Add(tempCTDA);
                }
            }
            if (ele.TryPathTo("Idle/Flags", false, out subEle))
            {
                if (IdleFlags == null)
                {
                    IdleFlags = new SimpleSubrecord <PackageIdleFlags>();
                }

                IdleFlags.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Idle/Count", false, out subEle))
            {
                if (IdleCount == null)
                {
                    IdleCount = new SimpleSubrecord <Byte>();
                }

                IdleCount.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Idle/TimerSetting", false, out subEle))
            {
                if (IdleTimerSetting == null)
                {
                    IdleTimerSetting = new SimpleSubrecord <Single>();
                }

                IdleTimerSetting.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Idle/Animations", false, out subEle))
            {
                if (IdleAnimations == null)
                {
                    IdleAnimations = new FormArray();
                }

                IdleAnimations.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Unused", false, out subEle))
            {
                if (Unused == null)
                {
                    Unused = new SimpleSubrecord <Byte[]>();
                }

                Unused.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("CombatStyle", false, out subEle))
            {
                if (CombatStyle == null)
                {
                    CombatStyle = new RecordReference();
                }

                CombatStyle.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("EatMarker", false, out subEle))
            {
                if (EatMarker == null)
                {
                    EatMarker = new SubMarker();
                }

                EatMarker.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("EscortDistance", false, out subEle))
            {
                if (EscortDistance == null)
                {
                    EscortDistance = new SimpleSubrecord <UInt32>();
                }

                EscortDistance.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("FollowDistance_StartLocation_TriggerRadius", false, out subEle))
            {
                if (FollowDistance_StartLocation_TriggerRadius == null)
                {
                    FollowDistance_StartLocation_TriggerRadius = new SimpleSubrecord <UInt32>();
                }

                FollowDistance_StartLocation_TriggerRadius.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("PatrolIsRepeatable", false, out subEle))
            {
                if (PatrolIsRepeatable == null)
                {
                    PatrolIsRepeatable = new SimpleSubrecord <NoYesByte>();
                }

                PatrolIsRepeatable.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("UseWeaponData", false, out subEle))
            {
                if (UseWeaponData == null)
                {
                    UseWeaponData = new PackageUseWeaponData();
                }

                UseWeaponData.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Target2", false, out subEle))
            {
                if (Target2 == null)
                {
                    Target2 = new PackageTarget();
                }

                Target2.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("UseItemMarker", false, out subEle))
            {
                if (UseItemMarker == null)
                {
                    UseItemMarker = new SubMarker();
                }

                UseItemMarker.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("AmbushMarker", false, out subEle))
            {
                if (AmbushMarker == null)
                {
                    AmbushMarker = new SubMarker();
                }

                AmbushMarker.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("DialogData", false, out subEle))
            {
                if (DialogData == null)
                {
                    DialogData = new PackageDialogData();
                }

                DialogData.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("DummyIgnore", false, out subEle))
            {
                if (DummyIgnore == null)
                {
                    DummyIgnore = new PackageLocation();
                }

                DummyIgnore.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("OnBegin", false, out subEle))
            {
                if (OnBegin == null)
                {
                    OnBegin = new PackageEvent();
                }

                OnBegin.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("OnEnd", false, out subEle))
            {
                if (OnEnd == null)
                {
                    OnEnd = new PackageEvent();
                }

                OnEnd.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("OnChange", false, out subEle))
            {
                if (OnChange == null)
                {
                    OnChange = new PackageEvent();
                }

                OnChange.ReadXML(subEle, master);
            }
        }
Пример #21
0
 bool PackageMatch(PackageLocation location, PackageReference packageRef)
 {
     return(location.Package.Name.EqualsNoCase(packageRef.Name) &&
            location.Package.Version.Equals(packageRef.Version));
 }