Example #1
0
        public static RoleSet DeserializeLengthDelimited(Stream stream)
        {
            RoleSet roleSet = new RoleSet();

            RoleSet.DeserializeLengthDelimited(stream, roleSet);
            return(roleSet);
        }
Example #2
0
        public static RoleSet DeserializeLengthDelimited(Stream stream, RoleSet instance)
        {
            long position = (long)ProtocolParser.ReadUInt32(stream);

            position += stream.Position;
            return(RoleSet.Deserialize(stream, instance, position));
        }
Example #3
0
        public static RoleSet DeserializeLengthDelimited(Stream stream, RoleSet instance)
        {
            long num = (long)((ulong)ProtocolParser.ReadUInt32(stream));

            num += stream.get_Position();
            return(RoleSet.Deserialize(stream, instance, num));
        }
Example #4
0
        public override bool Equals(object obj)
        {
            RoleSet roleSet = obj as RoleSet;

            if (roleSet == null)
            {
                return(false);
            }
            if (!this.Program.Equals(roleSet.Program))
            {
                return(false);
            }
            if (!this.Service.Equals(roleSet.Service))
            {
                return(false);
            }
            if (this.HasSubtype != roleSet.HasSubtype || this.HasSubtype && !this.Subtype.Equals(roleSet.Subtype))
            {
                return(false);
            }
            if (this.Role.Count != roleSet.Role.Count)
            {
                return(false);
            }
            for (int i = 0; i < this.Role.Count; i++)
            {
                if (!this.Role[i].Equals(roleSet.Role[i]))
                {
                    return(false);
                }
            }
            if (this.DefaultRole.Count != roleSet.DefaultRole.Count)
            {
                return(false);
            }
            for (int j = 0; j < this.DefaultRole.Count; j++)
            {
                if (!this.DefaultRole[j].Equals(roleSet.DefaultRole[j]))
                {
                    return(false);
                }
            }
            if (this.HasMaxMembers != roleSet.HasMaxMembers || this.HasMaxMembers && !this.MaxMembers.Equals(roleSet.MaxMembers))
            {
                return(false);
            }
            if (this.Attribute.Count != roleSet.Attribute.Count)
            {
                return(false);
            }
            for (int k = 0; k < this.Attribute.Count; k++)
            {
                if (!this.Attribute[k].Equals(roleSet.Attribute[k]))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #5
0
        public override bool Equals(object obj)
        {
            RoleSet roleSet = obj as RoleSet;

            if (roleSet == null)
            {
                return(false);
            }
            if (!this.Program.Equals(roleSet.Program))
            {
                return(false);
            }
            if (!this.Service.Equals(roleSet.Service))
            {
                return(false);
            }
            if (this.HasSubtype != roleSet.HasSubtype || (this.HasSubtype && !this.Subtype.Equals(roleSet.Subtype)))
            {
                return(false);
            }
            if (this.Role.get_Count() != roleSet.Role.get_Count())
            {
                return(false);
            }
            for (int i = 0; i < this.Role.get_Count(); i++)
            {
                if (!this.Role.get_Item(i).Equals(roleSet.Role.get_Item(i)))
                {
                    return(false);
                }
            }
            if (this.DefaultRole.get_Count() != roleSet.DefaultRole.get_Count())
            {
                return(false);
            }
            for (int j = 0; j < this.DefaultRole.get_Count(); j++)
            {
                if (!this.DefaultRole.get_Item(j).Equals(roleSet.DefaultRole.get_Item(j)))
                {
                    return(false);
                }
            }
            if (this.HasMaxMembers != roleSet.HasMaxMembers || (this.HasMaxMembers && !this.MaxMembers.Equals(roleSet.MaxMembers)))
            {
                return(false);
            }
            if (this.Attribute.get_Count() != roleSet.Attribute.get_Count())
            {
                return(false);
            }
            for (int k = 0; k < this.Attribute.get_Count(); k++)
            {
                if (!this.Attribute.get_Item(k).Equals(roleSet.Attribute.get_Item(k)))
                {
                    return(false);
                }
            }
            return(true);
        }
Example #6
0
 public static void Serialize(Stream stream, RoleSet instance)
 {
     if (instance.Program == null)
     {
         throw new ArgumentNullException("Program", "Required by proto specification.");
     }
     stream.WriteByte(10);
     ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Program));
     if (instance.Service == null)
     {
         throw new ArgumentNullException("Service", "Required by proto specification.");
     }
     stream.WriteByte(18);
     ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Service));
     if (instance.HasSubtype)
     {
         stream.WriteByte(26);
         ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Subtype));
     }
     if (instance.Role.Count > 0)
     {
         foreach (bnet.protocol.Role role in instance.Role)
         {
             stream.WriteByte(34);
             ProtocolParser.WriteUInt32(stream, role.GetSerializedSize());
             bnet.protocol.Role.Serialize(stream, role);
         }
     }
     if (instance.DefaultRole.Count > 0)
     {
         stream.WriteByte(42);
         uint num = 0;
         foreach (uint defaultRole in instance.DefaultRole)
         {
             num += ProtocolParser.SizeOfUInt32(defaultRole);
         }
         ProtocolParser.WriteUInt32(stream, num);
         foreach (uint defaultRole1 in instance.DefaultRole)
         {
             ProtocolParser.WriteUInt32(stream, defaultRole1);
         }
     }
     if (instance.HasMaxMembers)
     {
         stream.WriteByte(48);
         ProtocolParser.WriteUInt64(stream, (ulong)instance.MaxMembers);
     }
     if (instance.Attribute.Count > 0)
     {
         foreach (bnet.protocol.attribute.Attribute attribute in instance.Attribute)
         {
             stream.WriteByte(58);
             ProtocolParser.WriteUInt32(stream, attribute.GetSerializedSize());
             bnet.protocol.attribute.Attribute.Serialize(stream, attribute);
         }
     }
 }
 public static RoleSetConfig Deserialize(Stream stream, RoleSetConfig instance, long limit)
 {
     if (instance.Privilege == null)
     {
         instance.Privilege = new List <Privilege>();
     }
     while (limit < 0L || stream.get_Position() < limit)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             if (limit >= 0L)
             {
                 throw new EndOfStreamException();
             }
             return(instance);
         }
         else
         {
             int num2 = num;
             if (num2 != 10)
             {
                 if (num2 != 18)
                 {
                     Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                     uint field = key.Field;
                     if (field == 0u)
                     {
                         throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                     }
                     ProtocolParser.SkipKey(stream, key);
                 }
                 else if (instance.RoleSet == null)
                 {
                     instance.RoleSet = RoleSet.DeserializeLengthDelimited(stream);
                 }
                 else
                 {
                     RoleSet.DeserializeLengthDelimited(stream, instance.RoleSet);
                 }
             }
             else
             {
                 instance.Privilege.Add(bnet.protocol.Privilege.DeserializeLengthDelimited(stream));
             }
         }
     }
     if (stream.get_Position() == limit)
     {
         return(instance);
     }
     throw new ProtocolBufferException("Read past max limit");
 }
