Esempio n. 1
0
		/// <summary>
		/// Parses the <paramref name="path"/> into a <see cref="AssetFolder"/>.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="assetType">The <see cref="AssetType"/>.</param>
		/// <param name="path">The path which to parse.</param>
		/// <returns>Returns the <see cref="AssetFolder"/>.</returns>
		public AssetFolder ParseFolder(IMansionContext context, AssetType assetType, string path)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (assetType == null)
				throw new ArgumentNullException("assetType");
			if (string.IsNullOrEmpty(path))
				throw new ArgumentNullException("path");

			// if the asset type is unknown, return unknown folder
			if (assetType.Equals(AssetType.Unknown))
				return AssetFolder.Unknown;

			// get the path parts
			var parts = path.Split(Dispatcher.Constants.UrlPartTrimCharacters, StringSplitOptions.RemoveEmptyEntries);
			if (parts.Length == 0)
				return AssetFolder.Create(context, assetType, assetType.Node);

			// retrieve the folder node
			var folderNode = RetrieveFolderByNameNode(context, assetType.Node, parts);

			// create the folder
			return AssetFolder.Create(context, assetType, folderNode);
		}