Esempio n. 1
0
        /// <summary> Copy all data from the 'source' to this object </summary>
        /// <remarks> Returns true if any updates were done </remarks>
        internal virtual bool UpdateDataFrom(AXmlObject source)
        {
            Assert(this.GetType() == source.GetType(), "Source has different type");
            DebugAssert(this.StartOffset == source.StartOffset, "Source has different StartOffset");

            if (this.LastUpdatedFrom == source) {
                DebugAssert(this.EndOffset == source.EndOffset, "Source has different EndOffset");
                return false;
            }

            Assert(!this.IsCached, "Can not update cached item");
            Assert(source.IsCached, "Must update from cache");

            this.LastUpdatedFrom = source;
            this.StartOffset = source.StartOffset;
            // In some cases we are just updating objects of that same
            // type and position and hoping to be luckily right
            this.EndOffset = source.EndOffset;

            // Do not bother comparing - assume changed if non-null
            if (this.syntaxErrors != null || source.syntaxErrors != null) {
                // May be called again in derived class - oh, well, does not matter
                OnChanging();
                this.Document.Parser.TrackedSegments.RemoveSyntaxErrorsOf(this);
                if (source.syntaxErrors == null) {
                    this.syntaxErrors = null;
                } else {
                    this.syntaxErrors = new List<SyntaxError>();
                    foreach(var error in source.MySyntaxErrors) {
                        // The object differs, so create our own copy
                        // The source still might need it in the future and we do not want to break it
                        this.AddSyntaxError(error.Clone(this));
                    }
                }
                this.Document.Parser.TrackedSegments.AddSyntaxErrorsOf(this);
                OnChanged();
            }

            return true;
        }
Esempio n. 2
0
 /// <summary> Is call to UpdateDataFrom is allowed? </summary>
 internal bool CanUpdateDataFrom(AXmlObject source)
 {
     return
         this.GetType() == source.GetType() &&
         this.StartOffset == source.StartOffset &&
         (this.LastUpdatedFrom == source || !this.IsCached);
 }