当前位置: 首页>>代码示例>>C#>>正文


C# IProtoSerializer类代码示例

本文整理汇总了C#中IProtoSerializer的典型用法代码示例。如果您正苦于以下问题:C# IProtoSerializer类的具体用法?C# IProtoSerializer怎么用?C# IProtoSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IProtoSerializer类属于命名空间,在下文中一共展示了IProtoSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FieldDecorator

 public FieldDecorator(Type forType, FieldInfo field, IProtoSerializer tail) : base(tail)
 {
     Helpers.DebugAssert(forType != null);
     Helpers.DebugAssert(field != null);
     this.forType = forType;
     this.field = field;
 }
开发者ID:Rasarack,项目名称:SteamBot,代码行数:7,代码来源:FieldDecorator.cs

示例2: MemberSpecifiedDecorator

 public MemberSpecifiedDecorator(MethodInfo getSpecified, MethodInfo setSpecified, IProtoSerializer tail)
     : base(tail)
 {
     if (getSpecified == null && setSpecified == null) throw new InvalidOperationException();
     this.getSpecified = getSpecified;
     this.setSpecified = setSpecified;
 }
开发者ID:Rasarack,项目名称:SteamBot,代码行数:7,代码来源:MemberSpecifiedDecorator.cs

示例3: ListDecorator

        public ListDecorator(Type declaredType, Type concreteType, IProtoSerializer tail, int fieldNumber, bool writePacked, WireType packedWireType, bool returnList, bool overwriteList) : base(tail)
        {
            if (returnList) options |= OPTIONS_ReturnList;
            if (overwriteList) options |= OPTIONS_OverwriteList;
            if ((writePacked || packedWireType != WireType.None) && fieldNumber <= 0) throw new ArgumentOutOfRangeException("fieldNumber");
            if (!CanPack(packedWireType))
            {
                if (writePacked) throw new InvalidOperationException("Only simple data-types can use packed encoding");
                packedWireType = WireType.None;
            }            

            this.fieldNumber = fieldNumber;
            if (writePacked) options |= OPTIONS_WritePacked;
            this.packedWireType = packedWireType;
            if (declaredType == null) throw new ArgumentNullException("declaredType");
            if (declaredType.IsArray) throw new ArgumentException("Cannot treat arrays as lists", "declaredType");
            this.declaredType = declaredType;
            this.concreteType = concreteType;
            
            // look for a public list.Add(typedObject) method
            bool isList;
            add = TypeModel.ResolveListAdd(declaredType, tail.ExpectedType, out isList);
            if (isList)
            {
                options |= OPTIONS_IsList;
                if (declaredType.FullName.StartsWith("System.Data.Linq.EntitySet`1[["))
                { // see http://stackoverflow.com/questions/6194639/entityset-is-there-a-sane-reason-that-ilist-add-doesnt-set-assigned
                    options |= OPTIONS_SuppressIList;
                }
            }
            if (add == null) throw new InvalidOperationException();
        }
开发者ID:KimimaroTsukimiya,项目名称:SteamBot-1,代码行数:32,代码来源:ListDecorator.cs

示例4: ListDecorator

 public ListDecorator(Type declaredType, Type concreteType, IProtoSerializer tail, int packedFieldNumber, WireType packedWireType) : base(tail)
 {
     this.packedWireType = WireType.None;
     if (packedFieldNumber != 0)
     {
         if (packedFieldNumber < 0) throw new ArgumentOutOfRangeException("packedFieldNumber");
         switch(packedWireType)
         {
             case WireType.Fixed32:
             case WireType.Fixed64:
             case WireType.SignedVariant:
             case WireType.Variant:
                 break;
             default:
                 throw new InvalidOperationException("Only simple data-types can use packed encoding");
         }
         this.packedFieldNumber = packedFieldNumber;
         this.packedWireType = packedWireType;
     }
     if (declaredType == null) throw new ArgumentNullException("declaredType");
     if (declaredType.IsArray) throw new ArgumentException("Cannot treat arrays as lists", "declaredType");
     this.declaredType = declaredType;
     this.concreteType = concreteType;
     
     // look for a public list.Add(typedObject) method
     add = TypeModel.ResolveListAdd(declaredType, tail.ExpectedType, out isList);
     if (add == null) throw new InvalidOperationException();
 }
开发者ID:AugustoAngeletti,项目名称:blockspaces,代码行数:28,代码来源:ListDecorator.cs

示例5: ReflectedUriDecorator

        public ReflectedUriDecorator(Type type, ProtoBuf.Meta.TypeModel model, IProtoSerializer tail) : base(tail)
        {
            expectedType = type;

            absoluteUriProperty = expectedType.GetProperty("AbsoluteUri");
            typeConstructor = expectedType.GetConstructor(new Type[] { typeof(string) });
        }
