private void buildResolver(Scope scope)
        {
            if (ErrorMessages.Any() || Dependencies.Any(x => x.ErrorMessages.Any()))
            {
                _resolver = new ErrorMessageResolver(this);
            }
            else
            {
                var assembly = scope.ServiceGraph.ToGeneratedAssembly();
                GenerateResolver(assembly);

                if (_resolverType == null)
                {
                    _resolver = new ErrorMessageResolver(this);
                }
                else
                {
                    assembly.CompileAll();

                    _resolver = (IResolver)scope.Root.QuickBuild(_resolverType.CompiledType);
                    _resolverType.ApplySetterValues(_resolver);
                }
            }

            _resolver.Hash = GetHashCode();
            _resolver.Name = Name;
        }
Beispiel #2
0
        public void Save(Stream stream)
        {
            // Make sure we're saving a valid package id
            PackageIdValidator.ValidatePackageId(Id);

            // Throw if the package doesn't contain any dependencies nor content
            if (!Files.Any() && !Dependencies.Any() && !FrameworkReferences.Any())
            {
                throw new InvalidOperationException(NuGetResources.CannotCreateEmptyPackage);
            }

            using (Package package = Package.Open(stream, FileMode.Create)) {
                // Validate and write the manifest
                WriteManifest(package);

                // Write the files to the package
                WriteFiles(package);

                // Copy the metadata properties back to the package
                package.PackageProperties.Creator     = String.Join(",", Authors);
                package.PackageProperties.Description = Description;
                package.PackageProperties.Identifier  = Id;
                package.PackageProperties.Version     = Version.ToString();
                package.PackageProperties.Language    = Language;
                package.PackageProperties.Keywords    = ((IPackageMetadata)this).Tags;
            }
        }
Beispiel #3
0
        private void buildResolver(Scope scope)
        {
            if (_resolver != null)
            {
                return;
            }

            lock (_locker)
            {
                if (_resolver != null)
                {
                    return;
                }

                if (ErrorMessages.Any() || Dependencies.Any(x => x.ErrorMessages.Any()))
                {
                    var errorResolver = new ErrorMessageResolver(this);
                    _resolver = errorResolver.Resolve;
                }
                else
                {
                    _resolver = BuildFuncResolver(scope);
                }
            }
        }
Beispiel #4
0
        public XmlDocument ToXml()
        {
            var cr = Environment.NewLine;

            var src = string.Empty;

            if (Dependencies != null && Dependencies.Any())
            {
                var depSrc = Dependencies.Select(d => $"    <Dependency id='{d.Id}'{GenerateVersionAttrs(d)} />");
                src =
                    $"  <Dependencies>" + cr +
                    string.Join(cr, depSrc) + cr +
                    $"  </Dependencies>";
            }

            src =
                $"<?xml version='1.0' encoding='utf-8'?>" + cr +
                $"<Package type='{PackageType}'>" + cr +
                $"  <Id>{ComponentId}</Id>" + cr +
                $"  <ReleaseDate>{ReleaseDate:yyyy-MM-dd}</ReleaseDate>" + cr +
                $"  <Version>{Version}</Version>" + cr +
                (string.IsNullOrEmpty(Description) ? "" : $"  <Description>{Description}</Description>") + cr +
                src + cr +
                $"</Package>" + cr;

            var xml = new XmlDocument();

            xml.LoadXml(src);
            return(xml);
        }
Beispiel #5
0
        public void BuildFor(CohortAggregateContainer container, ParameterManager parameterManager)
        {
            ThrowIfAlreadyBuilt();
            IsForContainer = true;

            _log.AppendLine("Starting Build for " + container);
            //gather dependencies
            foreach (var cohortSet in ChildProvider.GetAllChildrenRecursively(container).OfType <AggregateConfiguration>().Where(IsEnabled).OrderBy(ac => ac.Order))
            {
                AddDependency(cohortSet);
            }

            if (!Dependencies.Any())
            {
                throw new QueryBuildingException($"There are no AggregateConfigurations under the SET container '{container}'");
            }

            LogDependencies();

            BuildDependenciesSql(parameterManager.ParametersFoundSoFarInQueryGeneration[ParameterLevel.Global].ToArray());

            MakeCacheDecision();

            Sql = BuildSql(container, parameterManager);
        }
Beispiel #6
0
        public void Describe(Description description)
        {
            description.Title = "Package '{0}'".ToFormat(Name);
            description.Properties["Role"] = Role;

            description.Properties["Assemblies"] = Manifest.Assemblies.Join(", ");

            if (Manifest.NativeAssemblies != null && Manifest.NativeAssemblies.Any())
            {
                description.Properties["NativeAssemblies"] = Manifest.NativeAssemblies.Join(", ");
            }

            if (Manifest.BinPath != null)
            {
                description.Properties["BinPath"] = Manifest.BinPath;
            }

            if (Manifest.ContentFileSet != null)
            {
                description.Properties["Content Files"] = Manifest.ContentFileSet.ToString();
            }

            if (Dependencies != null && Dependencies.Any())
            {
                description.AddList("Dependencies", Dependencies);
            }
        }
