Exemplo n.º 1
0
 internal void VerifyExtensionContainingType <TExtension>(GeneratedExtensionLite <TMessage, TExtension> extension)
 {
     if (!object.ReferenceEquals(extension.ContainingTypeDefaultInstance, this.DefaultInstanceForType))
     {
         throw new ArgumentException(string.Format("Extension is for type \"{0}\" which does not match message type \"{1}\".", extension.ContainingTypeDefaultInstance, this.DefaultInstanceForType));
     }
 }
        public TBuilder AddExtension <TExtension>(GeneratedExtensionLite <TMessage, IList <TExtension> > extension, TExtension value)
        {
            ExtendableMessageLite <TMessage, TBuilder> extendableMessageLite = this.MessageBeingBuilt;

            extendableMessageLite.VerifyExtensionContainingType <IList <TExtension> >(extension);
            extendableMessageLite.Extensions.AddRepeatedField(extension.Descriptor, extension.SingularToReflectionType(value));
            return(this.ThisBuilder);
        }
        public TBuilder SetExtension <TExtension>(GeneratedExtensionLite <TMessage, IList <TExtension> > extension, int index, TExtension value)
        {
            ExtendableMessageLite <TMessage, TBuilder> extendableMessageLite = this.MessageBeingBuilt;

            extendableMessageLite.VerifyExtensionContainingType <IList <TExtension> >(extension);
            extendableMessageLite.Extensions[extension.Descriptor, index] = extension.SingularToReflectionType(value);
            return(this.ThisBuilder);
        }
        /// <summary>
        /// Clears an extension.
        /// </summary>
        public TBuilder ClearExtension <TExtension>(GeneratedExtensionLite <TMessage, TExtension> extension)
        {
            ExtendableMessageLite <TMessage, TBuilder> message = MessageBeingBuilt;

            message.VerifyExtensionContainingType(extension);
            message.Extensions.ClearField(extension.Descriptor);
            return(ThisBuilder);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Sets the value of an extension.
        /// </summary>
        public TBuilder SetExtension <TExtension>(GeneratedExtensionLite <TMessage, TExtension> extension, TExtension value)
        {
            ExtendableMessageLite <TMessage, TBuilder> message = MessageBeingBuilt;

            message.VerifyExtensionContainingType(extension);
            message.Extensions[extension.Descriptor] = extension.ToReflectionType(value);
            return(ThisBuilder);
        }
Exemplo n.º 6
0
        public TExtension GetExtension <TExtension>(GeneratedExtensionLite <TMessage, TExtension> extension)
        {
            this.VerifyExtensionContainingType <TExtension>(extension);
            object obj = this.extensions[extension.Descriptor];

            if (obj == null)
            {
                return(extension.DefaultValue);
            }
            return((TExtension)((object)extension.FromReflectionType(obj)));
        }
Exemplo n.º 7
0
 internal void VerifyExtensionContainingType <TExtension>(GeneratedExtensionLite <TMessage, TExtension> extension)
 {
     if (!ReferenceEquals(extension.ContainingTypeDefaultInstance, DefaultInstanceForType))
     {
         // This can only happen if someone uses unchecked operations.
         throw new ArgumentException(
                   String.Format("Extension is for type \"{0}\" which does not match message type \"{1}\".",
                                 extension.ContainingTypeDefaultInstance, DefaultInstanceForType
                                 ));
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Returns the value of an extension.
        /// </summary>
        public TExtension GetExtension <TExtension>(GeneratedExtensionLite <TMessage, TExtension> extension)
        {
            VerifyExtensionContainingType(extension);
            object value = extensions[extension.Descriptor];

            if (value == null)
            {
                return(extension.DefaultValue);
            }
            else
            {
                return((TExtension)extension.FromReflectionType(value));
            }
        }
 /// <summary>
 /// Checks if a singular extension is present
 /// </summary>
 public bool HasExtension <TExtension>(GeneratedExtensionLite <TMessage, TExtension> extension)
 {
     return(MessageBeingBuilt.HasExtension(extension));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Checks if a singular extension is present.
 /// </summary>
 public bool HasExtension <TExtension>(GeneratedExtensionLite <TMessage, TExtension> extension)
 {
     VerifyExtensionContainingType(extension);
     return(extensions.HasField(extension.Descriptor));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Returns the number of elements in a repeated extension.
 /// </summary>
 public int GetExtensionCount <TExtension>(GeneratedExtensionLite <TMessage, IList <TExtension> > extension)
 {
     VerifyExtensionContainingType(extension);
     return(extensions.GetRepeatedFieldCount(extension.Descriptor));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Returns one element of a repeated extension.
 /// </summary>
 public TExtension GetExtension <TExtension>(GeneratedExtensionLite <TMessage, IList <TExtension> > extension,
                                             int index)
 {
     VerifyExtensionContainingType(extension);
     return((TExtension)extension.SingularFromReflectionType(extensions[extension.Descriptor, index]));
 }
Exemplo n.º 13
0
        public TExtension GetExtension <TExtension>(GeneratedExtensionLite <TMessage, TExtension> extension)
        {
            TMessage messageBeingBuilt = this.MessageBeingBuilt;

            return(messageBeingBuilt.GetExtension <TExtension>(extension));
        }
 /// <summary>
 /// Returns one element of a repeated extension.
 /// </summary>
 public TExtension GetExtension <TExtension>(GeneratedExtensionLite <TMessage, IList <TExtension> > extension,
                                             int index)
 {
     return(MessageBeingBuilt.GetExtension(extension, index));
 }
 /// <summary>
 /// Returns the value of an extension.
 /// </summary>
 public TExtension GetExtension <TExtension>(GeneratedExtensionLite <TMessage, TExtension> extension)
 {
     return(MessageBeingBuilt.GetExtension(extension));
 }
 /// <summary>
 /// Returns the number of elements in a repeated extension.
 /// </summary>
 public int GetExtensionCount <TExtension>(GeneratedExtensionLite <TMessage, IList <TExtension> > extension)
 {
     return(MessageBeingBuilt.GetExtensionCount(extension));
 }
Exemplo n.º 17
0
        public int GetExtensionCount <TExtension>(GeneratedExtensionLite <TMessage, IList <TExtension> > extension)
        {
            TMessage messageBeingBuilt = this.MessageBeingBuilt;

            return(messageBeingBuilt.GetExtensionCount <TExtension>(extension));
        }
Exemplo n.º 18
0
        public TExtension GetExtension <TExtension>(GeneratedExtensionLite <TMessage, IList <TExtension> > extension, int index)
        {
            TMessage messageBeingBuilt = this.MessageBeingBuilt;

            return(messageBeingBuilt.GetExtension <TExtension>(extension, index));
        }