void Deserialize(string xml)
        {
            var element = XElement.Parse(xml);
            var reader  = new AssetManifestReader(element);

            assetManifest = reader.Read();
        }
 void AddReferences(AssetManifest assetManifest)
 {
     foreach (var referenceElement in element.Elements("Reference"))
     {
         AddReference(assetManifest, referenceElement);
     }
 }
 public AssetManifestWriter_Tests()
 {
     containerElement = new XElement("Bundle");
     var writer = new AssetManifestWriter(containerElement);
     assetManifest = new AssetManifest
     {
         Path = "~/asset",
         References =
             {
                 new AssetReferenceManifest
                 {
                     Path = "~/bundle",
                     Type = AssetReferenceType.DifferentBundle,
                     SourceLineNumber = 1
                 },
                 new AssetReferenceManifest
                 {
                     Path = "~/image.png",
                     Type = AssetReferenceType.RawFilename,
                     SourceLineNumber = 2
                 },
                 new AssetReferenceManifest
                 {
                     Path = "http://example.com/",
                     Type = AssetReferenceType.Url,
                     SourceLineNumber = 3
                 }
             }
     };
     writer.Write(assetManifest);
     assetElement = containerElement.Elements("Asset").FirstOrDefault();
 }
Beispiel #4
0
 void AddReferences(AssetManifest assetManifest)
 {
     foreach (var referenceElement in element.Elements("Reference"))
     {
         AddReference(assetManifest, referenceElement);
     }
 }
        public AssetManifestWriter_Tests()
        {
            containerElement = new XElement("Bundle");
            var writer = new AssetManifestWriter(containerElement);

            assetManifest = new AssetManifest
            {
                Path       = "~/asset",
                References =
                {
                    new AssetReferenceManifest
                    {
                        Path             = "~/bundle",
                        Type             = AssetReferenceType.DifferentBundle,
                        SourceLineNumber = 1
                    },
                    new AssetReferenceManifest
                    {
                        Path             = "~/image.png",
                        Type             = AssetReferenceType.RawFilename,
                        SourceLineNumber = 2
                    },
                    new AssetReferenceManifest
                    {
                        Path             = "http://example.com/",
                        Type             = AssetReferenceType.Url,
                        SourceLineNumber = 3
                    }
                }
            };
            writer.Write(assetManifest);
            assetElement = containerElement.Elements("Asset").FirstOrDefault();
        }
 XElement AssetElement(AssetManifest assetManifest)
 {
     return new XElement(
         "Asset",
         new XAttribute("Path", assetManifest.Path),
         ReferenceElements(assetManifest.References)
     );
 }
Beispiel #7
0
 XElement AssetElement(AssetManifest assetManifest)
 {
     return(new XElement(
                "Asset",
                new XAttribute("Path", assetManifest.Path),
                ReferenceElements(assetManifest.References)
                ));
 }
 public AssetManifest Read()
 {
     var assetManifest = new AssetManifest
     {
         Path = GetPathAttribute()
     };
     AddReferences(assetManifest);
     return assetManifest;
 }
Beispiel #9
0
        public AssetManifest Read()
        {
            var assetManifest = new AssetManifest
            {
                Path = GetPathAttribute()
            };

            AddReferences(assetManifest);
            return(assetManifest);
        }
Beispiel #10
0
        public void AssetsManifestsWithSamePathAreEqual()
        {
            var manifest1 = new AssetManifest {
                Path = "~/path"
            };
            var manifest2 = new AssetManifest {
                Path = "~/path"
            };

            manifest1.Equals(manifest2).ShouldBeTrue();
        }
Beispiel #11
0
        public void AssetsManifestsWithSamePathButDifferentlyCasedAreEqual()
        {
            var manifest1 = new AssetManifest {
                Path = "~/PATH"
            };
            var manifest2 = new AssetManifest {
                Path = "~/path"
            };

            manifest1.Equals(manifest2).ShouldBeTrue();
        }
 void AddReference(AssetManifest assetManifest, XElement referenceElement)
 {
     var path = referenceElement.AttributeValueOrThrow("Path", () => new InvalidCassetteManifestException("Reference manifest element missing \"Path\" attribute."));
     var typeString = referenceElement.AttributeValueOrThrow("Type", () => new InvalidCassetteManifestException("Reference manifest element missing \"Type\" attribute."));
     var sourceLineNumberString = referenceElement.AttributeValueOrThrow("SourceLineNumber", () => new InvalidCassetteManifestException("Reference manifest element missing \"SourceLineNumber\" attribute."));
     assetManifest.References.Add(new AssetReferenceManifest
     {
         Path = path,
         Type = ParseAssetReferenceType(typeString),
         SourceLineNumber = ParseSourceLineNumber(sourceLineNumberString)
     });
 }
