コード例 #1
0
 private void SetFlag(byte flag, bool value)
 {
     if (value)
     {
         ProtoContractAttribute protoContractAttribute = this;
         protoContractAttribute.flags = (byte)(protoContractAttribute.flags | flag);
         return;
     }
     this.flags = (byte)(this.flags & ~flag);
 }
 static public int get_ImplicitFirstTag(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute self = (ProtoBuf.ProtoContractAttribute)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.ImplicitFirstTag);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_UseProtoMembersOnly(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute self = (ProtoBuf.ProtoContractAttribute)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.UseProtoMembersOnly);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_EnumPassthru(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute self = (ProtoBuf.ProtoContractAttribute)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.EnumPassthru);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_AsReferenceDefault(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute self = (ProtoBuf.ProtoContractAttribute)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.AsReferenceDefault);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_SkipConstructor(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute self = (ProtoBuf.ProtoContractAttribute)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.SkipConstructor);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #7
0
        public static void AppendEnum <TEnum>(StringBuilder sb, int nestLevel) where TEnum : struct
        {
            ProtoContractAttribute attrib = AttributeUtils.GetAttribute <ProtoContractAttribute>(typeof(TEnum));
            string name = attrib == null || string.IsNullOrEmpty(attrib.Name) ? typeof(TEnum).Name : attrib.Name;

            Indent(sb, nestLevel).Append("enum ").Append(name).Append(" {").AppendLine();
            foreach (Serializer.ProtoEnumValue <TEnum> value in Serializer.GetEnumValues <TEnum>())
            {
                Indent(sb, nestLevel + 1).Append(' ').Append(value.Name)
                .Append(" = ").Append(value.WireValue).Append(";").AppendLine();
            }
            Indent(sb, nestLevel).Append("}").AppendLine();
        }
 static public int constructor(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute o;
         o = new ProtoBuf.ProtoContractAttribute();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_UseProtoMembersOnly(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute self = (ProtoBuf.ProtoContractAttribute)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.UseProtoMembersOnly = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_ImplicitFirstTag(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute self = (ProtoBuf.ProtoContractAttribute)checkSelf(l);
         int v;
         checkType(l, 2, out v);
         self.ImplicitFirstTag = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_Name(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute self = (ProtoBuf.ProtoContractAttribute)checkSelf(l);
         string v;
         checkType(l, 2, out v);
         self.Name = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_AsReferenceDefault(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute self = (ProtoBuf.ProtoContractAttribute)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.AsReferenceDefault = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_DataMemberOffset(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute self = (ProtoBuf.ProtoContractAttribute)checkSelf(l);
         int v;
         checkType(l, 2, out v);
         self.DataMemberOffset = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_IgnoreListHandling(IntPtr l)
 {
     try {
         ProtoBuf.ProtoContractAttribute self = (ProtoBuf.ProtoContractAttribute)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.IgnoreListHandling = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #15
0
ファイル: Entity.cs プロジェクト: neilyo0313/protobuf-unity5
        private static Entity Load(Type type)
        {
            Attribute[] attribs  = Attribute.GetCustomAttributes(type);
            bool        isEntity = false;
            string      name     = null;

            for (int i = 0; i < attribs.Length; i++)
            {
                if (attribs[i] is ProtoContractAttribute)
                {
                    ProtoContractAttribute pca = (ProtoContractAttribute)attribs[i];
                    name     = pca.Name;
                    isEntity = true;
                    break;
                }
            }
            if (!isEntity)
            {
                for (int i = 0; i < attribs.Length; i++)
                {
                    if (attribs[i].GetType().FullName == Serializer.DataContractAttributeFullName)
                    {
                        Serializer.ParseDataContractAttribute(attribs[i], out name);
                        isEntity = true;
                        break;
                    }
                }
            }
            if (!isEntity)
            {
                for (int i = 0; i < attribs.Length; i++)
                {
                    if (attribs[i] is XmlTypeAttribute)
                    {
                        XmlTypeAttribute xta = (XmlTypeAttribute)attribs[i];
                        name     = xta.TypeName;
                        isEntity = true;
                        break;
                    }
                }
            }
            return(isEntity ? new Entity(type, name, null) : null);
        }