Beispiel #7
0
        public void SaveFile()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(upfilePath);
            XmlElement root = doc.DocumentElement;

            // Set Unity Version
            root.SelectSingleNode("UnityVersion").InnerText = UnityVersion;

            // Set Repositories
            foreach (Repository repo in Repositories)
            {
                if (!GetRepositoryOverrides().Any(extraRepo =>
                                                  extraRepo is FileRepository &&
                                                  Uplift.Common.FileSystemUtil.MakePathOSFriendly((extraRepo as FileRepository).Path) == Uplift.Common.FileSystemUtil.MakePathOSFriendly((repo as FileRepository).Path)
                                                  ))
                {
                    AddOrReplaceRepository(doc, repo);
                }
            }

            foreach (XmlNode node in root.SelectSingleNode("Repositories").SelectNodes("FileRepository"))
            {
                if (!Repositories.Any(repo => (repo as FileRepository).Path == node.Attributes["Path"].Value))
                {
                    root.SelectSingleNode("Repositories").RemoveChild(node);
                }
            }

            // Set Configuration
            SetPathConfiguration(doc, "BaseInstallPath", Configuration.BaseInstallPath);
            SetPathConfiguration(doc, "DocsPath", Configuration.DocsPath);
            SetPathConfiguration(doc, "EditorPluginPath", Configuration.EditorPluginPath);
            SetPathConfiguration(doc, "ExamplesPath", Configuration.ExamplesPath);
            SetPathConfiguration(doc, "GizmoPath", Configuration.GizmoPath);
            SetPathConfiguration(doc, "MediaPath", Configuration.MediaPath);
            SetPathConfiguration(doc, "PluginPath", Configuration.PluginPath);
            SetPathConfiguration(doc, "RepositoryPath", Configuration.RepositoryPath);
            SetPathConfiguration(doc, "EditorDefaultResourcePath", Configuration.EditorDefaultResourcePath);

            // Set Dependencies
            foreach (DependencyDefinition def in Dependencies)
            {
                AddOrReplaceDependency(doc, def);
            }

            foreach (XmlNode node in root.SelectSingleNode("Dependencies").SelectNodes("Package"))
            {
                if (!Dependencies.Any(def => def.Name == node.Attributes["Name"].Value))
                {
                    root.SelectSingleNode("Dependencies").RemoveChild(node);
                }
            }

            doc.Save(upfilePath);
        }
Beispiel #8
0
        /// <summary>
        /// Loads this resource.
        /// </summary>
        public virtual void Load(Scheduler scheduler = null)
        {
            try
            {
                loadDependencies(scheduler);

                if (Dependencies.Any(x => x.State != ResourceState.Loaded))
                {
                    throw new MissingMemberException("Some dependency is not loaded.");
                }

                if (State != ResourceState.Loaded || Reloadable)
                {
                    OnLoad();

                    if (scheduler != null)
                    {
                        scheduler.Add(() =>
                        {
                            State = ResourceState.Loaded;

                            OnComplete();
                        });
                    }
                    else
                    {
                        State = ResourceState.Loaded;
                        OnComplete();
                    }
                }
            }
            catch (Exception e)
            {
                if (scheduler != null)
                {
                    scheduler.Add(() =>
                    {
                        State = ResourceState.Aborted;
                        if (!OnAbort(this, e))
                        {
                            throw e;
                        }
                    });
                }
                else
                {
                    State = ResourceState.Aborted;
                    if (!OnAbort(this, e))
                    {
                        throw e;
                    }
                }
            }
        }
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendFormat("ObjectList('{0}')\n{{\n", Alias);

            sb.AppendFormat("\t.Compiler\t\t            = '{0}' \n " +
                            "\t.CompilerInputFiles\t\t  = {{ {1} }}\n" +
                            "\t.CompilerOutputPath\t\t  = '{2}'\n" +
                            "\t.CompilerOutputExtension\t\t  = '{3}'\n" +
                            "\t.CompilerOptions\t = '{4}'\n",
                            ObjectCompiler.Alias,
                            string.Join("\n\t\t\t", ActionInputs.Select(a => "'" + a.Value + "'")),
                            OutputPath,
                            OutputExt,
                            CompilerArguments);
            if (PchOptions != null)
            {
                sb.AppendFormat("\t.PCHInputFile\t\t          = '{0}' \n " +
                                "\t.PCHOutputFile\t\t         = '{1}' \n " +
                                "\t.PCHOptions\t\t            = '{2}' \n ",
                                PchOptions.Input,
                                PchOptions.Output,
                                PchOptions.Options);
            }

            var dependencyString = "";

            if (Dependencies.Any())
            {
                foreach (var dependency in Dependencies)
                {
                    dependencyString += "\n\t\t\t '" + dependency.Alias + "'";
                    //if(dependency is ObjectGroupComponent)
                    //{
                    //    if(((ObjectGroupComponent)dependency).PchOptions != null)
                    //    {
                    //        //dependencyString += "\n\t\t\t '" + dependency.Alias + "-PCH'";
                    //    }
                    //}
                }
            }

            if (!string.IsNullOrEmpty(dependencyString))
            {
                sb.AppendFormat("\t.PreBuildDependencies\t\t   = {{ {0} }} \n ",
                                dependencyString);
            }

            sb.Append("}\n");

            return(sb.ToString());
        }
        public void AttachResolver(Scope root)
        {
            if (ErrorMessages.Any() || Dependencies.Any(x => x.ErrorMessages.Any()))
            {
                _resolver = new ErrorMessageResolver(this);
            }
            else
            {
                _resolver = (IResolver)root.QuickBuild(_resolverType.CompiledType);
                _resolverType.ApplySetterValues(_resolver);
            }

            _resolver.Hash = GetHashCode();
            _resolver.Name = Name;
        }
Beispiel #11
0
        internal void ReportArrear(List <OurOwnNuSpec> allNuSpecs, IReporter reporter)
        {
            var lst = allNuSpecs.Where(x => x.Identity == null).ToArray();

            foreach (var l in lst)
            {
                Debug.Write("");
            }

            if (!Dependencies.Any())
            {
                return;
            }

            reporter.AppendLine(@"===" + SpecFile.FullName, Brushes.Blue);
            reporter.AppendLine($"[{Identity.Id}, {Identity.Version}]");
            foreach (var dep in Dependencies)
            {
                var depName  = dep.Id;
                var depReq   = dep.Version;
                var depRes   = "<unknown>";
                var depMatch = allNuSpecs.FirstOrDefault(x => x.Identity != null && x.Identity.Id == depName);
                if (depMatch != null)
                {
                    depRes = depMatch.Identity.Version;
                }

                Brush repColor = null;
                if (depRes != "<unknown>")
                {
                    var depRequirement = VersionRange.Parse(depReq);
                    var sv             = NuGet.Versioning.NuGetVersion.Parse(depRes);

                    if (!depRequirement.Satisfies(sv))
                    {
                        repColor = Brushes.OrangeRed;
                    }
                    if (depRequirement.MinVersion < sv)
                    {
                        repColor = Brushes.Orange;
                    }
                }

                reporter.AppendLine($" - {depName}: req: {depReq} avail: {depRes}", repColor);
            }
        }
