/***************************************************/ /**** Public Methods ****/ /***************************************************/ public IFSContainer Create(ILocatableResource resource, PushType pushType, PushConfig pushConfig) { if (resource == null) { return(null); } IFSContainer fileOrDir = resource.ToFiling(); return(Create(fileOrDir, pushType, pushConfig)); }
/***************************************************/ public IFSContainer Create(IFSContainer fileOrDir, PushType pushType, PushConfig pushConfig) { pushConfig = pushConfig ?? new PushConfig(); if (fileOrDir == null) { return(null); } if (fileOrDir is IFile) { return(CreateJson((FSFile)fileOrDir, pushType, pushConfig) as IFSContainer); } if (fileOrDir is IDirectory) { return(CreateDirectory((FSDirectory)fileOrDir, pushType, pushConfig) as IFSContainer); } BH.Engine.Base.Compute.RecordError($"Could not create {fileOrDir.ToString()}."); return(null); }
public static oM.Adapters.File.IFSContainer ToFiling(this ILocatableResource iLocRes) { try { IFSContainer fileOrDir = null; if (iLocRes is IFile) { fileOrDir = (FSFile)Path.Combine(iLocRes.Location, iLocRes.Name ?? ""); } if (iLocRes is IDirectory) { fileOrDir = (FSDirectory)Path.Combine(iLocRes.Location, iLocRes?.Name ?? ""); } IContainableResource iContRes = iLocRes as IContainableResource; if (iContRes != null && fileOrDir != null) { fileOrDir.Content = iContRes.Content; } return(fileOrDir); } catch { } try { FSDirectory dir = (FSDirectory)Path.Combine(iLocRes.Location, iLocRes.Name ?? ""); return(dir); } catch { } BH.Engine.Base.Compute.RecordError($"The resource {iLocRes.IFullPath()} has an invalid path."); return(null); }