コード例 #1
0
 public void AddTwoBags(PositionsBag bagOne, PositionsBag bagTwo)
 {
     XList.AddRange(bagOne.XList);
     XList.AddRange(bagTwo.XList);
     YList.AddRange(bagOne.YList);
     YList.AddRange(bagTwo.YList);
 }
コード例 #2
0
ファイル: AutopackageModel.cs プロジェクト: virmitio/devtools
        internal void ProcessBasicPackageInformation()
        {
            // -----------------------------------------------------------------------------------------------------------------------------------
            // New Step: Validate the basic information of this package
            string pkgName = Source.PackageRules.GetProperty("name").Value;
            Architecture pkgArchitecture = Architecture.Auto;
            FourPartVersion pkgVersion = Source.PackageRules.GetPropertyValue("version");
            FlavorString pkgFlavor = Source.PackageRules.GetPropertyValue("flavor");
            string pkgPublicKeyToken = Source.Certificate.PublicKeyToken;

            if (string.IsNullOrEmpty(pkgName)) {
                Event<Error>.Raise(
                    MessageCode.MissingPackageName, Source.PackageRules.Last().SourceLocation, "Missing property 'name' in 'package' rule.");
            }

            if (pkgVersion == 0) {
                // try to figure out package version from binaries.
                // check assemblies first
                foreach (var assembly in Assemblies) {
                    pkgVersion = assembly.Version;
                    if (pkgVersion == 0) {
                        Event<Error>.Raise(
                            MessageCode.AssemblyHasNoVersion, assembly.Rule.SourceLocation, "Assembly '{0}/{1}' doesn't have a version.", assembly.Name, assembly.Culture ?? "");
                    } else {
                        Event<Warning>.Raise(
                            MessageCode.AssumingVersionFromAssembly, Assemblies.First().Rule.SourceLocation,
                            "Package Version not specified, assuming version '{0}' from first assembly", pkgVersion.ToString());

                        if (pkgArchitecture == Architecture.Auto || pkgArchitecture == Architecture.Unknown) {
                            // while we're here, let's grab this as the architecture.
                            pkgArchitecture = assembly.Architecture;
                        }

                        break;
                    }
                }
                if (pkgVersion == 0) {
                    // check application next
                    foreach (var file in DestinationDirectoryFiles) {
                        var binary = Binary.Load(file.SourcePath).Result;

                        if (binary.IsPEFile) {
                            pkgVersion = binary.FileVersion;

                            Event<Warning>.Raise(
                                MessageCode.AssumingVersionFromApplicationFile, null,
                                "Package Version not specified, assuming version '{0}' from application file '{1}'", pkgVersion.ToString(),
                                file.SourcePath);

                            if (pkgArchitecture == Architecture.Auto || pkgArchitecture == Architecture.Unknown) {
                                // while we're here, let's grab this as the architecture.
                                if (binary.IsAnyCpu) {
                                    pkgArchitecture = Architecture.Any;
                                } else if (binary.Is64Bit) {
                                    pkgArchitecture = Architecture.x64;
                                } else {
                                    pkgArchitecture = Architecture.x86;
                                }
                            }

                            break;
                        }
                    }
                }

                if (pkgVersion == 0) {
                    Event<Error>.Raise(MessageCode.UnableToDeterminePackageVersion, null, "Unable to determine package version.");
                    return; // fast fail.
                }

            }

            // set any assemblies without version numbers to package version
            foreach (var assembly in Assemblies.Where(each => each.Version == 0L)) {
                assembly.Version = pkgVersion;
            }

            // make sure that all the assemblies have the same version as the package
            foreach (var assembly in Assemblies.Where(each => each.Version != pkgVersion)) {
                Event<Error>.Raise(MessageCode.AssemblyVersionDoesNotMatch, null, "Assembly '{0}' has different version ({1}) that this package ({2}) .", assembly.Name, assembly.Version, Version);
            }

            // check to see that all the assemblies are the same version.
            var versions = Assemblies.Select(each => each.Version).Distinct().ToArray();
            if (versions.Length > 1) {
                foreach (var asm in Assemblies) {
                    Event<Error>.Raise(
                        MessageCode.MultipleAssemblyVersions, asm.Rule.SourceLocation, "All Assemblies must have the same version. '{0}' Version => {1}.",
                        asm.Name, asm.Version);
                }
                // fail fast, this is pointless.
                return;
            }

            var arch = Source.PackageRules.GetPropertyValue("arch") as string;
            arch = arch ?? Source.PackageRules.GetPropertyValue("architecture") as string;
            if ((pkgArchitecture == Architecture.Auto || pkgArchitecture == Architecture.Unknown) && arch != null) {
                pkgArchitecture = arch;
            }

            // is it still not set?
            if (pkgArchitecture == Architecture.Auto || pkgArchitecture == Architecture.Unknown) {
                // figure it out from what's going in the package.
                Event<Error>.Raise(MessageCode.UnableToDeterminePackageArchitecture, null, "Unable to determine package architecture.");
            }

            var locations = Source.PackageRules.GetPropertyValues("location").Union(Source.PackageRules.GetPropertyValues("locations"));
            if( !locations.IsNullOrEmpty()) {
                Locations = new XList<Uri>();
                Locations.AddRange(locations.Select(location => location.ToUri()).Where(uri => uri != null));
            }

            var feeds = Source.PackageRules.GetPropertyValues("feed").Union(Source.PackageRules.GetPropertyValues("feeds"));
            if (!feeds.IsNullOrEmpty()) {
                Feeds = new XList<Uri>();
                Feeds.AddRange(feeds.Select(feed => feed.ToUri()).Where(uri => uri != null));
            }

            var publisher = Source.PackageRules.GetPropertyValue("publisher");

            if( !string.IsNullOrEmpty(publisher)) {
                var identityRules = Source.IdentityRules.GetRulesByParameter(publisher);
                if (!identityRules.IsNullOrEmpty()) {
                    PackageDetails.Publisher = new Identity {
                        Name = identityRules.GetPropertyValue("name"),
                        Email = identityRules.GetPropertyValue("email"),
                        Location = identityRules.GetPropertyValue("website").ToUri()
                    };
                }
            }
            CanonicalName = string.Format("coapp:{0}{1}-{2}-{3}-{4}", pkgName, pkgFlavor, pkgVersion, pkgArchitecture, pkgPublicKeyToken);
        }
