示例#1
0
 /// <summary>
 /// An <see cref="AttributeSource"/> that uses the same attributes as the supplied one.
 /// </summary>
 public AttributeSource(AttributeSource input)
 {
     if (input == null)
     {
         throw new System.ArgumentException("input AttributeSource must not be null");
     }
     this.attributes     = input.attributes;
     this.attributeImpls = input.attributeImpls;
     this.currentState   = input.currentState;
     this.factory        = input.factory;
 }
示例#2
0
 /// <summary>
 /// An <see cref="AttributeSource"/> that uses the same attributes as the supplied one.
 /// </summary>
 public AttributeSource(AttributeSource input)
 {
     if (input is null)
     {
         throw new ArgumentNullException(nameof(input), "input AttributeSource must not be null"); // LUCENENET specific - changed from IllegalArgumentException to ArgumentNullException (.NET convention)
     }
     this.attributes     = input.attributes;
     this.attributeImpls = input.attributeImpls;
     this.currentState   = input.currentState;
     this.factory        = input.factory;
 }
示例#3
0
 /// <summary>
 /// Copies the contents of this <see cref="AttributeSource"/> to the given target <see cref="AttributeSource"/>.
 /// The given instance has to provide all <see cref="IAttribute"/>s this instance contains.
 /// The actual attribute implementations must be identical in both <see cref="AttributeSource"/> instances;
 /// ideally both <see cref="AttributeSource"/> instances should use the same <see cref="AttributeFactory"/>.
 /// You can use this method as a replacement for <see cref="RestoreState(State)"/>, if you use
 /// <see cref="CloneAttributes()"/> instead of <see cref="CaptureState()"/>.
 /// </summary>
 public void CopyTo(AttributeSource target)
 {
     for (State state = GetCurrentState(); state != null; state = state.next)
     {
         Attribute targetImpl = target.attributeImpls[state.attribute.GetType()].Value;
         if (targetImpl == null)
         {
             throw new System.ArgumentException("this AttributeSource contains Attribute of type " + state.attribute.GetType().Name + " that is not in the target");
         }
         state.attribute.CopyTo(targetImpl);
     }
 }
示例#4
0
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            if (obj is AttributeSource)
            {
                AttributeSource other = (AttributeSource)obj;

                if (HasAttributes)
                {
                    if (!other.HasAttributes)
                    {
                        return(false);
                    }

                    if (this.attributeImpls.Count != other.attributeImpls.Count)
                    {
                        return(false);
                    }

                    // it is only equal if all attribute impls are the same in the same order
                    State thisState  = this.GetCurrentState();
                    State otherState = other.GetCurrentState();
                    while (thisState != null && otherState != null)
                    {
                        if (otherState.attribute.GetType() != thisState.attribute.GetType() || !otherState.attribute.Equals(thisState.attribute))
                        {
                            return(false);
                        }
                        thisState  = thisState.next;
                        otherState = otherState.next;
                    }
                    return(true);
                }
                else
                {
                    return(!other.HasAttributes);
                }
            }
            else
            {
                return(false);
            }
        }
示例#5
0
 public AttributeReflectorAnonymousInnerClassHelper(AttributeSource outerInstance, bool prependAttClass, StringBuilder buffer)
 {
     this.outerInstance   = outerInstance;
     this.prependAttClass = prependAttClass;
     this.buffer          = buffer;
 }
示例#6
0
 public IteratorAnonymousInnerClassHelper(AttributeSource outerInstance, AttributeSource.State initState)
 {
     this.outerInstance = outerInstance;
     this.initState     = initState;
     state = initState;
 }