Exemple #1
0
        public NitroxProtobufSerializer(params string[] assemblies)
        {
            Main       = this;
            model      = TypeModel.Create();
            knownTypes = (Dictionary <Type, int>) typeof(ProtobufSerializerPrecompiled).GetField("knownTypes", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);

            foreach (string assembly in assemblies)
            {
                RegisterAssemblyClasses(assembly);
            }

            foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
            {
                bool hasUweProtobuf = (type.GetCustomAttributes(typeof(ProtoContractAttribute), true).Length > 0);

                if (hasUweProtobuf)
                {
                    AddType(type);
                }
            }
        }