コード例 #1
0
        public string UrlForAsset(AssetFolder folder, string name)
        {
            var url = _inner.UrlForAsset(folder, name);

            _cache.Enqueue(url);

            return(_request.ToRelativeUrl(_directories, url));
        }
コード例 #2
0
        public static HttpResponse GetAsset(this EndpointDriver endpoints, AssetFolder folder, string name, string etag = null)
        {
            var path = new AssetPath(name, folder);

            return(endpoints.GetByInput(path, configure: request => {
                request.Headers.Add(HttpRequestHeader.IfNoneMatch, etag);
            }));
        }
コード例 #3
0
 public AssetCatalog(string path, string authorId)
 {
     if (Path.GetExtension(path) != ".xcassets")
     {
         throw new Exception("Asset catalogs must have xcassets extension");
     }
     m_Root = new AssetFolder(path, null, authorId);
 }
コード例 #4
0
ファイル: Storage.cs プロジェクト: Julien-Pires/Pulsar
        /// <summary>
        /// Adds a folder
        /// </summary>
        /// <param name="path">Path of the folder</param>
        /// <param name="name">Name of the folder</param>
        public void AddFolder(string path, string name)
        {
            if(_foldersMap.ContainsKey(name))
                throw new ArgumentException(string.Format("Failed to add, a folder named {0} already presents", name));

            AssetFolder folder = new AssetFolder(path, _engine);
            _foldersMap.Add(name, folder);
        }
コード例 #5
0
        public async Task CreateAsync(AssetFolder folder)
        {
            folder.CreatedAt  = DateTimeService.Current();
            folder.ModifiedAt = folder.CreatedAt;

            var mongo = folder.ToMongo();

            await AssetFolders.InsertOneAsync(mongo);

            folder.Id = mongo.Id;
        }
コード例 #6
0
        private async Task LoadData(AssetFolder main)
        {
            var result = await MongoStorage.Default.GetAssetFolderAsync(AssetFolderId);

            main.Id         = result.Id;
            main.CreatedAt  = result.CreatedAt;
            main.ModifiedAt = result.ModifiedAt;
            main.Version    = result.Version;
            main.Name       = result.Name;
            main.Parent     = result.Parent;
        }
コード例 #7
0
        public static RestAssetFolder ToRest(this AssetFolder folder)
        {
            RestAssetFolder restFolder = new RestAssetFolder();

            restFolder.Id         = folder.Id;
            restFolder.CreatedAt  = folder.CreatedAt;
            restFolder.ModifiedAt = folder.ModifiedAt;
            restFolder.Version    = folder.Version;
            restFolder.Name       = folder.Name;

            return(restFolder);
        }
コード例 #8
0
        public static AssetFolder ToModel(this RestAssetFolder restFolder)
        {
            AssetFolder folder = new AssetFolder();

            folder.Id         = restFolder.Id;
            folder.CreatedAt  = restFolder.CreatedAt;
            folder.ModifiedAt = restFolder.ModifiedAt;
            folder.Version    = restFolder.Version;
            folder.Name       = restFolder.Name;

            return(folder);
        }
コード例 #9
0
        public static MongoAssetFolder ToMongo(this AssetFolder asset)
        {
            MongoAssetFolder mongoAsset = new MongoAssetFolder()
            {
                Id         = asset.Id,
                CreatedAt  = asset.CreatedAt,
                ModifiedAt = asset.ModifiedAt,
                Version    = asset.Version,
                Name       = asset.Name,
                Parent     = asset.Parent?.Id
            };

            return(mongoAsset);
        }
コード例 #10
0
        AssetFolder OpenFolderForResource(string relativePath)
        {
            var pathItems = PBXPath.Split(relativePath).ToList();

            // remove path filename
            pathItems.RemoveAt(pathItems.Count - 1);

            AssetFolder folder = root;

            foreach (var pathItem in pathItems)
            {
                folder = folder.OpenFolder(pathItem);
            }
            return(folder);
        }
