Пример #1
0
        public static IDictionary <string, string> ToDictionary(this XmlAttributeCollection attributes)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }

            var result = new Dictionary <string, string>();

            foreach (var attribute in attributes.OfType <XmlAttribute>())
            {
                result.Add(attribute.LocalName, attribute.Value);
            }

            return(result);
        }
        private void CompareAttributes(XmlAttributeCollection expected1, XmlAttributeCollection actual1, string path, int childNumber)
        {
            var expected = expected1.OfType <XmlAttribute>().ToList();
            var actual   = actual1.OfType <XmlAttribute>().ToList();

            foreach (XmlAttribute exp in expected1)
            {
                expected.Remove(exp);
                var act = actual.FirstOrDefault(x => x.Name == exp.Name);
                Assert.IsNotNull(act, $"{path}[{childNumber}][@{exp.Name}]");

                Assert.AreEqual(exp.Value, act.Value);
                actual.Remove(act);
            }

            foreach (var act in actual)
            {
                Assert.Fail($"Unexpected attr {path}[{childNumber}][@{act.Name}='{act.Value}']");
            }
        }
Пример #3
0
        /// <summary>
        /// Reads the attributes from the "FileList" element of the SDK manifest.
        /// </summary>
        private void ReadFileListAttributes(XmlAttributeCollection attributes)
        {
            foreach (XmlAttribute attribute in attributes.OfType <XmlAttribute>())
            {
                string value = attribute.Value.Trim();
                if (value.Length > 0)
                {
                    if (attribute.Name.StartsWith(Attributes.FrameworkIdentity, StringComparison.OrdinalIgnoreCase))
                    {
                        if (_frameworkIdentities == null)
                        {
                            _frameworkIdentities = new Dictionary <string, string>();
                        }

                        _frameworkIdentities.Add(attribute.Name, value);
                        continue;
                    }

                    if (attribute.Name.StartsWith(Attributes.APPX, StringComparison.OrdinalIgnoreCase))
                    {
                        if (_appxLocations == null)
                        {
                            _appxLocations = new Dictionary <string, string>();
                        }

                        _appxLocations.Add(attribute.Name, value);
                        continue;
                    }

                    switch (attribute.Name)
                    {
                    case Attributes.TargetPlatform:
                        TargetPlatform = value;
                        break;

                    case Attributes.TargetPlatformMinVersion:
                        TargetPlatformMinVersion = value;
                        break;

                    case Attributes.TargetPlatformVersion:
                        TargetPlatformVersion = value;
                        break;

                    case Attributes.MinVSVersion:
                        MinVSVersion = value;
                        break;

                    case Attributes.MinOSVersion:
                        _minOSVersion = value;
                        break;

                    case Attributes.MaxOSVersionTested:
                        _maxOSVersionTested = value;
                        break;

                    case Attributes.MaxPlatformVersion:
                        _maxPlatformVersion = value;
                        break;

                    case Attributes.PlatformIdentity:
                        PlatformIdentity = value;
                        break;

                    case Attributes.SupportPrefer32Bit:
                        SupportPrefer32Bit = value;
                        break;

                    case Attributes.SupportsMultipleVersions:
                        _supportsMultipleVersions = ParseSupportMultipleVersions(value);
                        break;

                    case Attributes.SDKType:
                        Enum.TryParse(value, out _sdkType);
                        break;

                    case Attributes.DisplayName:
                        DisplayName = value;
                        break;

                    case Attributes.MoreInfo:
                        MoreInfo = value;
                        break;

                    case Attributes.CopyRedistToSubDirectory:
                        CopyRedistToSubDirectory = value;
                        break;

                    case Attributes.SupportedArchitectures:
                        SupportedArchitectures = value;
                        break;

                    case Attributes.DependsOnSDK:
                        DependsOnSDK = value;
                        break;

                    case Attributes.ProductFamilyName:
                        ProductFamilyName = value;
                        break;
                    }
                }
            }
        }
Пример #4
0
 private IEnumerable <XmlAttribute> ValueAttributes(XmlAttributeCollection c)
 {
     return(c.OfType <XmlAttribute>().Where(a => a.NamespaceURI != JsonNamespaceUri));
 }
Пример #5
0
 public static bool Any(this XmlAttributeCollection attrs, Func <XmlAttribute, bool> pred)
 {
     return(attrs.OfType <XmlAttribute>().Any(pred));
 }
Пример #6
0
        public static string GetValueOrDefault(this XmlAttributeCollection xmlAttributeCollection, string attributeName, string defaultValue = default)
        {
            var xmlAttribute = xmlAttributeCollection.OfType <XmlAttribute>().FirstOrDefault(x => string.Equals(attributeName, x.Name, StringComparison.OrdinalIgnoreCase));

            return(xmlAttribute != null ? xmlAttribute.Value : defaultValue);
        }