Hi All,
I am doing development in C# for Aaadhar authentication. While
functionality is working fine while sending PID details in XML format, it
is responding with response code
as 511 in case of BFD in protobuf format.
Please find sample class file with proto contract and proto member
attributes. Also find method used to convert this proto class into memory
stream.
Even If I am sending type attribute as 'P' for protobuf but still getting
response as 511(Invalid PID XML format).
Any sample C# or .Net workable code for protobuf will be very helpful for
me so if anyone has already done this than kindly share.
Regards,
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using ProtoBuf;
namespace ProtocolBuffer
{
private static int CalcProtoBufSize(object oObj)
{
using (MemoryStream ms = new MemoryStream())
{
ProtoBuf.Serializer.Serialize(ms, oObj);
return ms.ToArray().Length;
}
}
[ProtoContract]
public class Pid
{
[ProtoMember(1, IsRequired = true)]
public int ver { get; set; }
[ProtoMember(2, IsRequired = false)]
public string ts { get; set; }
[ProtoMember(3, IsRequired = false)]
public Demo demo { get; set; }
[ProtoMember(4, IsRequired = false)]
public Bios bios { get; set; }
}
[ProtoContract]
public class Demo
{
[ProtoMember(1, IsRequired = false)]
public string LangCode { get; set; }
[ProtoMember(2, IsRequired = false)]
public string pi { get; set; }
[ProtoMember(3, IsRequired = false)]
public string pa { get; set; }
[ProtoMember(4, IsRequired = false)]
public string pfa { get; set; }
}
[ProtoContract]
public class Bios
{
[ProtoMember(1, IsRequired = true)]
public Bio bio { get; set; }
}
[ProtoContract]
public class Bio
{
[ProtoMember(1, IsRequired = false)]
public BioType type { get; set; }
[ProtoMember(2, IsRequired = false)]
public Position posh { get; set; }
[ProtoMember(3, IsRequired = false)]
public byte[] content { get; set; }
}
public enum BioType { FMR = 0, FIR = 1, IIR = 2 };
public enum Position
{
LEFT_IRIS = 1,
RIGHT_IRIS = 2,
LEFT_INDEX = 3,
LEFT_LITTLE = 4,
LEFT_MIDDLE = 5,
LEFT_RING = 6,
LEFT_THUMB = 7,
RIGHT_INDEX = 8,
RIGHT_LITTLE = 9,
RIGHT_MIDDLE = 10,
RIGHT_RING = 11,
RIGHT_THUMB = 12,
UNKNOWN = 13
}
}