コード例 #11
0
        private void replaceCenterCode(TextAsset template, AssetFolder folder, string toReplace, string filename)
        {
            List <string> lines = new List <string>();

            using (var reader = new StringReader(template.text)) {
                while (true)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    lines.Add(line.Replace(TEMPLATE_NAMESPACE, TARGET_NAMESPACE).
                              Replace("_Template_", "").
                              Replace("_BitConverterTestMock_", "BitConverterNonAlloc"));
                }
            }

            string codeTemplate = lines.Query().
                                  SkipWhile(l => !l.Contains(BEGIN_KEY)).
                                  Skip(1).
                                  TakeWhile(l => !l.Contains(END_KEY)).
                                  Select(s => s + "\n").
                                  Fold((a, b) => a + b);

            string beforeCode = lines.Query().
                                TakeWhile(l => !l.Contains(BEGIN_KEY)).
                                Select(s => s + "\n").
                                Fold((a, b) => a + b);

            string afterCode = lines.Query().
                               SkipWhile(l => !l.Contains(END_KEY)).
                               Skip(1).
                               Select(s => s + "\n").
                               Fold((a, b) => a + b);

            using (var writer = File.CreateText(Path.Combine(folder.Path, filename))) {
                writer.Write(beforeCode);

                foreach (var primitiveType in primitiveTypes)
                {
                    writer.Write(codeTemplate.Replace(toReplace, primitiveType));
                }

                writer.Write(afterCode);
            }
        }
コード例 #12
0
        public static AssetFolder ToModel(this MongoAssetFolder mongoAsset)
        {
            AssetFolder asset = new AssetFolder()
            {
                Id         = mongoAsset.Id,
                CreatedAt  = mongoAsset.CreatedAt,
                ModifiedAt = mongoAsset.ModifiedAt,
                Version    = mongoAsset.Version,
                Name       = mongoAsset.Name,
            };

            if (mongoAsset.Parent != null)
            {
                asset.Parent = ContentItemProxy.CreateAssetFolder(mongoAsset.Parent.Value);
            }

            return(asset);
        }
コード例 #13
0
        /*
         * Read asset folder from JSON entry.
         */
        private static void ReadAssetFolder(AssetFolder af, JSONNode node)
        {
            af.name = node["name"] != null ? node["name"].ToString() : "Root";

            JSONArray idxArray = node["children"].AsArray;

            if (idxArray.Count == 0)
            {
                return;
            }

            af.childIds = new string[idxArray.Count];

            for (int i = 0; i < idxArray.Count; i++)
            {
                af.childIds[i] = idxArray[i];
            }
        }
コード例 #14
0
        // Checks if a folder with given name exists and returns it if it does.
        // Otherwise, creates a new folder.
        public AssetFolder OpenFolder(string name)
        {
            var item = GetChild(name);

            if (item != null)
            {
                if (item is AssetFolder)
                {
                    return(item as AssetFolder);
                }
                throw new Exception("The given path is already occupied with an asset");
            }

            var folder = new AssetFolder(m_Path, name, authorId);

            m_Items.Add(folder);
            return(folder);
        }
コード例 #15
0
        // Checks if a folder with given path exists and returns it if it does.
        // Otherwise, creates a new folder. Parent folders are created if needed.
        public AssetFolder OpenFolder(string relativePath)
        {
            if (relativePath == null)
            {
                return(root);
            }
            var pathItems = PBXPath.Split(relativePath);

            if (pathItems.Length == 0)
            {
                return(root);
            }
            AssetFolder folder = root;

            foreach (var pathItem in pathItems)
            {
                folder = folder.OpenFolder(pathItem);
            }
            return(folder);
        }
コード例 #16
0
        public void SetUp()
        {
            FubuMvcPackageFacility.PhysicalRootPath = Environment.CurrentDirectory;

            packageDirectory = ".".ToFullPath();
            _packages        = new List <IPackageInfo>();

            AssetFolderIs = AssetFolder.scripts;
            writeFile("a.js");
            writeFile("b.js");
            writeFile("folder1/c.js");
            writeFile("folder2/d.js");

            AssetFolderIs = AssetFolder.styles;
            writeFile("main.css");
            writeFile("page.css");
            writeFile("folder1/a.css");

            startPackage("pak1");
            AssetFolderIs = AssetFolder.scripts;
            writeFile("e.js");
            writeFile("f.js");

            startPackage("pak2");
            AssetFolderIs = AssetFolder.styles;
            writeFile("a.css");
            writeFile("b.css");
            writeFile("c.css");

            startPackage("pak3");
            AssetFolderIs = AssetFolder.scripts;
            writeFile("a.js");

            _theFileGraph = new AssetFileGraph();
            var activator = new AssetFileGraphBuilderActivator(_theFileGraph, new AssetLogsCache());

            theLog = new PackageLog();
            activator.Activate(_packages, theLog);

            Debug.WriteLine(theLog.FullTraceText());
        }
