Пример #1
0
 private void AddChildren(XElement element, SignRequestItem package)
 {
     foreach (var child in element.Elements())
     {
         package.AddChild(ReadElement(child));
     }
 }
Пример #2
0
        private SignRequestItem ReadNupkg(XElement element)
        {
            var package = SignRequestItem.CreateNugetPackage(GetPath(element), GetCertificate(element));

            AddChildren(element, package);
            return(package);
        }
Пример #3
0
        private SignRequestItem ReadZip(XElement element)
        {
            var zip = SignRequestItem.CreateZip(GetPath(element));

            AddChildren(element, zip);
            return(zip);
        }
Пример #4
0
        private SignRequestItem ReadVsix(XElement element)
        {
            var vsix = SignRequestItem.CreateVsix(GetPath(element), GetCertificate(element));

            AddChildren(element, vsix);
            return(vsix);
        }
Пример #5
0
        /// <summary>
        /// Add a child type.
        /// </summary>
        /// <param name="item"></param>
        public void AddChild(SignRequestItem item)
        {
            if (!CanContainChildren)
            {
                throw new InvalidOperationException("Cannot add a child to items which do not allow nested files");
            }

            _children.Add(item);
        }
        private static void AddContainer(XElement parent, SignRequestItem item, string elementType)
        {
            var container = new XElement(elementType, new XAttribute(XmlElementNames.Path, item.Path));

            if (!string.IsNullOrEmpty(item.Certificate))
            {
                container.Add(new XAttribute(XmlElementNames.Certificate, item.Certificate));
            }

            parent.Add(container);

            foreach (var i in item.Children)
            {
                AddRequest(container, i);
            }
        }
        private static void AddRequest(XElement parent, SignRequestItem item)
        {
            var path = new XAttribute(XmlElementNames.Path, item.Path);

            switch (item.ItemType)
            {
            case SignRequestItemType.Zip:
                AddContainer(parent, item, XmlElementNames.Zip);
                break;

            case SignRequestItemType.Nupkg:
                AddContainer(parent, item, XmlElementNames.Nupkg);
                break;

            case SignRequestItemType.Vsix:
                AddContainer(parent, item, XmlElementNames.Vsix);
                break;

            case SignRequestItemType.Exclusion:
                parent.Add(new XElement(XmlElementNames.ExcludedFile, path));
                break;

            case SignRequestItemType.File:
                var file = new XElement(XmlElementNames.File, path);

                if (!string.IsNullOrEmpty(item.Certificate))
                {
                    file.Add(new XAttribute(XmlElementNames.Certificate, item.Certificate));
                }

                if (!string.IsNullOrEmpty(item.StrongName))
                {
                    file.Add(new XAttribute(XmlElementNames.StrongName, item.StrongName));
                }

                parent.Add(file);
                break;

            default:
                throw new InvalidOperationException("Unrecognized sign request item");
            }
        }
Пример #8
0
 private static SignRequestItem ReadFile(XElement element)
 => SignRequestItem.CreateFile(GetPath(element), GetCertificate(element), GetStrongName(element));
Пример #9
0
 private static SignRequestItem ReadExclusion(XElement element)
 => SignRequestItem.CreateExclusion(GetPath(element));