Example #8
0
 public static void Serialize(Stream stream, RoleSetConfig instance)
 {
     if (instance.Privilege.Count > 0)
     {
         foreach (Privilege privilege in instance.Privilege)
         {
             stream.WriteByte(10);
             ProtocolParser.WriteUInt32(stream, privilege.GetSerializedSize());
             bnet.protocol.Privilege.Serialize(stream, privilege);
         }
     }
     if (instance.RoleSet == null)
     {
         throw new ArgumentNullException("RoleSet", "Required by proto specification.");
     }
     stream.WriteByte(18);
     ProtocolParser.WriteUInt32(stream, instance.RoleSet.GetSerializedSize());
     RoleSet.Serialize(stream, instance.RoleSet);
 }
 public static void Serialize(Stream stream, RoleSetConfig instance)
 {
     if (instance.Privilege.get_Count() > 0)
     {
         using (List <Privilege> .Enumerator enumerator = instance.Privilege.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 Privilege current = enumerator.get_Current();
                 stream.WriteByte(10);
                 ProtocolParser.WriteUInt32(stream, current.GetSerializedSize());
                 bnet.protocol.Privilege.Serialize(stream, current);
             }
         }
     }
     if (instance.RoleSet == null)
     {
         throw new ArgumentNullException("RoleSet", "Required by proto specification.");
     }
     stream.WriteByte(18);
     ProtocolParser.WriteUInt32(stream, instance.RoleSet.GetSerializedSize());
     RoleSet.Serialize(stream, instance.RoleSet);
 }
