コード例 #1
0
        protected override void BuildConstantsInternal(ReaderConstantsBuilderContext context)
        {
            context.SetFields(Type, new[]
            {
                new KeyValuePair <string, Type>("setters_" + Type.Name + "_" + Guid.NewGuid(), typeof(IntPtr[])),
                new KeyValuePair <string, Type>("delegates_" + Type.Name + "_" + Guid.NewGuid(), typeof(Delegate[])),
                new KeyValuePair <string, Type>("hashCodes_" + Type.Name + "_" + Guid.NewGuid(), typeof(ulong[])),
            });
            foreach (var member in context.GetDataMembers(Type))
            {
                Type memberType;
                switch (member.Member.MemberType)
                {
                case MemberTypes.Property:
                    memberType = ((PropertyInfo)member.Member).PropertyType;
                    break;

                case MemberTypes.Field:
                    memberType = ((FieldInfo)member.Member).FieldType;
                    break;

                default:
                    throw new NotSupportedException("Data member of type " + member.Member.MemberType + " is not supported");
                }
                context.BuildConstants(memberType);
            }
        }
コード例 #2
0
 protected override void BuildConstantsInternal(ReaderConstantsBuilderContext context)
 {
     context.SetFields(Type, new[]
     {
         new KeyValuePair <string, Type>("readers_" + Type.Name + "_" + Guid.NewGuid(), typeof(IntPtr[])),
         new KeyValuePair <string, Type>("delegates_" + Type.Name + "_" + Guid.NewGuid(), typeof(Delegate[])),
     });
 }
コード例 #3
0
 protected override void BuildConstantsInternal(ReaderConstantsBuilderContext context)
 {
     context.SetFields(Type, new[]
     {
         new KeyValuePair <string, Type>("readers_" + Type.Name + "_" + Guid.NewGuid(), typeof(IntPtr[])),
         new KeyValuePair <string, Type>("delegates_" + Type.Name + "_" + Guid.NewGuid(), typeof(Delegate[]))    // This field is needed only to save references to the dynamic methods. Otherwise GC will destroy them
     });
     Array.ForEach(GroBufHelpers.LeafTypes.Where(type => type != null).ToArray(), type => context.BuildConstants(type));
 }
コード例 #4
0
ファイル: EnumReaderBuilder.cs プロジェクト: skbkontur/GroBuf
 protected override void BuildConstantsInternal(ReaderConstantsBuilderContext context)
 {
     context.SetFields(Type, new[]
     {
         new KeyValuePair <string, Type>("values_" + Type.Name + "_" + Guid.NewGuid(), typeof(int[])),
         new KeyValuePair <string, Type>("hashCodes_" + Type.Name + "_" + Guid.NewGuid(), typeof(ulong[])),
     });
     context.BuildConstants(typeof(int));
     context.BuildConstants(typeof(string));
 }
コード例 #5
0
 protected override void BuildConstantsInternal(ReaderConstantsBuilderContext context)
 {
     context.SetFields(Type, new[] { new KeyValuePair <string, Type>("customSerializer_" + Type.Name + "_" + Guid.NewGuid(), typeof(IGroBufCustomSerializer)) });
 }
コード例 #6
0
 public void BuildConstants(ReaderConstantsBuilderContext context)
 {
     context.SetFields(Type, new KeyValuePair <string, Type> [0]);
     BuildConstantsInternal(context);
 }