Beispiel #12
0
        internal void Report(IReporter reporter)
        {
            if (!Dependencies.Any())
            {
                return;
            }

            reporter.AppendLine(@"===" + SpecFile.FullName, Brushes.Blue);
            foreach (var dep in Dependencies)
            {
                reporter.AppendLine(@"  - " + dep.Id + " " + dep.Version);
                var depRequirement = VersionRange.Parse(dep.Version);
                foreach (var project in Projects)
                {
                    var rp = project.RequiredPackages.FirstOrDefault(p => p.Id == dep.Id);
                    if (rp == null)
                    {
                        continue;
                    }

                    try
                    {
                        var sv  = NuGet.Versioning.NuGetVersion.Parse(rp.Version);
                        var sat = depRequirement.Satisfies(sv);
                        if (!sat)
                        {
                            reporter.AppendLine(
                                $"    - Mismatch: {rp.Version} referenced in {project.ConfigFile.Directory.Name}/{project.ConfigFile.Name}", Brushes.OrangeRed);
                        }
                        else if (string.Compare(rp.Version, depRequirement.MinVersion.ToString(), StringComparison.CurrentCulture) != 0)
                        {
                            reporter.AppendLine(
                                $"    - Warning: MinVersion {depRequirement.MinVersion.ToString()} is lower than installed {rp.Version} in {project.ConfigFile.Directory.Name}/{project.ConfigFile.Name}", Brushes.Orange);
                        }
                    }
                    catch (Exception)
                    {
                        if (string.Compare(rp.Version, dep.Version, StringComparison.CurrentCulture) != 0)
                        {
                            reporter.AppendLine(
                                $"    - Mismatch: {rp.Version} referenced in {project.ConfigFile.Directory.Name}/{project.ConfigFile.Name}", Brushes.OrangeRed);
                        }
                    }
                }
            }
        }
