Пример #1
0
        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);
        }
Пример #2
0
        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();
        }
Пример #3
0
        internal ChoIniSectionNode(ChoIniDocument ownerDocument, string name, ChoIniCommentNode inlineCommentNode)
            : base(ownerDocument)
        {
            ChoGuard.ArgumentNotNullOrEmpty(name, "Name");

            _name = name != null?name.Trim() : null;

            _inlineCommentNode = inlineCommentNode;
        }
Пример #4
0
        public ChoIniCommentNode AddInlineComment(string inlineComment)
        {
            ChoIniCommentNode inlineCommentNode = new ChoIniCommentNode(OwnerDocument, inlineComment);

            if (!OwnerDocument.OnNodeInserting(this, inlineCommentNode))
            {
                OwnerDocument.Dirty = true;
                _inlineCommentNode  = inlineCommentNode;
                OwnerDocument.OnNodeInserted(this, inlineCommentNode);
            }
            return(_inlineCommentNode);
        }
Пример #5
0
        public ChoIniCommentNode AddInlineCommentNode(ChoIniCommentNode inlineCommentNode)
        {
            if (!OwnerDocument.OnNodeInserting(this, inlineCommentNode))
            {
                OwnerDocument.Dirty = true;
                _inlineCommentNode  = inlineCommentNode;
                OwnerDocument.OnNodeInserted(this, inlineCommentNode);

                return(_inlineCommentNode);
            }

            return(null);
        }
Пример #6
0
        public ChoIniCommentNode GetCommentNode(string commentLine)
        {
            ChoIniCommentNode commentNode = null;

            if (TryGetCommentNode(commentLine, out commentNode))
            {
                return(commentNode);
            }
            else
            {
                throw new ChoIniDocumentException(String.Format("Can't find comment node. [Comment: {0}]", commentLine));
            }
        }
Пример #7
0
        public bool ReplaceInlineComment(ChoIniCommentNode inlineCommentNode)
        {
            if (!OwnerDocument.OnNodeChanging(this, _inlineCommentNode, inlineCommentNode, ChoIniNodeChangedAction.ReplaceNode))
            {
                OwnerDocument.Dirty = true;
                ChoIniCommentNode oldValue = _inlineCommentNode;
                _inlineCommentNode = inlineCommentNode;
                OwnerDocument.OnNodeChanged(this, oldValue, _inlineCommentNode, ChoIniNodeChangedAction.ReplaceNode);
            }
            else
            {
                return(false);
            }

            return(true);
        }
Пример #8
0
        public bool RemoveInlineComment()
        {
            if (!OwnerDocument.OnNodeRemoving(this, _inlineCommentNode))
            {
                OwnerDocument.Dirty = true;
                ChoIniCommentNode oldValue = _inlineCommentNode;
                _inlineCommentNode = null;
                OwnerDocument.OnNodeRemoved(this, oldValue);
            }
            else
            {
                return(false);
            }

            return(true);
        }
Пример #9
0
 public bool TryGetCommentNode(string commentLine, out ChoIniCommentNode commentNode)
 {
     commentNode = null;
     foreach (ChoIniNode iniNode in _iniNodes)
     {
         if (!(iniNode is ChoIniCommentNode))
         {
             continue;
         }
         if (((ChoIniCommentNode)iniNode).Value == commentLine)
         {
             commentNode = iniNode as ChoIniCommentNode;
             return(true);
         }
     }
     return(false);
 }
Пример #10
0
        public bool ReplaceInlineComment(string inlineComment)
        {
            ChoIniCommentNode inlineCommentNode = new ChoIniCommentNode(OwnerDocument, inlineComment);

            if (!OwnerDocument.OnNodeChanging(this, _inlineCommentNode, inlineCommentNode, ChoIniNodeChangedAction.ReplaceNode))
            {
                OwnerDocument.Dirty = true;
                object oldValue = _inlineCommentNode;
                _inlineCommentNode = inlineCommentNode;
                OwnerDocument.OnNodeChanged(this, oldValue, _inlineCommentNode, ChoIniNodeChangedAction.ReplaceNode);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #11
0
        public bool ReplaceCommentNode(string origCommentLine, string newCommentLine)
        {
            ChoIniCommentNode newCommentNode = new ChoIniCommentNode(OwnerDocument, newCommentLine);
            ChoIniCommentNode commentNode    = GetCommentNode(origCommentLine);

            if (!OwnerDocument.OnNodeChanging(this, commentNode, newCommentNode, ChoIniNodeChangedAction.ReplaceNode))
            {
                OwnerDocument.Dirty = true;
                object oldValue = commentNode;
                commentNode.Value = newCommentLine;
                OwnerDocument.OnNodeChanged(this, oldValue, newCommentNode, ChoIniNodeChangedAction.ReplaceNode);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #12
0
 public override void Clear()
 {
     OwnerDocument.Dirty = true;
     _iniNodes.Clear();
     _inlineCommentNode = null;
 }
Пример #13
0
        public bool RemoveCommentNode(string commentLine)
        {
            ChoIniCommentNode commentNode = GetCommentNode(commentLine);

            return(Remove(commentNode));
        }
Пример #14
0
        public ChoIniCommentNode AddCommentNode(string commentLine)
        {
            ChoIniCommentNode commentNode = new ChoIniCommentNode(OwnerDocument, commentLine);

            return(AddIniNode(commentNode) as ChoIniCommentNode);
        }
Пример #15
0
 public ChoIniCommentNode CreateOrReplaceInlineCommentNode(ChoIniCommentNode inlineCommentNode)
 {
     _inlineCommentNode = inlineCommentNode;
     return(_inlineCommentNode);
 }
Пример #16
0
 public void ReplaceInlineComment(ChoIniCommentNode InlineComment)
 {
     _inlineCommentNode = InlineComment;
 }
Пример #17
0
 public void RemoveInlineComment()
 {
     _inlineCommentNode = null;
 }