Example #10
0
 public void Serialize(Stream stream)
 {
     RoleSet.Serialize(stream, this);
 }
Example #11
0
 public static RoleSet Deserialize(Stream stream, RoleSet instance, long limit)
 {
     instance.Subtype = "default";
     if (instance.Role == null)
     {
         instance.Role = new List <bnet.protocol.Role>();
     }
     if (instance.DefaultRole == null)
     {
         instance.DefaultRole = new List <uint>();
     }
     if (instance.Attribute == null)
     {
         instance.Attribute = new List <bnet.protocol.attribute.Attribute>();
     }
     while (true)
     {
         if (limit < (long)0 || stream.Position < limit)
         {
             int num = stream.ReadByte();
             if (num == -1)
             {
                 if (limit >= (long)0)
                 {
                     throw new EndOfStreamException();
                 }
                 break;
             }
             else if (num == 10)
             {
                 instance.Program = ProtocolParser.ReadString(stream);
             }
             else if (num == 18)
             {
                 instance.Service = ProtocolParser.ReadString(stream);
             }
             else if (num == 26)
             {
                 instance.Subtype = ProtocolParser.ReadString(stream);
             }
             else if (num == 34)
             {
                 instance.Role.Add(bnet.protocol.Role.DeserializeLengthDelimited(stream));
             }
             else if (num == 42)
             {
                 long position = (long)ProtocolParser.ReadUInt32(stream);
                 position += stream.Position;
                 while (stream.Position < position)
                 {
                     instance.DefaultRole.Add(ProtocolParser.ReadUInt32(stream));
                 }
                 if (stream.Position != position)
                 {
                     throw new ProtocolBufferException("Read too many bytes in packed data");
                 }
             }
             else if (num == 48)
             {
                 instance.MaxMembers = (int)ProtocolParser.ReadUInt64(stream);
             }
             else if (num == 58)
             {
                 instance.Attribute.Add(bnet.protocol.attribute.Attribute.DeserializeLengthDelimited(stream));
             }
             else
             {
                 Key key = ProtocolParser.ReadKey((byte)num, stream);
                 if (key.Field == 0)
                 {
                     throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                 }
                 ProtocolParser.SkipKey(stream, key);
             }
         }
         else
         {
             if (stream.Position != limit)
             {
                 throw new ProtocolBufferException("Read past max limit");
             }
             break;
         }
     }
     return(instance);
 }
Example #12
0
 public static RoleSet Deserialize(Stream stream, RoleSet instance)
 {
     return(RoleSet.Deserialize(stream, instance, (long)-1));
 }
Example #13
0
 public void Deserialize(Stream stream)
 {
     RoleSet.Deserialize(stream, this);
 }
