private string GetImportVariable(string specPath) { specPath = DScriptWriterUtils.GetPathFromExpression(specPath); // Check whether producer of variableName is the same file or not. if (DScriptWriterUtils.NormalizePath(AbsolutePath).EndsWith(specPath, StringComparison.Ordinal)) { return(string.Empty); } specPath = DScriptWriterUtils.RemoveFileEnding(specPath); string variableName; if (m_imports.TryGetValue(specPath, out variableName)) { // return null; return(variableName); } variableName = "P" + m_counter++; m_imports.Add(specPath, variableName); Writer.WriteLine("import * as {1} from '{0}.dsc';", DScriptWriterUtils.NormalizePath(specPath), variableName); return(variableName); }
/// <inheritdoc /> public override void AddSpec(string specRelativePath, SpecWriter specWriter) { var dsSpecWriter = specWriter as DScriptSpecWriter; if (dsSpecWriter != null && !m_specs.ContainsKey(specRelativePath)) { var importSpec = new ImportSpec(dsSpecWriter, "P" + m_importCounter++); m_specs[specRelativePath] = importSpec; string normalizedPath = DScriptWriterUtils.NormalizePath(specRelativePath); string name = normalizedPath.Replace("/", "__").Replace(".", "__").Replace("-", "_"); Writer.WriteLine("import * as Mimic{1} from '/{0}';", normalizedPath, name); } }