Beispiel #13
0
        public AssetManifest BuildManifest(IAsset asset)
        {
            var assetManifest = new AssetManifest
            {
                Path = asset.SourceFile.FullPath
            };

            foreach (var reference in GetReferences(asset))
            {
                assetManifest.References.Add(reference);
            }
            return(assetManifest);
        }
Beispiel #14
0
        void AddReference(AssetManifest assetManifest, XElement referenceElement)
        {
            var path                   = referenceElement.AttributeValueOrThrow("Path", () => new InvalidCassetteManifestException("Reference manifest element missing \"Path\" attribute."));
            var typeString             = referenceElement.AttributeValueOrThrow("Type", () => new InvalidCassetteManifestException("Reference manifest element missing \"Type\" attribute."));
            var sourceLineNumberString = referenceElement.AttributeValueOrThrow("SourceLineNumber", () => new InvalidCassetteManifestException("Reference manifest element missing \"SourceLineNumber\" attribute."));

            assetManifest.References.Add(new AssetReferenceManifest
            {
                Path             = path,
                Type             = ParseAssetReferenceType(typeString),
                SourceLineNumber = ParseSourceLineNumber(sourceLineNumberString)
            });
        }
        public AssetManifestBuilder_Tests()
        {
            var asset = new Mock<IAsset>();
            asset.SetupGet(a => a.SourceFile.FullPath).Returns("~/asset");
            bundleReference = new AssetReference("~/bundle", asset.Object, 1, AssetReferenceType.DifferentBundle);
            urlReference = new AssetReference("http://example.com/", asset.Object, 2, AssetReferenceType.Url);
            rawFileReference = new AssetReference("~/file", asset.Object, 3, AssetReferenceType.RawFilename);
            var sameBundleReference = new AssetReference("~/same", asset.Object, 4, AssetReferenceType.SameBundle);
            asset.SetupGet(a => a.References)
                 .Returns(new[] { bundleReference, urlReference, rawFileReference, sameBundleReference });

            var builder = new AssetManifestBuilder();
            manifest = builder.BuildManifest(asset.Object);
        }
        public AssetManifestBuilder_Tests()
        {
            var asset = new Mock <IAsset>();

            asset.SetupGet(a => a.SourceFile.FullPath).Returns("~/asset");
            bundleReference  = new AssetReference("~/bundle", asset.Object, 1, AssetReferenceType.DifferentBundle);
            urlReference     = new AssetReference("http://example.com/", asset.Object, 2, AssetReferenceType.Url);
            rawFileReference = new AssetReference("~/file", asset.Object, 3, AssetReferenceType.RawFilename);
            var sameBundleReference = new AssetReference("~/same", asset.Object, 4, AssetReferenceType.SameBundle);

            asset.SetupGet(a => a.References)
            .Returns(new[] { bundleReference, urlReference, rawFileReference, sameBundleReference });

            var builder = new AssetManifestBuilder();

            manifest = builder.BuildManifest(asset.Object);
        }
 public void AssetsManifestsWithSamePathButDifferentlyCasedAreEqual()
 {
     var manifest1 = new AssetManifest { Path = "~/PATH" };
     var manifest2 = new AssetManifest { Path = "~/path" };
     manifest1.Equals(manifest2).ShouldBeTrue();
 }
 public void AssetsManifestsWithSamePathAreEqual()
 {
     var manifest1 = new AssetManifest { Path = "~/path" };
     var manifest2 = new AssetManifest { Path = "~/path" };
     manifest1.Equals(manifest2).ShouldBeTrue();
 }
 void Deserialize(string xml)
 {
     var element = XElement.Parse(xml);
     var reader = new AssetManifestReader(element);
     assetManifest = reader.Read();
 }
Beispiel #20
0
 public AssetFromManifest(AssetManifest assetManifest)
 {
     this.assetManifest = assetManifest;
 }
Beispiel #21
0
 public AssetFromManifest(AssetManifest assetManifest)
 {
     this.assetManifest = assetManifest;
 }
Beispiel #22
0
 public void Write(AssetManifest assetManifest)
 {
     container.Add(AssetElement(assetManifest));
 }
 public void Write(AssetManifest assetManifest)
 {
     container.Add(AssetElement(assetManifest));
 }