Beispiel #13
0
        public override IFigure HitTest(Rect rect)
        {
            if (Dependencies != null && !Dependencies.Any(f => f is ImmovablePoint))
            {
                PointPair boundingRect = Coordinates.GetBoundingRect().Inflate(CursorTolerance);

                if (rect.Contains(boundingRect.Midpoint) || rect.Contains(boundingRect.P1) || rect.Contains(boundingRect.P2))
                {
                    return(this);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Beispiel #14
0
        public override string ToString()
        {
            //Carry on here. Need to strip input/output out, or change to not require in/out
            var sb = new StringBuilder();

            sb.AppendFormat("Exec('{0}')\n{{\n", Alias);
            sb.AppendFormat("\t.ExecExecutable\t\t  = '{0}' \n " +
                            "\t.ExecArguments\t\t  = '{1}'\n" +
                            "\t.DoNotUseOutput = true\n" +
                            "\t.ExecOutput\t\t = '{2}-{0}'\n",
                            Linker.ExecPath,
                            Arguments, Alias);

            if (Dependencies.Any())
            {
                sb.AppendFormat("\t.PreBuildDependencies\t\t= {{ {0} }} \n ",
                                string.Join("\n\t\t\t", Dependencies.Select(d => "'" + d.Alias + "'").Distinct()));
            }
            sb.Append("}\n");

            return(sb.ToString());
        }
Beispiel #15
0
 public bool IsDependency(Vertex vertex)
 {
     return(Dependencies.Any(d => d == vertex) || (Dependencies.Any(dependency => dependency.IsDependency(vertex))));
 }
Beispiel #16
0
        /// <summary>
        /// Converts an object to a <see cref="JsonValue"/>.
        /// </summary>
        /// <param name="serializer">The <see cref="JsonSerializer"/> instance to use for additional serialization of values.</param>
        /// <returns>The <see cref="JsonValue"/> representation of the object.</returns>
        public virtual JsonValue ToJson(JsonSerializer serializer)
        {
            var json = new JsonObject();

            if (Id != null)
            {
                json["id"] = Id;
            }
            if (!string.IsNullOrWhiteSpace(Schema))
            {
                json["$schema"] = Schema;
            }
            if (Title != null)
            {
                json["title"] = Title;
            }
            if (!string.IsNullOrWhiteSpace(Description))
            {
                json["description"] = Description;
            }
            if (Default != null)
            {
                json["default"] = Default;
            }
            if (MultipleOf.HasValue)
            {
                json["multipleOf"] = MultipleOf;
            }
            if (Maximum.HasValue)
            {
                json["maximum"] = Maximum;
            }
            if (ExclusiveMaximum.HasValue)
            {
                json["exclusiveMaximum"] = ExclusiveMaximum;
            }
            if (Minimum.HasValue)
            {
                json["minimum"] = Minimum;
            }
            if (ExclusiveMinimum.HasValue)
            {
                json["exclusiveMinimum"] = ExclusiveMinimum;
            }
            if (MaxLength.HasValue)
            {
                json["maxLength"] = MaxLength;
            }
            if (MinLength.HasValue)
            {
                json["minLength"] = MinLength;
            }
            if (Pattern != null)
            {
                json["pattern"] = Pattern;
            }
            if (AdditionalItems != null)
            {
                json["additionalItems"] = AdditionalItems.ToJson(serializer);
            }
            if (Items != null)
            {
                json["items"] = Items.ToJson(serializer);
            }
            if (MaxItems.HasValue)
            {
                json["maxItems"] = MinItems;
            }
            if (MinItems.HasValue)
            {
                json["minItems"] = MinItems;
            }
            if (UniqueItems ?? false)
            {
                json["uniqueItems"] = UniqueItems;
            }
            if (MaxProperties.HasValue)
            {
                json["maxProperties"] = MaxProperties;
            }
            if (MinProperties.HasValue)
            {
                json["minProperties"] = MinProperties;
            }
            if (Required != null)
            {
                var array = Required.ToJson();
                array.Array.EqualityStandard = ArrayEquality.ContentsEqual;
                json["required"]             = array;
            }
            if (AdditionalProperties != null)
            {
                json["additionalProperties"] = AdditionalProperties.ToJson(serializer);
            }
            if (Definitions != null)
            {
                json["definitions"] = Definitions.ToJson(serializer);
            }
            if (Properties != null)
            {
                json["properties"] = Properties.ToJson(serializer);
            }
            if (PatternProperties != null && PatternProperties.Any())
            {
                json["patternProperties"] = PatternProperties.ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value).ToJson(serializer);
            }
            if (Dependencies != null && Dependencies.Any())
            {
                var jsonDependencies = new JsonObject();
                foreach (var dependency in Dependencies)
                {
                    jsonDependencies[dependency.PropertyName] = dependency.GetJsonData();
                }
                json["dependencies"] = jsonDependencies;
            }
            if (Enum != null)
            {
                var array = Enum.ToJson(serializer);
                array.Array.EqualityStandard = ArrayEquality.ContentsEqual;
                json["enum"] = Enum.ToJson(serializer);
            }
            if (Type != JsonSchemaType.NotDefined)
            {
                var array = Type.ToJson();
                if (array.Type == JsonValueType.Array)
                {
                    array.Array.EqualityStandard = ArrayEquality.ContentsEqual;
                }
                json["type"] = array;
            }
            if (AllOf != null)
            {
                var array = AllOf.Select(s => s.ToJson(serializer)).ToJson();
                array.EqualityStandard = ArrayEquality.ContentsEqual;
                json["allOf"]          = array;
            }
            if (AnyOf != null)
            {
                var array = AnyOf.Select(s => s.ToJson(serializer)).ToJson();
                array.EqualityStandard = ArrayEquality.ContentsEqual;
                json["anyOf"]          = array;
            }
            if (OneOf != null)
            {
                var array = OneOf.Select(s => s.ToJson(serializer)).ToJson();
                array.EqualityStandard = ArrayEquality.ContentsEqual;
                json["oneOf"]          = array;
            }
            if (Not != null)
            {
                json["not"] = Not.ToJson(serializer);
            }
            if (Format != null)
            {
                json["format"] = Format.Key;
            }
            if (ExtraneousDetails != null)
            {
                foreach (var kvp in ExtraneousDetails.Where(kvp => !_definedProperties.Contains(kvp.Key)))
                {
                    json[kvp.Key] = kvp.Value;
                }
            }
            return(json);
        }
Beispiel #17
0
        public XDocument Create()
        {
            var doc      = new XDocument(new XDeclaration("1.0", "utf-8", "no"));
            var package  = new XElement(XName.Get("package"));
            var metadata = new XElement(XName.Get("metadata"));

            package.Add(metadata);
            doc.Add(package);

            metadata.Add(new XElement(XName.Get("id"), Id));
            metadata.Add(new XElement(XName.Get("version"), Version));

            if (!string.IsNullOrEmpty(MinClientVersion))
            {
                metadata.Add(new XAttribute(XName.Get("minClientVersion"), MinClientVersion));
            }

            AddIfExists(metadata, "title", Title);
            AddIfExists(metadata, "authors", Authors);
            AddIfExists(metadata, "owners", Owners);
            AddIfExists(metadata, "description", Description);
            AddIfExists(metadata, "releaseNotes", ReleaseNotes);
            AddIfExists(metadata, "summary", Summary);
            AddIfExists(metadata, "language", Language);
            AddIfExists(metadata, "projectUrl", ProjectUrl);
            AddIfExists(metadata, "iconUrl", IconUrl);
            AddIfExists(metadata, "licenseUrl", LicenseUrl);
            AddIfExists(metadata, "copyright", Copyright);
            AddIfExists(metadata, "requireLicenseAcceptance", RequireLicenseAcceptance);
            AddIfExists(metadata, "tags", Tags);
            AddIfExists(metadata, "developmentDependency", DevelopmentDependency);

            if (Dependencies.Any())
            {
                var dependencies = new XElement(XName.Get("dependencies"));
                metadata.Add(dependencies);

                if (Dependencies.All(d => d.TargetFramework.IsAny))
                {
                    foreach (var d in Dependencies.Single().Packages)
                    {
                        var dependency = new XElement(XName.Get("dependency"));

                        dependency.Add(new XAttribute(XName.Get("id"), d.Id));
                        dependency.Add(new XAttribute(XName.Get("version"), d.VersionRange.ToLegacyShortString()));

                        dependencies.Add(dependency);
                    }
                }
                else
                {
                    foreach (var group in Dependencies)
                    {
                        var groupNode = new XElement(XName.Get("group"));
                        dependencies.Add(groupNode);

                        if (!group.TargetFramework.IsAny)
                        {
                            groupNode.Add(new XAttribute(XName.Get("targetFramework"), group.TargetFramework.GetShortFolderName()));
                        }

                        foreach (var d in group.Packages)
                        {
                            var dependency = new XElement(XName.Get("dependency"));

                            dependency.Add(new XAttribute(XName.Get("id"), d.Id));
                            dependency.Add(new XAttribute(XName.Get("version"), d.VersionRange.ToLegacyShortString()));

                            groupNode.Add(dependency);
                        }
                    }
                }
            }

            if (FrameworkAssemblies.Any())
            {
                var frameworkAssemblies = new XElement(XName.Get("frameworkAssemblies"));
                metadata.Add(frameworkAssemblies);

                foreach (var fwa in FrameworkAssemblies)
                {
                    var fwaNode = new XElement(XName.Get("frameworkAssembly"));
                    frameworkAssemblies.Add(fwaNode);
                    fwaNode.Add(new XAttribute("assemblyName", fwa.Key));
                    fwaNode.Add(new XAttribute("targetFramework", string.Join(",", fwa.Value.Select(f => f.GetShortFolderName()))));
                }
            }

            return(doc);
        }
Beispiel #18
0
        internal protected virtual void SaveToElement(PomXmlElement element)
        {
            //writing modules
            var modulesNode = element.ReadOrCreateElement("modules");

            if (!Modules.Any())
            {
                modulesNode.Remove();
            }
            else
            {
                modulesNode.RemoveAllChildElements();
                foreach (Module module in Modules)
                {
                    if (!string.IsNullOrEmpty(module.Path))
                    {
                        var moduleNode = modulesNode.CreateElement("module");
                        module.SaveTo(moduleNode);
                    }
                }
            }

            //writing dependencies
            var dependenciesNode = element.ReadOrCreateElement("dependencies");

            if (!Dependencies.Any())
            {
                dependenciesNode.Remove();
            }
            else
            {
                dependenciesNode.RemoveAllChildElements();
                foreach (Dependency dependency in Dependencies)
                {
                    var dependencyNode = dependenciesNode.CreateElement("dependency");
                    dependency.SaveToElement(dependencyNode);
                }
            }

            //writing properties
            var propertiesNode = element.ReadOrCreateElement("properties");

            if (!Properties.Any())
            {
                propertiesNode.Remove();
            }
            else
            {
                propertiesNode.RemoveAllChildElements();
                foreach (Property prop in Properties)
                {
                    prop.SaveTo(propertiesNode);
                }
            }

            var buildNode = element.ReadOrCreateElement("build");

            if (!Plugins.Any() && !PluginManagement.Any())             // empty build section
            {
                buildNode.Remove();
            }
            else
            {
                var pluginsNode = buildNode.ReadOrCreateElement("plugins");
                if (!Plugins.Any())
                {
                    pluginsNode.Remove();
                }
                else
                {
                    pluginsNode.RemoveAllChildElements();
                    foreach (Plugin plugin in Plugins)
                    {
                        var pluginNode = pluginsNode.CreateElement("plugin");
                        plugin.SaveToElement(pluginNode);
                    }
                }

                var pluginManagementNode        = buildNode.ReadOrCreateElement("pluginManagement");
                var pluginManagementPluginsNode = pluginManagementNode.ReadOrCreateElement("plugins");

                if (!PluginManagement.Any())
                {
                    pluginManagementNode.Remove();
                }
                else
                {
                    pluginManagementPluginsNode.RemoveAllChildElements();
                    foreach (Plugin plugin in PluginManagement)
                    {
                        var pluginNode = pluginManagementPluginsNode.CreateElement("plugin");
                        plugin.SaveToElement(pluginNode);
                    }
                }
            }
        }
Beispiel #19
0
 public bool IsDependentOn(IPackage package)
 {
     return(Dependencies.Any(x => x.RequiredPackage.Id == package.Id || x.IsDependentOn(package)));
 }
Beispiel #20
0
 public bool DependsOn(string nuget)
 {
     return(Dependencies.Any(x => x.MatchesName(nuget)));
 }
Beispiel #21
0
        public void RepackReferencePackage(string basePath)
        {
            var categoryName = IsNet45Stubbed ? "cat2" : "cat1";
            var packPath     = Path.Combine(basePath, categoryName, Name, Version);
            var refPath      = Path.Combine(packPath, "ref");
            var libPath      = Path.Combine(packPath, "lib");
            var dllName      = Name + ".dll";

            var frameworkAssemblies = new List <string>();

            if (IsNet45Stubbed)
            {
                SafeCopy(
                    Path.Combine(LibraryInformation.Path, "lib", "contract", dllName),
                    Path.Combine(packPath, "ref", "core10", dllName));

                SafeCopy(
                    Path.Combine(LibraryInformation.Path, "lib", "portable-wpa81+wp80+win80+net45+aspnetcore50", dllName),
                    Path.Combine(packPath, "ref", "portable-wpa81+wp80+win80+net45", dllName));

                SafeCopy(
                    Path.Combine(LibraryInformation.Path, "lib", "net45", "_._"),
                    Path.Combine(packPath, "ref", "net45", "_._"));

                // keeping this implementation in the package?
                // PROBLEM: this implementation package has many more dependencies than are stated.
                // it will need to have the dependencies added to the nupkg for core10 tfm
                // or it will need to become an implementation package
                SafeCopy(
                    Path.Combine(LibraryInformation.Path, "lib", "aspnetcore50", dllName),
                    Path.Combine(packPath, "lib", "core10", dllName));

                SafeCopy(
                    Path.Combine(LibraryInformation.Path, "lib", "net45", "_._"),
                    Path.Combine(packPath, "lib", "net45", "_._"));

                frameworkAssemblies.Add(Name);
            }
            else
            {
                SafeCopy(
                    Path.Combine(LibraryInformation.Path, "lib", "contract", dllName),
                    Path.Combine(packPath, "ref", "core10", dllName));

                SafeCopy(
                    Path.Combine(LibraryInformation.Path, "lib", "portable-wpa81+wp80+win80+net45+aspnetcore50", dllName),
                    Path.Combine(packPath, "ref", "portable-wpa81+wp80+win80+net45", dllName));

                SafeCopy(
                    Path.Combine(LibraryInformation.Path, "lib", "net45", dllName),
                    Path.Combine(packPath, "ref", "net45", dllName));

                SafeCopy(
                    Path.Combine(LibraryInformation.Path, "lib", "net45", dllName),
                    Path.Combine(packPath, "lib", "net45", dllName));

                var comp = new Comp(Path.Combine(packPath, "lib", "net45", dllName), Version);
                comp.Parse();
                foreach (var assemblyReference in comp.AssemblyReferences)
                {
                    if (!Dependencies.Any(d => d.Name == assemblyReference) && assemblyReference != "mscorlib")
                    {
                        frameworkAssemblies.Add(assemblyReference);
                    }
                }
            }


            var nuspecTemplate     = @"<?xml version=""1.0""?>
<package xmlns=""http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd"">
  <metadata>
    <id>{0}</id>
    <version>{1}</version>
    <title>{0}</title>
    <authors>Microsoft</authors>
    <owners>Microsoft</owners>
    <licenseUrl>http://go.microsoft.com/fwlink/?LinkId=329770</licenseUrl>
    <iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>
    <requireLicenseAcceptance>true</requireLicenseAcceptance>
    <description>{0}</description>
    <copyright>Copyright © Microsoft Corporation</copyright>
    <dependencies>{2}
    </dependencies>{3}
  </metadata>
</package>
";
            var dependencyTemplate = @"
      <dependency id=""{0}"" version=""{1}"" />";

            var frameworkAssembliesTemplate = @"
    <frameworkAssemblies>{0}
    </frameworkAssemblies>";

            var frameworkAssemblyTemplate = @"
      <frameworkAssembly assemblyName=""{0}"" targetFramework=""net45"" />";

            var frameworkAssembliesText = "";

            if (frameworkAssemblies.Any())
            {
                frameworkAssembliesText = frameworkAssemblies.Select(x => string.Format(frameworkAssemblyTemplate, x)).Aggregate("", (a, b) => a + b);

                frameworkAssembliesText = string.Format(frameworkAssembliesTemplate, frameworkAssembliesText);
            }

            var nuspecText = string.Format(
                nuspecTemplate,
                Name,
                Version,
                Dependencies
                .OrderBy(x => x.Name)
                .Select(x => string.Format(dependencyTemplate, x.Name, x.LibraryInformation.Version))
                .Aggregate("", (a, b) => a + b),
                frameworkAssembliesText);

            File.WriteAllText(Path.Combine(packPath, Name + ".nuspec"), nuspecText);
        }
Beispiel #22
0
        public override void UpdateVisual()
        {
            base.UpdateVisual();
            if (PathType == PathType.Straight)
            {
                switch (LineType)
                {
                case LineType.JaggedLine:
                {
                    double length = 15;
                    double angel  = Math.PI / 4;
                    Pointline = ToPhysical(OnScreenCoordinates);
                    double PILine     = -GetRadian(Pointline.P1, Pointline.P2);
                    double LineLongth = GetLength(Pointline.P1, Pointline.P2);
                    geo = new GeometryGroup();
                    binTree(Pointline.P1, Pointline.P2, length, angel, PILine, LineLongth);
                    path.StrokeThickness = this.StrokeThickness;
                    line.StrokeThickness = 0;
                    path.Data            = geo;
                    break;
                }

                case LineType.CurvyLine:
                {
                    Pointline = ToPhysical(OnScreenCoordinates);
                    PathFigure   pf = DrawWave(Pointline.P1, Pointline.P2, 20d, 11, 11);
                    PathGeometry pg = new PathGeometry();
                    pg.Figures.Add(pf);
                    path.Data            = pg;
                    path.StrokeThickness = this.StrokeThickness;
                    line.StrokeThickness = 0;
                    break;
                }

                default:
                {
                    if (this.Dependencies != null && !this.Dependencies.Any(f => f is ImmovablePoint))
                    {
                        line.StrokeThickness = this.StrokeThickness;
                    }
                    path.StrokeThickness = 0;
                    break;
                }
                }
            }
            else if (PathType == PathType.Curve)
            {
                Pointline = ToPhysical(OnScreenCoordinates);
                PathFigure   pf = DrawCurveLine(Pointline.P1, Pointline.P2, 20d, 11, 11);
                PathGeometry pg = new PathGeometry();
                pg.Figures.Add(pf);
                path.Data = pg;
                if (this.Dependencies != null && !this.Dependencies.Any(f => f is ImmovablePoint))
                {
                    path.StrokeThickness = StrokeThickness;
                }
                line.StrokeThickness = 0;
            }

            if (this.Dependencies != null && this.Dependencies.Count() > 1)
            {
                if (this.Dependencies.ElementAt(1).Dependents.Count == 2 || this.Dependencies.ElementAt(1).Dependents.Count == 1 || this.Dependencies.ElementAt(1) is Game.Zone || this.Dependencies.ElementAt(1) is Game.PBPlayer)
                {
                    cap.Fill = Brushes.White;
                    PointPair line = OnScreenCoordinates;
                    Point     p1   = line.P1;
                    Point     p2   = line.P2;

                    double angle       = System.Math.Atan((p2.Y - p1.Y) / (p2.X - p1.X));
                    bool   blockPlayer = false;

                    if (this.Dependencies.ElementAt(1) is Game.PBPlayer)
                    {
                        blockPlayer = true;

                        double logicalSpace = CoordinateSystem.LogicalPlayerSize + 0.2;

                        if (p2.X < p1.X)
                        {
                            p2.X += logicalSpace / 2 * System.Math.Cos(angle);
                            p2.Y += logicalSpace / 2 * System.Math.Sin(angle);
                        }
                        else
                        {
                            p2.X -= logicalSpace / 2 * System.Math.Cos(angle);
                            p2.Y -= logicalSpace / 2 * System.Math.Sin(angle);
                        }
                    }

                    switch (CapType)
                    {
                    case CapType.Arrow:
                    {
                        double d            = p1.Distance(p2);
                        double arrowLength  = ToLogical(16);
                        double arrowWidth   = 1.0 / 3;
                        Point  triangleBase = new Point(
                            p2.X + (p1.X - p2.X) * arrowLength / d,
                            p2.Y + (p1.Y - p2.Y) * arrowLength / d);

                        cap.Points = new System.Windows.Media.PointCollection()
                        {
                            ToPhysical(p2),
                            ToPhysical(new Point(
                                           triangleBase.X + (p2.Y - triangleBase.Y) * arrowWidth,
                                           triangleBase.Y + (triangleBase.X - p2.X) * arrowWidth)),
                            ToPhysical(new Point(
                                           triangleBase.X + (triangleBase.Y - p2.Y) * arrowWidth,
                                           triangleBase.Y + (p2.X - triangleBase.X) * arrowWidth)),
                        };
                        break;
                    }

                    case CapType.Block:
                    {
                        Shape.Set(ToPhysical(new PointPair(p1, p2)));            //04-01-2010 scott

                        double d           = p1.Distance(p2);
                        double arrowLength = ToLogical(2);
                        double arrowWidth  = ToPhysical(0.1);

                        Point triangleBase = new Point(
                            p2.X + (p1.X - p2.X) * arrowLength / d,
                            p2.Y + (p1.Y - p2.Y) * arrowLength / d);

                        double angle2 = Math.PI / 4;
                        double len2   = ToPhysical(0.005);

                        double angle3 = angle - angle2;
                        double angle4 = angle2 + angle;
                        int    i      = 1;
                        if (p2.X < p1.X)
                        {
                            i = -1;
                        }

                        cap.Points = new System.Windows.Media.PointCollection();
                        cap.Points.Add(ToPhysical(new Point(
                                                      p2.X + (p2.Y - triangleBase.Y) * arrowWidth,
                                                      p2.Y + (triangleBase.X - p2.X) * arrowWidth)));

                        if (blockPlayer)
                        {
                            cap.Points.Add(ToPhysical(new Point(
                                                          (p2.X + (p2.Y - triangleBase.Y) * arrowWidth) + i * System.Math.Cos(angle3) * len2,
                                                          (p2.Y + (triangleBase.X - p2.X) * arrowWidth) + i * System.Math.Sin(angle3) * len2)));

                            cap.Points.Add(ToPhysical(new Point(
                                                          (triangleBase.X + (p2.Y - triangleBase.Y) * arrowWidth) + i * System.Math.Cos(angle3) * len2,
                                                          (triangleBase.Y + (triangleBase.X - p2.X) * arrowWidth) + i * System.Math.Sin(angle3) * len2)));
                        }

                        cap.Points.Add(ToPhysical(new Point(
                                                      triangleBase.X + (p2.Y - triangleBase.Y) * arrowWidth,
                                                      triangleBase.Y + (triangleBase.X - p2.X) * arrowWidth)));
                        cap.Points.Add(ToPhysical(new Point(
                                                      triangleBase.X + (triangleBase.Y - p2.Y) * arrowWidth,
                                                      triangleBase.Y + (p2.X - triangleBase.X) * arrowWidth)));

                        if (blockPlayer)
                        {
                            cap.Points.Add(ToPhysical(new Point(
                                                          (triangleBase.X + (triangleBase.Y - p2.Y) * arrowWidth) + i * System.Math.Cos(angle4) * len2,
                                                          (triangleBase.Y + (p2.X - triangleBase.X) * arrowWidth) + i * System.Math.Sin(angle4) * len2)));

                            cap.Points.Add(ToPhysical(new Point(
                                                          (p2.X + (triangleBase.Y - p2.Y) * arrowWidth) + i * System.Math.Cos(angle4) * len2,
                                                          (p2.Y + (p2.X - triangleBase.X) * arrowWidth) + i * System.Math.Sin(angle4) * len2)));
                        }

                        cap.Points.Add(ToPhysical(new Point(
                                                      p2.X + (triangleBase.Y - p2.Y) * arrowWidth,
                                                      p2.Y + (p2.X - triangleBase.X) * arrowWidth)));
                        break;
                    }

                    case CapType.BlockArea:
                    {
                        double d            = p1.Distance(p2);
                        double arrowLength  = ToLogical(3);
                        double arrowWidth   = 3;
                        Point  triangleBase = new Point(
                            p2.X + (p1.X - p2.X) * arrowLength / d,
                            p2.Y + (p1.Y - p2.Y) * arrowLength / d);


                        cap.Points = new System.Windows.Media.PointCollection()
                        {
                            ToPhysical(new Point(
                                           p2.X + (p2.Y - triangleBase.Y) * arrowWidth,
                                           p2.Y + (triangleBase.X - p2.X) * arrowWidth)),
                            ToPhysical(new Point(
                                           triangleBase.X + (p2.Y - triangleBase.Y) * arrowWidth,
                                           triangleBase.Y + (triangleBase.X - p2.X) * arrowWidth)),
                            ToPhysical(new Point(
                                           triangleBase.X + (triangleBase.Y - p2.Y) * arrowWidth,
                                           triangleBase.Y + (p2.X - triangleBase.X) * arrowWidth)),
                            ToPhysical(new Point(
                                           p2.X + (triangleBase.Y - p2.Y) * arrowWidth,
                                           p2.Y + (p2.X - triangleBase.X) * arrowWidth)),
                        };
                        break;
                    }

                    case CapType.BlockPerson:
                    {
                        Shape.Set(ToPhysical(new PointPair(p1, p2)));            //04-01-2010 scott

                        double d           = p1.Distance(p2);
                        double arrowLength = ToLogical(3);
                        double arrowWidth  = ToPhysical(0.1);

                        Point triangleBase = new Point(
                            p2.X + (p1.X - p2.X) * arrowLength / d,
                            p2.Y + (p1.Y - p2.Y) * arrowLength / d);

                        double angle2 = Math.PI / 4;
                        double len2   = ToPhysical(0.005);

                        double angle3 = angle - angle2;
                        double angle4 = angle2 + angle;
                        int    i      = 1;
                        if (p2.X < p1.X)
                        {
                            i = -1;
                        }

                        cap.Points = new System.Windows.Media.PointCollection();
                        cap.Points.Add(ToPhysical(new Point(
                                                      p2.X + (p2.Y - triangleBase.Y) * arrowWidth,
                                                      p2.Y + (triangleBase.X - p2.X) * arrowWidth)));


                        cap.Points.Add(ToPhysical(new Point(
                                                      (p2.X + (p2.Y - triangleBase.Y) * arrowWidth) + i * System.Math.Cos(angle3) * len2,
                                                      (p2.Y + (triangleBase.X - p2.X) * arrowWidth) + i * System.Math.Sin(angle3) * len2)));

                        cap.Points.Add(ToPhysical(new Point(
                                                      (triangleBase.X + (p2.Y - triangleBase.Y) * arrowWidth) + i * System.Math.Cos(angle3) * len2,
                                                      (triangleBase.Y + (triangleBase.X - p2.X) * arrowWidth) + i * System.Math.Sin(angle3) * len2)));


                        cap.Points.Add(ToPhysical(new Point(
                                                      triangleBase.X + (p2.Y - triangleBase.Y) * arrowWidth,
                                                      triangleBase.Y + (triangleBase.X - p2.X) * arrowWidth)));
                        cap.Points.Add(ToPhysical(new Point(
                                                      triangleBase.X + (triangleBase.Y - p2.Y) * arrowWidth,
                                                      triangleBase.Y + (p2.X - triangleBase.X) * arrowWidth)));

                        cap.Points.Add(ToPhysical(new Point(
                                                      (triangleBase.X + (triangleBase.Y - p2.Y) * arrowWidth) + i * System.Math.Cos(angle4) * len2,
                                                      (triangleBase.Y + (p2.X - triangleBase.X) * arrowWidth) + i * System.Math.Sin(angle4) * len2)));

                        cap.Points.Add(ToPhysical(new Point(
                                                      (p2.X + (triangleBase.Y - p2.Y) * arrowWidth) + i * System.Math.Cos(angle4) * len2,
                                                      (p2.Y + (p2.X - triangleBase.X) * arrowWidth) + i * System.Math.Sin(angle4) * len2)));

                        cap.Points.Add(ToPhysical(new Point(
                                                      p2.X + (triangleBase.Y - p2.Y) * arrowWidth,
                                                      p2.Y + (p2.X - triangleBase.X) * arrowWidth)));
                        break;
                    }

                    default:
                    {
                        break;
                    }
                    }
                }
                else
                {
                    cap.Fill = Brushes.Transparent;
                }

                DoubleCollection dc = new DoubleCollection();
                switch (DashType)
                {
                case DashType.Solid:
                    break;

                case DashType.Dashed:
                    dc.Add(3);
                    dc.Add(1);
                    break;

                case DashType.Dotted:
                    dc.Add(1);
                    dc.Add(1);
                    break;
                }
                Shape.StrokeDashArray = dc;
                path.StrokeDashArray  = dc;

                if (Dependencies != null && Dependencies.Any(f => f is ImmovablePoint))
                {
                    Shape.StrokeThickness = 0.5;
                    path.StrokeThickness  = 0;
                }

                UpdateColor();
            }
        }
        /// <summary>
        ///     Get the latest assets that were produced by each subscription
        ///     and compute any conflicts between subscriptionss
        /// </summary>
        /// <returns>Mapping of assets to subscriptions that produce them.</returns>
        private async Task <Dictionary <string, Subscription> > GetLatestAssetsAndComputeConflicts(IRemote remote)
        {
            // Populate the latest build task for each of these. The search for assets would be N*M*A where N is the number of
            // dependencies, M is the number of subscriptions, and A is average the number of assets per build.
            // Because this could add up pretty quickly, we build up a dictionary of assets->List<(subscription, build)>
            // instead.
            Dictionary <string, Subscription> assetsToLatestInSubscription =
                new Dictionary <string, Subscription>(StringComparer.OrdinalIgnoreCase);
            Dictionary <string, SubscriptionConflict> subscriptionConflicts = new Dictionary <string, SubscriptionConflict>();

            foreach (Subscription subscription in Subscriptions)
            {
                // Look up the latest build and add it to the dictionary.
                Build latestBuild = await remote.GetLatestBuildAsync(subscription.SourceRepository, subscription.Channel.Id);

                if (latestBuild != null)
                {
                    foreach (var asset in latestBuild.Assets)
                    {
                        string assetName = asset.Name;

                        if (assetsToLatestInSubscription.TryGetValue(assetName, out Subscription otherSubscription))
                        {
                            // Repos can publish the same asset twice for the same build, so filter out those cases,
                            // as well as cases where the subscription is functionally the same (e.g. you have a twice daily
                            // and weekly subscription). Basically cases where the source repo and source channels are the same.

                            if (otherSubscription.SourceRepository.Equals(subscription.SourceRepository, StringComparison.OrdinalIgnoreCase) &&
                                otherSubscription.Channel.Id == subscription.Channel.Id)
                            {
                                continue;
                            }

                            // While technically this asset would need to be utilized in the dependencies
                            // to cause an issue, it's an issue waiting to happen, so stick this in the conflicting subscriptions.
                            if (subscriptionConflicts.TryGetValue(assetName, out SubscriptionConflict conflict))
                            {
                                conflict.Subscriptions.Add(subscription);
                            }
                            else
                            {
                                SubscriptionConflict newConflict = new SubscriptionConflict(assetName,
                                                                                            new List <Subscription>()
                                {
                                    otherSubscription, subscription
                                },
                                                                                            Dependencies.Any(d => d.Name.Equals(assetName, StringComparison.OrdinalIgnoreCase)));
                                subscriptionConflicts.Add(assetName, newConflict);
                            }
                        }
                        else
                        {
                            assetsToLatestInSubscription.Add(assetName, subscription);
                        }
                    }
                }
            }

            // Now there is a complete accounting of the conflicts.
            ConflictingSubscriptions = subscriptionConflicts.Values.ToList();

            return(assetsToLatestInSubscription);
        }