/// <summary> /// Initializes a new instance of the <see cref="ResourceLanguage" /> class. /// </summary> /// <param name="container">The containing resource entity.</param> /// <param name="cultureKey">The culture key.</param> /// <param name="file">The .resx file having all the localization.</param> /// <param name="duplicateKeyHandling">How to handle duplicate keys.</param> /// <exception cref="System.InvalidOperationException"> /// </exception> internal ResourceLanguage([NotNull] ResourceEntity container, [NotNull] CultureKey cultureKey, [NotNull] ProjectFile file, DuplicateKeyHandling duplicateKeyHandling) { Contract.Requires(container != null); Contract.Requires(cultureKey != null); Contract.Requires(file != null); _container = container; _cultureKey = cultureKey; _file = file; try { _document = file.Load(); _documentRoot = _document.Root; } catch (XmlException ex) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidResourceFileError, file.FilePath), ex); } if (_documentRoot == null) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidResourceFileError, file.FilePath)); } var defaultNamespace = _documentRoot.GetDefaultNamespace(); _dataNodeName = defaultNamespace.GetName(@"data"); _valueNodeName = defaultNamespace.GetName(@"value"); _commentNodeName = defaultNamespace.GetName(@"comment"); UpdateNodes(file, duplicateKeyHandling); }
internal void OnProjectFileSaved([NotNull] ResourceLanguage language, [NotNull] ProjectFile projectFile) { Contract.Requires(projectFile != null); ProjectFileSaved?.Invoke(this, new ProjectFileEventArgs(language, projectFile)); }
internal CodeReference([NotNull] ProjectFile projectFile, int lineNumber, [NotNull][ItemNotNull] IList <string> lineSegments) { ProjectFile = projectFile; LineNumber = lineNumber; LineSegments = lineSegments; }
/// <summary> /// Initializes a new instance of the <see cref="ResourceLanguage" /> class. /// </summary> /// <param name="container">The containing resource entity.</param> /// <param name="cultureKey">The culture key.</param> /// <param name="file">The .resx file having all the localization.</param> /// <exception cref="System.InvalidOperationException"> /// </exception> internal ResourceLanguage([NotNull] ResourceEntity container, [NotNull] CultureKey cultureKey, [NotNull] ProjectFile file) { Container = container; CultureKey = cultureKey; ProjectFile = file; _configuration = container.Container.Configuration; try { _document = file.Load(); } catch (XmlException ex) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidResourceFileError, file.FilePath), ex); } if (DocumentRoot == null) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidResourceFileError, file.FilePath)); } var defaultNamespace = DocumentRoot.GetDefaultNamespace(); _dataNodeName = defaultNamespace.GetName(@"data"); _valueNodeName = defaultNamespace.GetName(@"value"); _commentNodeName = defaultNamespace.GetName(@"comment"); UpdateNodes(); }
public bool IsSourceFile(ProjectFile file) { Contract.Requires(file != null); return(_extensions.Contains(file.Extension, StringComparer.OrdinalIgnoreCase)); }
public static bool IsCSharpFile(this ProjectFile projectFile) { Contract.Requires(projectFile != null); return(Path.GetExtension(projectFile.FilePath).Equals(".cs", StringComparison.OrdinalIgnoreCase)); }
public static bool IsDesignerFile(this ProjectFile projectFile) { Contract.Requires(projectFile != null); return(projectFile.GetBaseName().EndsWith(".Designer", StringComparison.OrdinalIgnoreCase)); }
internal void OnProjectFileSaved([NotNull] ResourceLanguage language, [NotNull] ProjectFile projectFile) { ProjectFileSaved?.Invoke(this, new ProjectFileEventArgs(language, projectFile)); }
public static bool IsCSharpFile([NotNull] this ProjectFile projectFile) { return(Path.GetExtension(projectFile.FilePath).Equals(".cs", StringComparison.OrdinalIgnoreCase)); }
public static bool IsDesignerFile([NotNull] this ProjectFile projectFile) { return(projectFile.GetBaseName().EndsWith(".Designer", StringComparison.OrdinalIgnoreCase)); }