Esempio n. 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);
        }
Esempio n. 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();
        }
Esempio n. 3
0
        internal ChoIniSectionNode(ChoIniDocument ownerDocument, string name, ChoIniCommentNode inlineCommentNode)
            : base(ownerDocument)
        {
            ChoGuard.ArgumentNotNullOrEmpty(name, "Name");

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

            _inlineCommentNode = inlineCommentNode;
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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));
            }
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
 }
Esempio n. 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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 12
0
 public override void Clear()
 {
     OwnerDocument.Dirty = true;
     _iniNodes.Clear();
     _inlineCommentNode = null;
 }
Esempio n. 13
0
        public bool RemoveCommentNode(string commentLine)
        {
            ChoIniCommentNode commentNode = GetCommentNode(commentLine);

            return(Remove(commentNode));
        }
Esempio n. 14
0
        public ChoIniCommentNode AddCommentNode(string commentLine)
        {
            ChoIniCommentNode commentNode = new ChoIniCommentNode(OwnerDocument, commentLine);

            return(AddIniNode(commentNode) as ChoIniCommentNode);
        }
Esempio n. 15
0
 public ChoIniCommentNode CreateOrReplaceInlineCommentNode(ChoIniCommentNode inlineCommentNode)
 {
     _inlineCommentNode = inlineCommentNode;
     return(_inlineCommentNode);
 }
Esempio n. 16
0
 public void ReplaceInlineComment(ChoIniCommentNode InlineComment)
 {
     _inlineCommentNode = InlineComment;
 }
Esempio n. 17
0
 public void RemoveInlineComment()
 {
     _inlineCommentNode = null;
 }