コード例 #17
0
        /*
         * Read assets from given JSON Class.
         */
        private static void ReadAssets(Project project, JSONClass assetsRoot, string projectPath)
        {
            List <AssetEntry>  entries = new List <AssetEntry>();
            List <AssetFolder> folders = new List <AssetFolder>();

            IEnumerator children = assetsRoot.GetEnumerator();

            while (children.MoveNext())
            {
                // Get current
                KeyValuePair <string, JSONNode> current = (children.Current != null) ?
                                                          (KeyValuePair <string, JSONNode>)children.Current : default(KeyValuePair <string, JSONNode>);
                JSONNode child = current.Value;

                // Get its ID
                string id       = current.Key;
                bool   isFolder = child["children"] != null;

                if (isFolder)
                {
                    AssetFolder folder = new AssetFolder();
                    folder.id   = id;
                    folder.name = child["root"] != null ? "Root" : child["name"].ToString();
                    ReadAssetFolder(folder, child);
                    folders.Add(folder);
                }
                else
                {
                    AssetEntry asset = new AssetEntry();
                    asset.id   = id;
                    asset.name = child["name"];
                    asset.ParseType(child["type"]);
                    asset.LinkAsset(projectPath);
                    entries.Add(asset);
                }
            }

            project.assetEntries = entries.ToArray();
            project.assetFolders = folders.ToArray();
        }
コード例 #18
0
        public void SetUp()
        {
            packageDirectory = ".".ToFullPath();
            _packages        = new List <IPackageInfo>();

            AssetFolderIs = AssetFolder.scripts;
            writeFile("a.js");
            writeFile("b.js");
            writeFile("folder1/c.js");
            writeFile("folder2/d.js");

            AssetFolderIs = AssetFolder.styles;
            writeFile("main.css");
            writeFile("page.css");
            writeFile("folder1/a.css");

            startPackage("pak1");
            AssetFolderIs = AssetFolder.scripts;
            writeFile("e.js");
            writeFile("f.js");

            startPackage("pak2");
            AssetFolderIs = AssetFolder.styles;
            writeFile("a.css");
            writeFile("b.css");
            writeFile("c.css");

            startPackage("pak3");
            AssetFolderIs = AssetFolder.scripts;
            writeFile("a.js");

            thePipeline = new AssetPipeline();
            var activator = new AssetPipelineBuilderActivator(thePipeline, new AssetLogsCache());

            theLog = new PackageLog();
            activator.Activate(_packages, theLog);

            Debug.WriteLine(theLog.FullTraceText());
        }
コード例 #19
0
        public void Intercept(IInvocation invocation)
        {
            AssetFolder main = (AssetFolder)invocation.InvocationTarget;

            if (_firstLoad == false)
            {
                main.Id = AssetFolderId;

                _firstLoad = true;
            }

            if (invocation.Method.Name != $"get_{nameof(Asset.Id)}")
            {
                if (_isLoaded == false)
                {
                    LoadData(main).Wait();

                    _isLoaded = true;
                }
            }

            invocation.Proceed();
        }
コード例 #20
0
 public async Task UpdateAsync(AssetFolder folder)
 {
     await AssetFolders.ReplaceOneAsync(Builders <MongoAssetFolder> .Filter.Where(x => x.Id == folder.Id), folder.ToMongo());
 }
コード例 #21
0
 public void css_folder_is_styles()
 {
     AssetFolder.FolderFor(MimeType.Css).ShouldEqual(AssetFolder.styles);
 }
コード例 #22
0
 public void truetype_fonts_recorded_as_images_to_force_binary()
 {
     AssetFolder.FolderFor(MimeType.TrueTypeFont).ShouldEqual(AssetFolder.fonts);
 }
コード例 #23
0
ファイル: SceneTree.cs プロジェクト: Julien-Pires/Pulsar
        /// <summary>
        /// Creates an entity
        /// </summary>
        /// <param name="name">Name of the entity</param>
        /// <param name="meshName">Name of the mesh</param>
        /// <param name="assetFolder">Asset folder</param>
        /// <returns>Returns an entity instance</returns>
        public Entity CreateEntity(string name, string meshName, AssetFolder assetFolder)
        {
            Mesh mesh = assetFolder.Load<Mesh>(meshName);

            return CreateEntity(name, mesh);
        }
コード例 #24
0
        protected async Task OpenFolder(AssetFolder folder)
        {
            SelectedFolder = folder;

            await RefreshAsync();
        }