コード例 #3
0
        XList <int> CalculateRow(Topic parent, Topic[] children, MindMapLayoutArgs e)
        {
            XList <int> listHeight = new XList <int>();

            if (!parent.IsRoot)
            {
                parent.TextSize = CalculateTextSize(parent, e);
                listHeight.Add(parent.ContentBounds.Height);
            }
            XList <int> prevSubListHeight = new XList <int>();

            bool isIncrease = parent.IsRoot || parent.Type == TopicType.Barrier;
            int  i          = isIncrease ? 0 : children.Length - 1;

            while (i > -1 && i < children.Length)
            {
                Topic       subTopic      = children[i];
                XList <int> subListHeight = CalculateRow(subTopic, e);
                if (subTopic.Type == TopicType.Barrier && prevSubListHeight.Count > 1)
                {
                    prevSubListHeight.RemoveAt(0);
                    if (subListHeight.IsEmpty)
                    {
                        subListHeight.AddRange(prevSubListHeight);
                    }
                    else
                    {
                        XList <int> savedList = subListHeight;
                        subListHeight = new XList <int>();
                        subListHeight.Add(savedList[0]);
                        subListHeight.AddRange(prevSubListHeight);
                        savedList.RemoveAt(0);
                        subListHeight.AddRange(savedList);
                    }
                }

                if (parent.Type == TopicType.Barrier || parent.IsRoot)
                {
                    // Append row
                    listHeight.AddRange(subListHeight);
                }
                else
                {
                    // Merge rows
                    for (int k = 0, n = listHeight.Count; k < n; ++k)
                    {
                        if (k < subListHeight.Count)
                        {
                            listHeight[k] = Math.Max(subListHeight[k], listHeight[k]);
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (listHeight.Count < subListHeight.Count)
                    {
                        for (int k = listHeight.Count, n = subListHeight.Count; k < n; ++k)
                        {
                            listHeight.Add(subListHeight[k]);
                        }
                    }
                }
                prevSubListHeight = subListHeight;

                if (isIncrease)
                {
                    ++i;
                }
                else
                {
                    --i;
                }
            }
            return(listHeight);
        }
コード例 #4
0
 public void AddBag(PositionsBag bag)
 {
     XList.AddRange(bag.XList);
     YList.AddRange(bag.YList);
 }