private void CodeTest_Click(object sender, RoutedEventArgs e) { var csharpSetting = new CSharpSetting() { RootPath = Environment.CurrentDirectory, }; var typeScope = new RelativeScope <CSharpSetting>(csharpSetting, "TypeScope"); var groupScope = new RelativeScope <CSharpSetting>(csharpSetting, "GroupScope", typeScope); var projectScope = new RootScope("ProjectScope"); var otherScope = new RelativeScope <CSharpSetting>(csharpSetting, "OtherScope", typeScope); var otherProjectScope = new CombineScope <CSharpSetting>(csharpSetting, projectScope, otherScope); var basePath = new RootPath(csharpSetting.RootPath); var secondPath = new RelativePath <CSharpSetting>(csharpSetting, "ProjectPath", basePath); var mappingPath = new ScopeMappingPath <CSharpSetting>(csharpSetting, secondPath, groupScope, projectScope); var testType = new CSharpGenerateType(csharpSetting, mappingPath, mappingPath, "TestType"); testType.Usings.Scopes.Add(otherProjectScope); testType.TypeDocumentation.Summary = "テストサマリー\r\nサマリー2行目"; OutputBlock.Text = SBHelper.ToString(sb => { sb.AppendLine(testType.GenerateFileName()); testType.ApppendStrings(sb); sb.AppendLine(testType.GenerateFullTypeName()); }); }
public void ConfigureAll(Configuration conf, Target target) { conf.ProjectPath = RootPath; conf.ProjectFileName = "[project.Name].[target.DevEnv]"; conf.Output = Configuration.OutputType.DotNetClassLibrary; conf.Options.Add(Options.CSharp.LanguageVersion.CSharp5); conf.Defines.Add(_projectInfo.Defines.ToArray()); foreach (var projectReference in _projectInfo.ProjectReferences) { conf.AddPrivateDependency(target, projectReference); } DebugProjectGenerator.DebugProjectExtension.AddReferences(conf, _projectInfo.References); DebugProjectGenerator.DebugProjectExtension.AddSharpmakePackage(conf); // set up custom configuration only to setup project if (string.CompareOrdinal(conf.ProjectPath.ToLower(), RootPath.ToLower()) == 0 && _projectInfo.IsSetupProject) { conf.SetupProjectOptions(_projectInfo.StartArguments); } }
/// <inheritdoc /> public IFile GetInputFile(FilePath path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } if (path.IsRelative) { IFile notFound = null; foreach (DirectoryPath inputPath in InputPaths.Reverse()) { IFile file = GetFile(RootPath.Combine(inputPath).CombineFile(path)); if (notFound == null) { notFound = file; } if (file.Exists) { return(file); } } if (notFound == null) { throw new InvalidOperationException("The input paths collection must have at least one path"); } return(notFound); } return(GetFile(path)); }
private string BuildResourcePath(string resourcePath) { string fullPath; string assemblyPath = SourceAssembly.GetName().Name; if (!string.IsNullOrWhiteSpace(RootPath)) { if (!RootPath.StartsWith(assemblyPath, StringComparison.Ordinal)) { fullPath = $"{assemblyPath}.{RootPath}.{resourcePath}"; } else { fullPath = $"{RootPath}.{resourcePath}"; } } else { if (resourcePath.StartsWith(assemblyPath, StringComparison.Ordinal)) { fullPath = resourcePath; } else { fullPath = $"{assemblyPath}.{resourcePath}"; } } return(fullPath); }
public virtual void Initialize(Action <DavServerOptions> setupAction, IDictionary <string, string> properties) { if (properties == null) { throw new ArgumentNullException(nameof(properties)); } var path = properties.GetNullifiedValue(nameof(RootPath)); if (string.IsNullOrWhiteSpace(path)) { throw new DavServerException("0002: Configuration is missing parameter '" + nameof(RootPath) + "'."); } if (!Path.IsPathRooted(path)) { throw new DavServerException("0004: Parameter '" + nameof(RootPath) + "' must be rooted."); } // make sure we use long file names RootPath = path; if (!RootPath.StartsWith(@"\\?\")) { RootPath = LongFileNamePrefix + RootPath; } if (!Extensions.DirectoryExists(RootPath)) { throw new DavServerException("0006: Directory root path '" + path + "' cannot be found, please check the appsettings.json file."); } setupAction?.Invoke(Options); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="mode">出力モード</param> /// <param name="inputCSRoot">入力:C#のルートパス</param> /// <param name="inputFile">出力:TypeScriptのルートパス</param> /// <param name="outputTSRoot">出力:TypeScriptのルートパス</param> private Config(OutputMode mode, RootPath inputCSRoot, RootPath outputTSRoot, FilePath inputFile) { Mode = mode; InputCSRoot = inputCSRoot; InputFile = inputFile; OutputTSRoot = outputTSRoot; }
/// <summary> /// Writes the appropriate PersonsStore properties to the config file. /// </summary> public static void WriteConfig() { // xml document creation. var xmlDoc = new XmlDocument(); // root node creation. XmlNode rootNode = xmlDoc.CreateElement("config"); xmlDoc.AppendChild(rootNode); XmlNode rootPathNode = xmlDoc.CreateElement("rootPath"); rootPathNode.InnerText = RootPath.ToString(); rootNode.AppendChild(rootPathNode); // XmlWritter settings -> how the xml will be created in file. XmlWriterSettings settings = new XmlWriterSettings { Encoding = Encoding.UTF8, ConformanceLevel = ConformanceLevel.Document, OmitXmlDeclaration = false, CloseOutput = true, Indent = true, IndentChars = " ", NewLineHandling = NewLineHandling.Replace }; // Save the xml to the config file. using (FileStream configStream = File.Open(ConfigFilePath, FileMode.Create)) using (XmlWriter writer = XmlWriter.Create(configStream, settings)) { xmlDoc.WriteContentTo(writer); } }
public NtStatus GetFileInformation(Path path, out FileInformation fileInfo, IDokanFileInfo info) { fileInfo = default; return(path switch { // Dirs RootPath p => GetFileInformation(p, out fileInfo), DatabasePath p => GetFileInformation(p, out fileInfo), CollectionPath p => GetFileInformation(p, out fileInfo), DataDirectoryPath p => GetFileInformation(p, out fileInfo), QueryDirectoryPath p => GetFileInformation(p, out fileInfo), QueryEmptyDirectoryPath p => GetFileInformation(p, out fileInfo), // Files StatsPath p => GetFileInformation(p, out fileInfo), IndexesPath p => GetFileInformation(p, out fileInfo), CurrentOpPath p => GetFileInformation(p, out fileInfo), ServerStatusPath p => GetFileInformation(p, out fileInfo), BuildInfoPath p => GetFileInformation(p, out fileInfo), HostInfoPath p => GetFileInformation(p, out fileInfo), ListCommandsPath p => GetFileInformation(p, out fileInfo), DataDocumentPath p => GetFileInformation(p, out fileInfo), QueryDocumentPath p => GetFileInformation(p, out fileInfo), QueryAllDocumentsPath p => GetFileInformation(p, out fileInfo), var p => LogFailure(p) });
public PathInfo CountPathFiles(RootPath rootPath) { PathInfo pathInfo = Context.PathInfos.Where(pi => String.Equals(pi.RootPath, rootPath.Path)).SingleOrDefault(); if (pathInfo == null) { pathInfo = new PathInfo(); pathInfo.RootPath = rootPath.Path; Context.Entry(pathInfo).State = System.Data.Entity.EntityState.Added; } else { Context.Entry(pathInfo).State = System.Data.Entity.EntityState.Modified; } Viewer viewer = new Viewer(pathInfo); if (!viewer.WidthBrowsePath()) { Context.Entry(pathInfo).State = System.Data.Entity.EntityState.Detached; return(null); } Context.SaveChanges(); return(pathInfo); }
/// <summary> /// Builds up a relative path based on specified segment parts. /// </summary> /// <param name="path">Path segments</param> /// <returns>Returns a relative path.</returns> public string GetPath(string[] path) { string[] childPath = path ?? new string[] { }; // create result path string resultPath = PathUtil.Combine(childPath); resultPath = resultPath.Trim('/', '\\'); // prepend root path with corrected separators // remove all leading and trailing separator chars string cleansedRoot = RootPath.Trim('/', '\\'); // replace all slashes with directory separator cleansedRoot = cleansedRoot.Replace('/', PathUtil.DirectorySeparatorChar); // replace all backslashes with directory separator cleansedRoot = cleansedRoot.Replace('\\', PathUtil.DirectorySeparatorChar); if (!resultPath.StartsWith(cleansedRoot)) { resultPath = Path.Join(cleansedRoot, resultPath); } // if root path is relative, add relative separator if (RootPath.StartsWith(PathUtil.DirectorySeparatorChar) || RootPath.StartsWith(PathUtil.AltDirectorySeparatorChar)) { resultPath = PathUtil.DirectorySeparatorChar + resultPath; } return(resultPath); }
private void LoadDefaults() { Language = Configuration.CodeGeneration.GetLanguage(); RootPath = Configuration.CodeGeneration.GetOutputPath(); RootFile = Configuration.CodeGeneration.GetOutputFile(); RootPath = RootPath.Replace("\\.\\", "\\"); CodeGenerationFileType[] types = { CodeGenerationFileType.AttributeConstants, CodeGenerationFileType.Entities, CodeGenerationFileType.OptionSets, CodeGenerationFileType.Requests, CodeGenerationFileType.Responses, CodeGenerationFileType.ServiceContext }; foreach (var type in types) { var options = Configuration.CodeGeneration.GetOutputOptions(type); string file = options.GetComputedFile(RootPath); string path = Path.GetDirectoryName(file); OutputFiles.Add(type, file); OutputPaths.Add(type, path); } }
public PathInfo TransiteToPath(RootPath rootPath) { Viewer viewer = new Viewer(); string transitedPath = viewer.TryTransite(rootPath.NewPath, rootPath.Path); if (transitedPath == null) { return(null); } PathInfo pathInfo = Context.PathInfos.SingleOrDefault(p => String.Equals(p.RootPath, transitedPath)); if (pathInfo == null) { pathInfo = new PathInfo(); pathInfo.RootPath = transitedPath; } viewer.PathInfo = pathInfo; if (!viewer.Observe()) { return(null); } return(pathInfo); }
/// <inheritdoc /> public DirectoryPath GetContainingInputPath(NormalizedPath path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } if (path.IsAbsolute) { return(InputPaths .Reverse() .Select(x => RootPath.Combine(x)) .FirstOrDefault(x => x.FileProvider == path.FileProvider && (path.FullPath == x.Collapse().FullPath || path.FullPath.StartsWith(x.Collapse().FullPath + "/")))); } FilePath filePath = path as FilePath; if (filePath != null) { IFile file = GetInputFile(filePath); return(file.Exists ? GetContainingInputPath(file.Path) : null); } DirectoryPath directoryPath = path as DirectoryPath; if (directoryPath != null) { return(InputPaths .Reverse() .Select(x => new KeyValuePair <DirectoryPath, IDirectory>(x, GetRootDirectory(x.Combine(directoryPath)))) .Where(x => x.Value.Exists) .Select(x => RootPath.Combine(x.Key)) .FirstOrDefault()); } return(null); }
public override void Init() { if (RootPathType == RootPathType.Default) { if (RootPath == null) { RootPath = String.Format("data/data/{0}/", Package.Name); } else { if (RootPath[0] == '/') { RootPath = RootPath.Substring(1); } if (RootPath.Last() != '/') { RootPath += '/'; } } } else if (RootPathType == RootPathType.PathPrepare) { RootPathPrepareRegexes = Package.RootPathPrepares.First(c => c.Name == RootPath).PathRegexes; } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (AccountName != null) { hashCode = hashCode * 59 + AccountName.GetHashCode(); } if (ContainerName != null) { hashCode = hashCode * 59 + ContainerName.GetHashCode(); } if (AccessKey != null) { hashCode = hashCode * 59 + AccessKey.GetHashCode(); } if (RootPath != null) { hashCode = hashCode * 59 + RootPath.GetHashCode(); } if (ConnectionURL != null) { hashCode = hashCode * 59 + ConnectionURL.GetHashCode(); } return(hashCode); } }
public static void AddRootPath(RootPath rootPath) { if (rootPath != null && !RootPaths.Contains(rootPath)) { RootPaths.Add(rootPath); RootPaths.Sort(); } }
/// <inheritdoc /> public FilePath GetTempPath(FilePath path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } return(RootPath.Combine(TempPath).CombineFile(path)); }
/// <inheritdoc /> public IFile GetRootFile(FilePath path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } return(GetFile(RootPath.CombineFile(path))); }
public IDirectory GetRootDirectory(DirectoryPath path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } return(GetDirectory(RootPath.Combine(path))); }
public override int GetHashCode() { unchecked { int hashCode = (RootPath != null ? RootPath.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Item1 != null ? Item1.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Item2 != null ? Item2.GetHashCode() : 0); return(hashCode); } }
private static bool OpenUNC(RootPath rootPath, out UNC unc) { unc = null; if (rootPath.IsUNCPath && !string.IsNullOrEmpty(rootPath.UserName)) { unc = new UNC(rootPath.Path, rootPath.Domain, rootPath.UserNameWithoutDomain, rootPath.Password); return(unc.Open()); } return(true); }
public LinuxStorageRoot(LinuxStorageProvider storageProvider, string rootPath) : base(storageProvider) { RootPath = rootPath ?? throw new ArgumentNullException(nameof(rootPath)); if (!RootPath.EndsWith("/")) { RootPath += "/"; } Uri = new Uri($"file://{(RootPath == "/" ? RootPath : RootPath.TrimEnd('/'))}"); }
private void GCStaticRootsImpl(GCRoot gcroot) { ulong target = gcroot.Heap.GetObjectsOfType("TargetType").Single(); RootPath[] paths = gcroot.EnumerateGCRoots(target, false, CancellationToken.None).ToArray(); Assert.AreEqual(1, paths.Length); RootPath rootPath = paths[0]; AssertPathIsCorrect(gcroot.Heap, rootPath.Path.ToArray(), rootPath.Path.First().Address, target); }
/// <summary> /// Initialises the packages store by validating parameters, then connecting to the network share. /// </summary> /// <exception cref="ArgumentNullException"> if <paramref name="DriveLetter"/> is null or contains only whitespace or <paramref name="RootPath"/> is null or contains only whitespace or <paramref name="UserName"/> is null or contains only whitespace or <paramref name="AccessKey"/> is null or contains only whitespace or <paramref name="FileShareName"/> is null or contains only whitespace.</exception> /// <exception cref="ArgumentOutOfRangeException"> if <paramref name="DriveLetter"/> does not match ^[A-Za-z]:$ or <paramref name="RootPath"/> does not start with <paramref name="DriveLetter"/></exception> private void InitPackageStore() { _logger = Logger.Initialise(LogFileName); _fileSystemOperations.Logger = _logger; if (string.IsNullOrWhiteSpace(DriveLetter)) { throw new ArgumentNullException("DriveLetter"); } if (!Regex.IsMatch(DriveLetter, "^[A-Za-z]:$")) { throw new ArgumentOutOfRangeException("DriveLetter", "DriveLetter must be a single drive letter (A-Z) followed by a colon"); } if (string.IsNullOrWhiteSpace(RootPath)) { throw new ArgumentNullException("RootPath"); } if (!RootPath.ToLower().StartsWith(DriveLetter.ToLower())) { throw new ArgumentOutOfRangeException("RootPath", "RootPath must be on the drive specified by DriveLetter (ie, if DriveLetter='P:', then RootPath must start with 'P:\'"); } if (string.IsNullOrWhiteSpace(UserName)) { throw new ArgumentNullException("UserName"); } if (string.IsNullOrWhiteSpace(AccessKey)) { throw new ArgumentNullException("AccessKey"); } if (string.IsNullOrWhiteSpace(FileShareName)) { throw new ArgumentNullException("FileShareName"); } var uncPath = string.Format(@"\\{0}.file.core.windows.net\{1}", UserName, FileShareName); try { _logger.DebugFormat("Mapping network share '{0}' to drive '{1}' with username '{2}'", uncPath, DriveLetter, UserName); var stopWatch = new Stopwatch(); stopWatch.Start(); _fileShareMapper.Mount(DriveLetter, uncPath, UserName, AccessKey, _logger); stopWatch.Stop(); _logger.DebugFormat("Drive mapping successful and took {0} milliseconds.", stopWatch.ElapsedMilliseconds); } catch (Exception ex) { _logger.Error(String.Format("Exception occurred mapping drive '{0}' to '{1}' with username '{2}'", DriveLetter, uncPath, UserName), ex); throw; } }
public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } var compareTo = (LocalStorageLocation)obj; return(RootPath.Equals(compareTo.RootPath, StringComparison.CurrentCultureIgnoreCase)); }
private bool ExtractRARContent(string rarFilePath, RootPath rootPath, Record record) { bool success = true; SubRecord subRecord = null; _lastRARVolume = string.Empty; Unrar unrar = new Unrar(rarFilePath) { DestinationPath = (EngineSettings.UseSpecificOutputFolder ? Path.Combine(EngineSettings.OutputFolder, FileHandler.GetDeltaPath(Path.GetDirectoryName(rarFilePath), rootPath.Path)) : Path.GetDirectoryName(rarFilePath)) }; unrar.ExtractionProgress += unrar_ExtractionProgress; unrar.MissingVolume += unrar_MissingVolume; unrar.NewVolume += unrar_NewVolume; unrar.PasswordRequired += unrar_PasswordRequired; try { unrar.Open(Unrar.OpenMode.Extract); while (success && unrar.ReadHeader()) { WriteLogEntry("Extracting file, name=" + unrar.CurrentFile.FileName + ", size=" + unrar.CurrentFile.UnpackedSize + ", path=" + unrar.DestinationPath); subRecord = new SubRecord(unrar.DestinationPath, unrar.CurrentFile.FileName, unrar.CurrentFile.UnpackedSize); AddSubRecord(record.ID, subRecord); unrar.Extract(); success = ValidateExtractedFile(Path.Combine(unrar.DestinationPath, unrar.CurrentFile.FileName), unrar.CurrentFile.UnpackedSize, GetRARFileCRC(_lastRARVolume, unrar.CurrentFile.FileName)); if (!success) { WriteLogEntry(LogType.Warning, "Validation FAILED, aborting extraction"); } AddSubRecord(record.ID, (success ? subRecord.Succeed() : subRecord.Fail())); } } catch (Exception ex) { WriteLogEntry("An exception occurred while extracting from RAR file, path=" + rarFilePath + ", destination=" + unrar.DestinationPath, ex); if (subRecord != null) { AddSubRecord(record.ID, subRecord.Fail()); } success = false; } finally { unrar.Close(); unrar.ExtractionProgress -= unrar_ExtractionProgress; unrar.MissingVolume -= unrar_MissingVolume; unrar.NewVolume -= unrar_NewVolume; unrar.PasswordRequired -= unrar_PasswordRequired; } return(success); }
public string MapTo(RootPath root, string path) { if (this.Contains(path)) { string rel = this.GetRel(path); return(root.Combine(rel)); } else { throw new System.ArgumentOutOfRangeException("path", "does not contain this path"); } }
private void listViewRootPath_DoubleClick(object sender, EventArgs e) { if (listViewRootPath.SelectedItems.Count == 1) { RootPath selectedRootPath = (RootPath)listViewRootPath.SelectedItems[0].Tag; RootPathForm rootPathForm = new RootPathForm(_settingsWorker, selectedRootPath); if (rootPathForm.ShowDialog(this) == DialogResult.OK) { _settingsWorker.UpdateRootPath(); } } }
/// <summary> /// Connect to the FTP server using the supplied Url, UserName and Password. /// Then change directory to the supplied Site and Home root paths. /// </summary> /// <returns></returns> public override FtpResponse Connect() { FtpResponse resp = base.Connect(); RootPath absRoot = CompleteHomePath; if (absRoot != null) { ChangeDirectory(absRoot.ToString()); } return(resp); }
public void AddRootPath(RootPath rootPath) { try { EngineSettings.AddRootPath(rootPath); RegistryHandler.SaveEngineSettings(EngineSettingsType.RootPaths); RaiseRootPathListUpdatedEvent(EngineSettings.RootPaths); } catch (Exception ex) { CommonWorker.ShowError(ex); } }
protected void AddPath(RootPath path) { _paths.Add(path); }