示例#1
0
 /// <summary>
 /// Gets the parent folder of this location
 /// </summary>
 /// <param name="loc">Location</param>
 /// <param name="level">Parent level</param>
 /// <returns>Parent location</returns>
 public static ILocation GetParent(this ILocation loc, int level = 1)
 {
     if (loc.IsFile())
     {
         return(loc.Create(loc.Root, "", loc.Segments.Take(loc.Segments.Count - (level - 1))));
     }
     else
     {
         return(loc.Create(loc.Root, "", loc.Segments.Take(loc.Segments.Count - level)));
     }
 }
        public async Task <ActionResult <Location> > PostLocation(LocationDTO location)
        {
            await _location.Create(location);

            await _log.CreateLog(HttpContext, User.FindFirst("UserName").Value);

            return(CreatedAtAction("GetLocation", new { id = location.Id }, location));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description")] LocationDTO location)
        {
            if (ModelState.IsValid)
            {
                await _location.Create(location);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(location));
        }
示例#4
0
 /// <summary>
 /// Finds the relative location
 /// </summary>
 /// <param name="loc">Location</param>
 /// <param name="relativeTo">Location to get relative to</param>
 /// <param name="compType">Comparison type</param>
 /// <returns>Relative location</returns>
 public static ILocation GetRelative(this ILocation loc,
                                     ILocation relativeTo, StringComparison compType = StringComparison.CurrentCultureIgnoreCase)
 {
     if (loc.IsInLocation(relativeTo, compType))
     {
         return(loc.Create("", loc.FileName, loc.Segments.Skip(relativeTo.Segments.Count)));
     }
     else
     {
         throw new BaseUserMessageException($"'{loc.ToId()}' location is not within the '{relativeTo.ToId()}'");
     }
 }
示例#5
0
        private SecureLibraryLoader ResolveSecureLibrary(IComponentContext ctx, string manifestPath, string publicKeyXml)
        {
            if (!System.IO.File.Exists(manifestPath))
            {
                throw new UserMessageException($"Specified library manifest file is not found: {manifestPath}");
            }

            var manifest = new UserSettingsService().ReadSettings <SecureLibraryManifest>(
                manifestPath, new BaseValueSerializer <ILocation>(null, x => Location.FromString(x)));

            ILocation libLoc = Location.FromString(manifestPath);

            libLoc = libLoc.Create(libLoc.Root, "", libLoc.Segments);

            return(ctx.Resolve <SecureLibraryLoader>(
                       new TypedParameter(typeof(ILocation), libLoc),
                       new TypedParameter(typeof(SecureLibraryManifest), manifest),
                       new TypedParameter(typeof(string), publicKeyXml)));
        }
示例#6
0
 public LocationBO Post([FromBody] LocationBO location)
 {
     return(_location.Create(location));
 }
示例#7
0
 /// <summary>
 /// Combines location with aditional data
 /// </summary>
 /// <param name="loc">Location</param>
 /// <param name="blocks">Blocks to append to location</param>
 /// <returns>New combined location</returns>
 public static ILocation Combine(this ILocation loc, params string[] blocks)
 {
     return(loc.Create(loc.Root, "", loc.Segments.Concat(blocks)));
 }
示例#8
0
 /// <see cref="Combine(ILocation, string[])"/>
 /// <param name="other">Other location to append to this location</param>
 public static ILocation Combine(this ILocation loc, ILocation other)
 {
     return(loc.Create(loc.Root, other.FileName, loc.Segments.Concat(other.Segments)));
 }