コード例 #25
0
ファイル: PrefabFactory.cs プロジェクト: Julien-Pires/Pulsar
        /// <summary>
        /// Creates a box
        /// </summary>
        /// <param name="name">Name of the mesh</param>
        /// <param name="width">Width of the box</param>
        /// <param name="height">Height of the box</param>
        /// <param name="depth">Depth of the box</param>
        /// <param name="assetFolder">Asset folder</param>
        /// <returns>Returns a mesh instance</returns>
        public Mesh CreateBox(string name, float width, float height, float depth, AssetFolder assetFolder)
        {
            float halfWidth = width/2.0f;
            float halfHeight = height/2.0f;
            float halfDepth = height/2.0f;
            Vector3 topLeftFront = new Vector3(-halfWidth, halfHeight, halfDepth);
            Vector3 topRightFront = new Vector3(halfWidth, halfHeight, halfDepth);
            Vector3 bottomLeftFront = new Vector3(-halfWidth, -halfHeight, halfDepth);
            Vector3 bottomRightFront = new Vector3(halfWidth, -halfHeight, halfDepth);
            Vector3 topRightBack = new Vector3(-halfWidth, halfHeight, -halfDepth);
            Vector3 topLeftBack = new Vector3(halfWidth, halfHeight, -halfDepth);
            Vector3 bottomRightBack = new Vector3(-halfWidth, -halfHeight, -halfDepth);
            Vector3 bottomLeftBack = new Vector3(halfWidth, -halfHeight, -halfDepth);

            Vector3 frontNormal = new Vector3(0.0f, 0.0f, 1.0f);
            Vector3 backNormal = new Vector3(0.0f, 0.0f, -1.0f);
            Vector3 topNormal = new Vector3(0.0f, 1.0f, 0.0f);
            Vector3 bottomNormal = new Vector3(0.0f, -1.0f, 0.0f);
            Vector3 leftNormal = new Vector3(-1.0f, 0.0f, 0.0f);
            Vector3 rightNormal = new Vector3(1.0f, 0.0f, 0.0f);

            Vector2 texTopLeft = new Vector2(0.0f, 0.0f);
            Vector2 texTopRight = new Vector2(1.0f, 0.0f);
            Vector2 texBottomLeft = new Vector2(0.0f, 1.0f);
            Vector2 texBottomRight = new Vector2(1.0f, 1.0f);

            Mesh meshBox = assetFolder.Load<Mesh>(name, MeshParameters.NewInstance);
            meshBox.Bones = new Matrix[1];
            meshBox.Bones[0] = Matrix.Identity;

            meshBox.Begin(string.Empty, PrimitiveType.TriangleList, true, true, true);

            // Front
            meshBox.Position(ref bottomLeftFront); meshBox.Normal(ref frontNormal); meshBox.Texture(ref texBottomLeft);
            meshBox.Position(ref topLeftFront); meshBox.Normal(ref frontNormal); meshBox.Texture(ref texTopLeft);
            meshBox.Position(ref topRightFront); meshBox.Normal(ref frontNormal); meshBox.Texture(ref texTopRight);
            meshBox.Position(ref bottomRightFront); meshBox.Normal(ref frontNormal); meshBox.Texture(ref texBottomRight);
            meshBox.Position(ref bottomLeftFront); meshBox.Normal(ref frontNormal); meshBox.Texture(ref texBottomLeft);
            meshBox.Position(ref topRightFront); meshBox.Normal(ref frontNormal); meshBox.Texture(ref texTopRight);

            // Back
            meshBox.Position(ref bottomLeftBack); meshBox.Normal(ref backNormal); meshBox.Texture(ref texBottomLeft);
            meshBox.Position(ref topLeftBack); meshBox.Normal(ref backNormal); meshBox.Texture(ref texTopLeft);
            meshBox.Position(ref topRightBack); meshBox.Normal(ref backNormal); meshBox.Texture(ref texTopRight);
            meshBox.Position(ref bottomRightBack); meshBox.Normal(ref backNormal); meshBox.Texture(ref texBottomRight);
            meshBox.Position(ref bottomLeftBack); meshBox.Normal(ref backNormal); meshBox.Texture(ref texBottomLeft);
            meshBox.Position(ref topRightBack); meshBox.Normal(ref backNormal); meshBox.Texture(ref texTopRight);

            // Top
            meshBox.Position(ref topLeftFront); meshBox.Normal(ref topNormal); meshBox.Texture(ref texBottomLeft);
            meshBox.Position(ref topRightBack); meshBox.Normal(ref topNormal); meshBox.Texture(ref texTopLeft);
            meshBox.Position(ref topLeftBack); meshBox.Normal(ref topNormal); meshBox.Texture(ref texTopRight);
            meshBox.Position(ref topRightFront); meshBox.Normal(ref topNormal); meshBox.Texture(ref texBottomRight);
            meshBox.Position(ref topLeftFront); meshBox.Normal(ref topNormal); meshBox.Texture(ref texBottomLeft);
            meshBox.Position(ref topLeftBack); meshBox.Normal(ref topNormal); meshBox.Texture(ref texTopRight);

            // Bottom
            meshBox.Position(ref bottomLeftFront); meshBox.Normal(ref bottomNormal); meshBox.Texture(ref texTopLeft);
            meshBox.Position(ref bottomLeftBack); meshBox.Normal(ref bottomNormal); meshBox.Texture(ref texBottomRight);
            meshBox.Position(ref bottomRightBack); meshBox.Normal(ref bottomNormal); meshBox.Texture(ref texBottomLeft);
            meshBox.Position(ref bottomRightFront); meshBox.Normal(ref bottomNormal); meshBox.Texture(ref texTopRight);
            meshBox.Position(ref bottomLeftBack); meshBox.Normal(ref bottomNormal); meshBox.Texture(ref texBottomRight);
            meshBox.Position(ref bottomLeftFront); meshBox.Normal(ref bottomNormal); meshBox.Texture(ref texTopLeft);

            // Left
            meshBox.Position(ref topLeftFront); meshBox.Normal(ref leftNormal); meshBox.Texture(ref texTopRight);
            meshBox.Position(ref bottomLeftFront); meshBox.Normal(ref leftNormal); meshBox.Texture(ref texBottomRight);
            meshBox.Position(ref bottomRightBack); meshBox.Normal(ref leftNormal); meshBox.Texture(ref texBottomLeft);
            meshBox.Position(ref bottomRightBack); meshBox.Normal(ref leftNormal); meshBox.Texture(ref texBottomLeft);
            meshBox.Position(ref topRightBack); meshBox.Normal(ref leftNormal); meshBox.Texture(ref texTopLeft);
            meshBox.Position(ref topLeftFront); meshBox.Normal(ref leftNormal); meshBox.Texture(ref texTopRight);

            // Right
            meshBox.Position(ref topRightFront); meshBox.Normal(ref rightNormal); meshBox.Texture(ref texTopLeft);
            meshBox.Position(ref bottomLeftBack); meshBox.Normal(ref rightNormal); meshBox.Texture(ref texBottomRight);
            meshBox.Position(ref bottomRightFront); meshBox.Normal(ref rightNormal); meshBox.Texture(ref texBottomLeft);
            meshBox.Position(ref topLeftBack); meshBox.Normal(ref rightNormal); meshBox.Texture(ref texTopRight);
            meshBox.Position(ref bottomLeftBack); meshBox.Normal(ref rightNormal); meshBox.Texture(ref texBottomRight);
            meshBox.Position(ref topRightFront); meshBox.Normal(ref rightNormal); meshBox.Texture(ref texTopLeft);

            meshBox.End();

            string materialName = string.Format("{0}_material", name);
            meshBox.GetSubMesh(0).Material = assetFolder.Load<Material>(materialName,
                MaterialParameters.NewInstance);

            return meshBox;
        }