开发者ID:gezidan,项目名称:ZYSOCKET,代码行数:7,代码来源:ReflectedUriDecorator.cs

示例6: ArrayDecorator

 public ArrayDecorator(TypeModel model, IProtoSerializer tail, int fieldNumber, bool writePacked, WireType packedWireType, Type arrayType, bool overwriteList, bool supportNull)
     : base(tail)
 {
     this.itemType = arrayType.GetElementType();
     Type arg_3E_0 = (!supportNull) ? (Helpers.GetUnderlyingType(this.itemType) ?? this.itemType) : this.itemType;
     if ((writePacked || packedWireType != WireType.None) && fieldNumber <= 0)
     {
         throw new ArgumentOutOfRangeException("fieldNumber");
     }
     if (!ListDecorator.CanPack(packedWireType))
     {
         if (writePacked)
         {
             throw new InvalidOperationException("Only simple data-types can use packed encoding");
         }
         packedWireType = WireType.None;
     }
     this.fieldNumber = fieldNumber;
     this.packedWireType = packedWireType;
     if (writePacked)
     {
         this.options |= 1;
     }
     if (overwriteList)
     {
         this.options |= 2;
     }
     if (supportNull)
     {
         this.options |= 4;
     }
     this.arrayType = arrayType;
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:33,代码来源:ArrayDecorator.cs

示例7: ArrayDecorator

        public ArrayDecorator(TypeModel model, IProtoSerializer tail, int fieldNumber, bool writePacked, WireType packedWireType, Type arrayType, bool overwriteList, bool supportNull)
            : base(tail)
        {
            Helpers.DebugAssert(arrayType != null, "arrayType should be non-null");
            Helpers.DebugAssert(arrayType.IsArray && arrayType.GetArrayRank() == 1, "should be single-dimension array; " + arrayType.FullName);
            this.itemType = arrayType.GetElementType();
#if NO_GENERICS
            Type underlyingItemType = itemType;
#else
            Type underlyingItemType = supportNull ? itemType : (Helpers.GetUnderlyingType(itemType) ?? itemType);
#endif

            Helpers.DebugAssert(underlyingItemType == Tail.ExpectedType, "invalid tail");
            Helpers.DebugAssert(Tail.ExpectedType != model.MapType(typeof(byte)), "Should have used BlobSerializer");
            if ((writePacked || packedWireType != WireType.None) && fieldNumber <= 0) throw new ArgumentOutOfRangeException("fieldNumber");
            if (!ListDecorator.CanPack(packedWireType))
            {
                if (writePacked) throw new InvalidOperationException("Only simple data-types can use packed encoding");
                packedWireType = WireType.None;
            }       
            this.fieldNumber = fieldNumber;
            this.packedWireType = packedWireType;
            if (writePacked) options |= OPTIONS_WritePacked;
            if (overwriteList) options |= OPTIONS_OverwriteList;
            if (supportNull) options |= OPTIONS_SupportNull;
            this.arrayType = arrayType;
        }
开发者ID:CragonGame,项目名称:GameCloud.IM,代码行数:27,代码来源:ArrayDecorator.cs

示例8: TagDecorator

 public TagDecorator(int fieldNumber, WireType wireType, bool strict, IProtoSerializer tail)
     : base(tail)
 {
     this.fieldNumber = fieldNumber;
     this.wireType = wireType;
     this.strict = strict;
 }
开发者ID:tsuixl,项目名称:Frame,代码行数:7,代码来源:TagDecorator.cs

示例9: PropertyDecorator

 public PropertyDecorator(Type forType, PropertyInfo property, IProtoSerializer tail) : base(tail)
 {
     Helpers.DebugAssert(forType != null);
     Helpers.DebugAssert(property != null);
     this.forType = forType;
     this.property = property;
     SanityCheck(property, tail, out readOptionsWriteValue, true);
 }
开发者ID:AugustoAngeletti,项目名称:blockspaces,代码行数:8,代码来源:PropertyDecorator.cs

示例10: ImmutableCollectionDecorator

 internal ImmutableCollectionDecorator(TypeModel model, Type declaredType, Type concreteType, IProtoSerializer tail, int fieldNumber, bool writePacked, WireType packedWireType, bool returnList, bool overwriteList, bool supportNull, MethodInfo builderFactory, MethodInfo add, MethodInfo addRange, MethodInfo finish)
     : base(model, declaredType, concreteType, tail, fieldNumber, writePacked, packedWireType, returnList, overwriteList, supportNull)
 {
     this.builderFactory = builderFactory;
     this.add = add;
     this.addRange = addRange;
     this.finish = finish;
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:8,代码来源:ImmutableCollectionDecorator.cs

示例11: PropertyDecorator

 public PropertyDecorator(TypeModel model, Type forType, PropertyInfo property, IProtoSerializer tail)
     : base(tail)
 {
     this.forType = forType;
     this.property = property;
     PropertyDecorator.SanityCheck(model, property, tail, out this.readOptionsWriteValue, true, true);
     this.shadowSetter = PropertyDecorator.GetShadowSetter(model, property);
 }
开发者ID:floatyears,项目名称:Decrypt,代码行数:8,代码来源:PropertyDecorator.cs

示例12: DefaultValueDecorator

 public DefaultValueDecorator(object defaultValue, IProtoSerializer tail) : base(tail)
 {
     if (defaultValue == null) throw new ArgumentNullException("defaultValue");
     if (defaultValue.GetType() != tail.ExpectedType)
     {
         throw new ArgumentException("Default value is of incorrect type", "defaultValue");
     }
     this.defaultValue = defaultValue;
 }
开发者ID:Ribosome2,项目名称:protobuf-net-1,代码行数:9,代码来源:DefaultValueDecorator.cs

示例13: PrimitivesDecorator

        public PrimitivesDecorator(IProtoSerializer itemSerializer)
        {
            if (itemSerializer == null)
            {
                throw new ArgumentNullException("itemSerializer");
            }

            this.itemSerializer = itemSerializer;
        }
开发者ID:robb83,项目名称:Protocols,代码行数:9,代码来源:PrimitivesDecorator.cs

示例14: EmitReadList

        internal static void EmitReadList(ProtoBuf.Compiler.CompilerContext ctx, Compiler.Local list, IProtoSerializer tail, MethodInfo add, WireType packedWireType)
        {
            using (Compiler.Local fieldNumber = new Compiler.Local(ctx, typeof(int)))
            {
                Compiler.CodeLabel readPacked = packedWireType == WireType.None ? new Compiler.CodeLabel() : ctx.DefineLabel();                                   
                if (packedWireType != WireType.None)
                {
                    ctx.LoadReaderWriter();
                    ctx.LoadValue(typeof(ProtoReader).GetProperty("WireType"));
                    ctx.LoadValue((int)WireType.String);
                    ctx.BranchIfEqual(readPacked, false);
                }
                ctx.LoadReaderWriter();
                ctx.LoadValue(typeof(ProtoReader).GetProperty("FieldNumber"));
                ctx.StoreValue(fieldNumber);

                Compiler.CodeLabel @continue = ctx.DefineLabel();
                ctx.MarkLabel(@continue);

                EmitReadAndAddItem(ctx, list, tail, add);

                ctx.LoadReaderWriter();
                ctx.LoadValue(fieldNumber);
                ctx.EmitCall(typeof(ProtoReader).GetMethod("TryReadFieldHeader"));
                ctx.BranchIfTrue(@continue, false);

                if (packedWireType != WireType.None)
                {
                    Compiler.CodeLabel allDone = ctx.DefineLabel();
                    ctx.Branch(allDone, false);
                    ctx.MarkLabel(readPacked);

                    ctx.LoadReaderWriter();
                    ctx.EmitCall(typeof(ProtoReader).GetMethod("StartSubItem"));

                    Compiler.CodeLabel testForData = ctx.DefineLabel(), noMoreData = ctx.DefineLabel();
                    ctx.MarkLabel(testForData);
                    ctx.LoadValue((int)packedWireType);
                    ctx.LoadReaderWriter();
                    ctx.EmitCall(typeof(ProtoReader).GetMethod("HasSubValue"));
                    ctx.BranchIfFalse(noMoreData, false);

                    EmitReadAndAddItem(ctx, list, tail, add);
                    ctx.Branch(testForData, false);

                    ctx.MarkLabel(noMoreData);
                    ctx.LoadReaderWriter();
                    ctx.EmitCall(typeof(ProtoReader).GetMethod("EndSubItem"));
                    ctx.MarkLabel(allDone);
                }


                
            }
        }
开发者ID:AugustoAngeletti,项目名称:blockspaces,代码行数:55,代码来源:ListDecorator.cs

示例15: BuildSerializer

 public static ProtoSerializer BuildSerializer(IProtoSerializer head)
 {
     Type type = head.ExpectedType;
     CompilerContext ctx = new CompilerContext(type, true, true);
     ctx.LoadValue(Local.InputValue);
     ctx.CastFromObject(type);
     ctx.WriteNullCheckedTail(type, head, null);
     ctx.Emit(OpCodes.Ret);
     return (ProtoSerializer)ctx.method.CreateDelegate(
         typeof(ProtoSerializer));
 }
开发者ID:KimimaroTsukimiya,项目名称:SteamBot-1,代码行数:11,代码来源:CompilerContext.cs


注:本文中的IProtoSerializer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。