示例#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;
 }