internal ChoIniNameValueNode(ChoIniDocument ownerDocument, string name, string value, char nameValueSeperator, ChoIniCommentNode inlineCommentNode) : base(ownerDocument) { ChoGuard.ArgumentNotNullOrEmpty(name, "Name"); //Check for valid delimiter if (ownerDocument.NameValueSeperator != nameValueSeperator) { throw new ChoIniDocumentException(String.Format("Invalid NameValue Seperator [{0}] passed.", nameValueSeperator)); } _nameValueSeperator = nameValueSeperator; _name = name.Trim(); if (!ownerDocument.IgnoreValueWhiteSpaces) { _rawValue = value; } else { _rawValue = value != null?value.Trim() : null; } _inlineCommentNode = inlineCommentNode; NormalizeValue(); }
internal ChoIniIncludeFileNode(ChoIniDocument ownerDocument, string filePath, ChoIniCommentNode inlineCommentNode, Stream stream = null) : base(ownerDocument) { ChoGuard.ArgumentNotNullOrEmpty(filePath, "Ini Include File Path"); _filePath = filePath; _inlineCommentNode = inlineCommentNode; ChoIniDocument iniDocument = OwnerDocument; while (true) { if (iniDocument == null) { break; } if (_filePath == iniDocument.Path) { throw new ChoIniDocumentException(String.Format("Can't include {0} document, it is already included in the include chain of documents.", _filePath)); } iniDocument = iniDocument.ParentIniDocument; } _iniDocument = new ChoIniDocument(_filePath, ownerDocument); }
internal ChoIniSectionNode(ChoIniDocument ownerDocument, string name, ChoIniCommentNode inlineCommentNode) : base(ownerDocument) { ChoGuard.ArgumentNotNullOrEmpty(name, "Name"); _name = name != null?name.Trim() : null; _inlineCommentNode = inlineCommentNode; }
private static ChoIniDocument OpenNLoadDocument(string filePath) { ChoIniDocument iniDocument = ChoIniDocument.Load(filePath); iniDocument.TextIgnored += new EventHandler <ChoIniDocumentEventArgs>(iniDocument_IgnoredEntry); iniDocument.TextErrorFound += new EventHandler <ChoIniDocumentEventArgs>(iniDocument_ErrorFound); return(iniDocument); }
public ChoIniDocumentService(string name, ChoIniDocument iniDocument) { ChoGuard.ArgumentNotNull(name, "Name"); ChoGuard.ArgumentNotNull(iniDocument, "IniDocument"); _iniDocument = iniDocument; _queuedMsgService = new ChoQueuedMsgService <string>(name, ChoStandardQueuedMsgObject <string> .QuitMsg, false, false, QueueMessageHandler); _timerService = new ChoTimerService <string>(String.Format("{0}_Timer", _iniDocument.GetHashCode()), new ChoTimerService <string> .ChoTimerServiceCallback(OnTimerServiceCallback), null, 1000, 5000, false); }
private static ChoIniDocument LoadDocument(string filePath) { lock (_iniDocuments.SyncRoot) { if (!_iniDocuments.ContainsKey(filePath)) { _iniDocuments.Add(filePath, OpenNLoadDocument(filePath)); } else if (_iniDocuments[filePath].IsDisposed) { _iniDocuments[filePath] = ChoIniDocument.Load(filePath); } return(_iniDocuments[filePath]); } }
internal object GetData() { if (!IniFilePath.IsNullOrWhiteSpace() && File.Exists(IniFilePath)) { using (ChoIniDocument iniDocument = ChoIniDocument.Load(IniFilePath)) { ChoIniSectionNode iniSectionNode = iniDocument.GetSection(IniSectionName); if (iniSectionNode != null) { return(iniSectionNode.ToNameValueCollection()); } } } return(null); }
internal void SaveData(object data) { if (!(data is NameValueCollection)) { throw new ChoConfigurationException("Data object is not NameValueCollection object."); } NameValueCollection nameValueCollection = data as NameValueCollection; if (!IniFilePath.IsNullOrWhiteSpace()) { if (!File.Exists(IniFilePath)) { using (File.CreateText(IniFilePath)) { } } using (ChoIniDocument iniDocument = new ChoIniDocument(IniFilePath)) { ChoIniSectionNode sectionNode = iniDocument.GetSection(IniSectionName); if (sectionNode == null) { sectionNode = iniDocument.AddSection(IniSectionName); } sectionNode.ClearNodes(); foreach (string key in nameValueCollection.AllKeys) { sectionNode.AddNameValueNode(key, nameValueCollection[key] == null ? String.Empty : nameValueCollection[key].ToString()); } sectionNode.AppendNewLine(); iniDocument.Save(); } } }
internal ChoIniNewLineNode(ChoIniDocument ownerDocument) : base(ownerDocument) { }
internal ChoIniSectionNode(ChoIniDocument ownerDocument, string name) : this(ownerDocument, name, null) { }
internal ChoIniNode(ChoIniDocument ownerDocument) { _ownerDocument = ownerDocument; }
internal ChoIniNameValueNode(ChoIniDocument ownerDocument, string name, string value, char nameValueSeperator) : this(ownerDocument, name, value, nameValueSeperator, null) { }
internal ChoIniCommentNode(ChoIniDocument ownerDocument, string commentLine, char commentChar) : base(ownerDocument) { Value = commentLine; CommentChar = commentChar; }
internal ChoIniCommentNode(ChoIniDocument ownerDocument, string commentLine) : this(ownerDocument, commentLine, ownerDocument.FirstAvailableCommentChar) { }
internal ChoIniIncludeFileNode(ChoIniDocument ownerDocument, string filePath, string commentLine, Stream stream = null) : this(ownerDocument, filePath, String.IsNullOrEmpty(commentLine) ? null : new ChoIniCommentNode(ownerDocument, commentLine), stream) { }
internal ChoIniIncludeFileNode(ChoIniDocument ownerDocument, string filePath) : this(ownerDocument, filePath, (string)null) { }