Example #14
0
 public static void Serialize(Stream stream, RoleSet instance)
 {
     if (instance.Program == null)
     {
         throw new ArgumentNullException("Program", "Required by proto specification.");
     }
     stream.WriteByte(10);
     ProtocolParser.WriteBytes(stream, Encoding.get_UTF8().GetBytes(instance.Program));
     if (instance.Service == null)
     {
         throw new ArgumentNullException("Service", "Required by proto specification.");
     }
     stream.WriteByte(18);
     ProtocolParser.WriteBytes(stream, Encoding.get_UTF8().GetBytes(instance.Service));
     if (instance.HasSubtype)
     {
         stream.WriteByte(26);
         ProtocolParser.WriteBytes(stream, Encoding.get_UTF8().GetBytes(instance.Subtype));
     }
     if (instance.Role.get_Count() > 0)
     {
         using (List <Role> .Enumerator enumerator = instance.Role.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 Role current = enumerator.get_Current();
                 stream.WriteByte(34);
                 ProtocolParser.WriteUInt32(stream, current.GetSerializedSize());
                 bnet.protocol.Role.Serialize(stream, current);
             }
         }
     }
     if (instance.DefaultRole.get_Count() > 0)
     {
         stream.WriteByte(42);
         uint num = 0u;
         using (List <uint> .Enumerator enumerator2 = instance.DefaultRole.GetEnumerator())
         {
             while (enumerator2.MoveNext())
             {
                 uint current2 = enumerator2.get_Current();
                 num += ProtocolParser.SizeOfUInt32(current2);
             }
         }
         ProtocolParser.WriteUInt32(stream, num);
         using (List <uint> .Enumerator enumerator3 = instance.DefaultRole.GetEnumerator())
         {
             while (enumerator3.MoveNext())
             {
                 uint current3 = enumerator3.get_Current();
                 ProtocolParser.WriteUInt32(stream, current3);
             }
         }
     }
     if (instance.HasMaxMembers)
     {
         stream.WriteByte(48);
         ProtocolParser.WriteUInt64(stream, (ulong)((long)instance.MaxMembers));
     }
     if (instance.Attribute.get_Count() > 0)
     {
         using (List <Attribute> .Enumerator enumerator4 = instance.Attribute.GetEnumerator())
         {
             while (enumerator4.MoveNext())
             {
                 Attribute current4 = enumerator4.get_Current();
                 stream.WriteByte(58);
                 ProtocolParser.WriteUInt32(stream, current4.GetSerializedSize());
                 bnet.protocol.attribute.Attribute.Serialize(stream, current4);
             }
         }
     }
 }
Example #15
0
 public static RoleSet Deserialize(Stream stream, RoleSet instance, long limit)
 {
     instance.Subtype = "default";
     if (instance.Role == null)
     {
         instance.Role = new List <Role>();
     }
     if (instance.DefaultRole == null)
     {
         instance.DefaultRole = new List <uint>();
     }
     if (instance.Attribute == null)
     {
         instance.Attribute = new List <Attribute>();
     }
     while (limit < 0L || stream.get_Position() < limit)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             if (limit >= 0L)
             {
                 throw new EndOfStreamException();
             }
             return(instance);
         }
         else
         {
             int num2 = num;
             if (num2 != 10)
             {
                 if (num2 != 18)
                 {
                     if (num2 != 26)
                     {
                         if (num2 != 34)
                         {
                             if (num2 != 42)
                             {
                                 if (num2 != 48)
                                 {
                                     if (num2 != 58)
                                     {
                                         Key  key   = ProtocolParser.ReadKey((byte)num, stream);
                                         uint field = key.Field;
                                         if (field == 0u)
                                         {
                                             throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
                                         }
                                         ProtocolParser.SkipKey(stream, key);
                                     }
                                     else
                                     {
                                         instance.Attribute.Add(bnet.protocol.attribute.Attribute.DeserializeLengthDelimited(stream));
                                     }
                                 }
                                 else
                                 {
                                     instance.MaxMembers = (int)ProtocolParser.ReadUInt64(stream);
                                 }
                             }
                             else
                             {
                                 long num3 = (long)((ulong)ProtocolParser.ReadUInt32(stream));
                                 num3 += stream.get_Position();
                                 while (stream.get_Position() < num3)
                                 {
                                     instance.DefaultRole.Add(ProtocolParser.ReadUInt32(stream));
                                 }
                                 if (stream.get_Position() != num3)
                                 {
                                     throw new ProtocolBufferException("Read too many bytes in packed data");
                                 }
                             }
                         }
                         else
                         {
                             instance.Role.Add(bnet.protocol.Role.DeserializeLengthDelimited(stream));
                         }
                     }
                     else
                     {
                         instance.Subtype = ProtocolParser.ReadString(stream);
                     }
                 }
                 else
                 {
                     instance.Service = ProtocolParser.ReadString(stream);
                 }
             }
             else
             {
                 instance.Program = ProtocolParser.ReadString(stream);
             }
         }
     }
     if (stream.get_Position() == limit)
     {
         return(instance);
     }
     throw new ProtocolBufferException("Read past max limit");
 }
 public void SetRoleSet(RoleSet val)
 {
     this.RoleSet = val;
 }