Exemple #1
0
 public override void AddReference(string assetRelativePath, int lineNumber)
 {
     if (assetRelativePath.IsUrl())
     {
         AddUrlReference(assetRelativePath, lineNumber);
     }
     else
     {
         string appRelativeFilename;
         if (assetRelativePath.StartsWith("~"))
         {
             appRelativeFilename = assetRelativePath;
         }
         else if (assetRelativePath.StartsWith("/"))
         {
             appRelativeFilename = "~" + assetRelativePath;
         }
         else
         {
             var subDirectory = SourceFile.Directory.FullPath;
             appRelativeFilename = PathUtilities.CombineWithForwardSlashes(
                 subDirectory,
                 assetRelativePath
                 );
         }
         appRelativeFilename = PathUtilities.NormalizePath(appRelativeFilename);
         AddBundleReference(appRelativeFilename, lineNumber);
     }
 }
        T CreateBundle(string directoryName, IDirectory directory, IBundleFactory <T> bundleFactory)
        {
            var descriptor = GetBundleDescriptor(directory);

            if (descriptor.ExternalUrl != null)
            {
                return(bundleFactory.CreateExternalBundle(directoryName, descriptor));
            }
            else
            {
                var bundle = bundleFactory.CreateBundle(directoryName);
                if (descriptor.References.Any())
                {
                    bundle.AddReferences(descriptor.References);
                }
                bundle.AddAssets(
                    descriptor.AssetFilenames.Select(
                        assetFilename => new Asset(
                            PathUtilities.CombineWithForwardSlashes(bundle.Path, assetFilename),
                            bundle,
                            directory.GetFile(assetFilename)
                            )
                        ),
                    descriptor.AssetsSorted
                    );

                return(bundle);
            }
        }
Exemple #3
0
 void ParseAsset(string line)
 {
     if (line != "*" && !line.StartsWith("~"))
     {
         line = PathUtilities.NormalizePath(PathUtilities.CombineWithForwardSlashes(sourceFile.Directory.FullPath, line));
     }
     assetFilenames.Add(line);
 }
Exemple #4
0
 void ParseReference(string line)
 {
     if (!line.StartsWith("~"))
     {
         line = PathUtilities.NormalizePath(PathUtilities.CombineWithForwardSlashes(sourceFile.Directory.FullPath, line));
     }
     references.Add(line);
 }
        string GetImageFilename(Group matchedUrlGroup, string currentDirectory)
        {
            var originalUrl = matchedUrlGroup.Value.Trim('"', '\'');

            if (originalUrl.StartsWith("/"))
            {
                return(PathUtilities.NormalizePath("~" + originalUrl));
            }
            return(PathUtilities.NormalizePath(PathUtilities.CombineWithForwardSlashes(currentDirectory, originalUrl)));
        }
Exemple #6
0
 string NormalizePath(string path, Bundle bundle)
 {
     path = path.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
     if (path.StartsWith("~"))
     {
         return(path);
     }
     else
     {
         return(PathUtilities.CombineWithForwardSlashes(bundle.Path, path));
     }
 }
Exemple #7
0
        T CreateBundle(string filename, IBundleFactory <T> bundleFactory, IDirectory directory)
        {
            var name   = RemoveFileExtension(filename);
            var bundle = bundleFactory.CreateBundle(PathUtilities.CombineWithForwardSlashes(basePath, name));
            var asset  = new Asset(
                PathUtilities.CombineWithForwardSlashes(basePath, filename),
                bundle,
                directory.GetFile(filename)
                );

            bundle.AddAssets(new[] { asset }, true);
            return(bundle);
        }
Exemple #8
0
        string GetImageFilename(Group matchedUrlGroup, string currentDirectory,
                                out string queryString, out string fragment)
        {
            var originalUrl = matchedUrlGroup.Value.Trim('"', '\'');

            originalUrl = SplitOnLastOccurence(originalUrl, '#', out fragment);
            originalUrl = SplitOnLastOccurence(originalUrl, '?', out queryString);

            if (originalUrl.StartsWith("/"))
            {
                return(PathUtilities.NormalizePath("~" + originalUrl));
            }
            return(PathUtilities.NormalizePath(PathUtilities.CombineWithForwardSlashes(currentDirectory, originalUrl)));
        }
Exemple #9
0
        public override void AddRawFileReference(string relativeFilename)
        {
            var appRelativeFilename = relativeFilename.StartsWith("~")
                ? relativeFilename
                : PathUtilities.NormalizePath(PathUtilities.CombineWithForwardSlashes(
                                                  SourceFile.Directory.FullPath,
                                                  relativeFilename
                                                  ));

            var alreadyExists = references.Any(r => r.Path.Equals(appRelativeFilename, StringComparison.OrdinalIgnoreCase));

            if (alreadyExists)
            {
                return;
            }

            references.Add(new AssetReference(appRelativeFilename, this, -1, AssetReferenceType.RawFilename));
        }
Exemple #10
0
        string ConvertReferenceToAppRelative(string reference)
        {
            if (reference.IsUrl())
            {
                return(reference);
            }

            if (reference.StartsWith("~"))
            {
                return(PathUtilities.NormalizePath(reference));
            }
            else if (reference.StartsWith("/"))
            {
                return(PathUtilities.NormalizePath("~" + reference));
            }
            else
            {
                return(PathUtilities.NormalizePath(PathUtilities.CombineWithForwardSlashes(
                                                       Path,
                                                       reference
                                                       )));
            }
        }
Exemple #11
0
        public override void AddRawFileReference(string relativeFilename)
        {
            if (relativeFilename.StartsWith("/"))
            {
                relativeFilename = "~" + relativeFilename;
            }
            else if (!relativeFilename.StartsWith("~"))
            {
                relativeFilename = PathUtilities.NormalizePath(PathUtilities.CombineWithForwardSlashes(
                                                                   sourceFile.Directory.FullPath,
                                                                   relativeFilename
                                                                   ));
            }

            var alreadyExists = references.Any(r => r.ToPath.Equals(relativeFilename, StringComparison.OrdinalIgnoreCase));

            if (alreadyExists)
            {
                return;
            }

            references.Add(new AssetReference(Path, relativeFilename, -1, AssetReferenceType.RawFilename));
        }