コード例 #26
0
        /// <summary>
        /// Resolve the url for a named asset
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public string UrlForAsset(AssetFolder folder, string name)
        {
            var relativeUrl = DetermineRelativeAssetUrl(folder, name);

            return(_httpRequest.ToFullUrl(relativeUrl));
        }
コード例 #27
0
 public void javascript_folder_is_scripts()
 {
     AssetFolder.FolderFor(MimeType.Javascript).ShouldEqual(AssetFolder.scripts);
 }
コード例 #28
0
ファイル: MimeType.cs プロジェクト: rmueller/fubumvc
 public static MimeType ForFolder(AssetFolder folder)
 {
     return(_mimeTypes.GetAll().FirstOrDefault(x => x.Folder().Equals(folder)));
 }
コード例 #29
0
ファイル: MimeType.cs プロジェクト: rmueller/fubumvc
 public MimeType Folder(AssetFolder folder)
 {
     _folder = folder;
     return(this);
 }
コード例 #30
0
 public Task UpdateAsync(AssetFolder folder)
 {
     throw new NotImplementedException();
 }
コード例 #31
0
 // TODO -- move the unit tests
 public static string DetermineRelativeAssetUrl(AssetFolder folder, string name)
 {
     return("{0}/{1}/{2}".ToFormat(AssetsUrlFolder, folder, name));
 }
コード例 #32
0
        private void writePackageFile(AssetFolder assetFolder, params string[] names)
        {
            var path = PackageDirectory.ToFullPath().AppendPath("content", assetFolder.ToString()).AppendPath(names);

            system.WriteStringToFile(path, "something");
        }