public void AddAssemblyPartItem(ManifestAssemblyPartItem item)
 {
     if (!AssemblyPartsToAdd.Any(p => p.Source.ToLower() == item.Source.ToLower()))
     {
         AssemblyPartsToAdd.Add(item);
     }
 }
コード例 #2
0
        private SilverlightManifestAnalysisResult ParseManifestContent(string manifestContent)
        {
            var result = new SilverlightManifestAnalysisResult();

            var manifest = XDocument.Parse(manifestContent);
            if (manifest.Root == null)
            {
                throw new Exception("Manifest does not have Root element");
            }

            var entryPointAssemblyAttribute = manifest.Root.Attribute("EntryPointAssembly");
            result.EntryPointAssemblyName = entryPointAssemblyAttribute != null ? entryPointAssemblyAttribute.Value : null;

            var entryPointTypeAttribute = manifest.Root.Attribute("EntryPointType");
            result.EntryPointTypeName = entryPointTypeAttribute != null ? entryPointTypeAttribute.Value : null;

            var manifestItems = manifest.Root.Descendants().First().Descendants();
            result.AssemblyPartItems.Clear();

            foreach (var manifestItem in manifestItems)
            {
                var name = manifestItem.Attribute(_nameAttributeName);
                var source = manifestItem.Attribute("Source");

                if (name != null &&  source != null)
                {
                    var nameValue = name.Value;
                    var sourceValue = source.Value;

                    if (!string.IsNullOrEmpty(nameValue) && !string.IsNullOrEmpty(sourceValue))
                    {
                        var currentAssemblyPart = new ManifestAssemblyPartItem()
                                                  {
                                                      Source = sourceValue,
                                                      Name = nameValue
                                                  };

                        result.AssemblyPartItems.Add(currentAssemblyPart);

                        if (!string.IsNullOrEmpty(result.EntryPointAssemblyName))
                        {
                            if (currentAssemblyPart.Name == result.EntryPointAssemblyName)
                            {
                                result.EntryPointAssemblyDllName = currentAssemblyPart.Source;
                            }
                        }
                    }
                }
            }

            return result;
        }