/// Returns a (possibly shared) ExportFileReference for the uri. /// The destination file: /// - will have no path components in it /// - will not collide with any other destination files /// - will be similar to suggestedName (if suggestedName is passed) public static ExportFileReference GetOrCreateSafeLocal( DisambiguationContext disambiguationContext, string sourceUri, string uriBase, string suggestedName = null) { if (IsHttp(sourceUri)) { throw new ArgumentException("sourceUri"); } // Passing the same source file multiple times should give the same destination file string sourcePath = GetFullPathForUri(sourceUri, uriBase); if (disambiguationContext.m_filesByOriginalLocation.TryGetValue( sourcePath, out var existingRef)) { return(existingRef); } // A newly-seen source file should get an unused destination string exportedFileName = ExportUtils.CreateUniqueName( Path.GetFileName(suggestedName ?? sourcePath), disambiguationContext.m_exportedFileNames); var fileRef = CreateSafeLocal(sourcePath, exportedFileName); disambiguationContext.m_filesByOriginalLocation[fileRef.m_originalLocation] = fileRef; return(fileRef); }
public ExecutionContext(IDataProvider dataProvider, LocaleProvider locale, DisambiguationContext disambiguationContext, ExecutionContext previous) { // init this._DataProvider = dataProvider; this.Locale = locale; this.DisambiguationContext = disambiguationContext; this.Previous = previous; // get variables var variables = dataProvider.GetVariables(); // add -first variables for numbers var variablesFirst = variables .Where(x => x.Value is INumberVariable) .ToDictionary(x => string.Format("{0}-first", x.Key), x => (IVariable) new Data.NumberVariable(((INumberVariable)x.Value).Min)); // done this._Variables = variables.Concat(variablesFirst) .ToDictionary(x => x.Key.ToLower(), x => x.Value); }
public ExecutionContext(IDataProvider dataProvider, LocaleProvider locale, DisambiguationContext disambiguationContext) : this(dataProvider, locale, disambiguationContext, null) { }