public static void Initialize(params Assembly[] AdditionalAssemblies) { if (IsInitialized) { return; } List <Assembly> TargetAssemblies = AdditionalAssemblies.ToList(); TargetAssemblies.Add(typeof(Message).GetTypeInfo().Assembly); TypeInfo[] MessageTypes = TargetAssemblies.SelectMany(x => x.ExportedTypes).Select(x => x.GetTypeInfo()).Where(x => x.IsSubclassOf(typeof(Message))).ToArray(); Dictionary <Type, int> SubTypeCount = new Dictionary <Type, int>(); for (int i = 0; i < MessageTypes.Length; i++) { MetaType ProtobufType; if (!SubTypeCount.ContainsKey(MessageTypes[i].BaseType)) { ProtobufType = RuntimeTypeModel.Default.Add(MessageTypes[i].BaseType, true); SubTypeCount[MessageTypes[i].BaseType] = 101; } else { ProtobufType = RuntimeTypeModel.Default[MessageTypes[i].BaseType]; } ProtobufType.AddSubType(SubTypeCount[MessageTypes[i].BaseType], MessageTypes[i].AsType()); SubTypeCount[MessageTypes[i].BaseType]++; } IsInitialized = true; }
public ProtobufValue(ulong value) : this() { this.Type = ProtobufType.Unsigned; this.Unsigned = value; }
public ProtobufValue(string value) : this() { this.String = value; this.Type = ProtobufType.String; }
public ProtobufValue(long value) : this() { this.Signed = value; this.Type = ProtobufType.Signed; }
public ProtobufValue(float value) : this() { this.Float32 = value; this.Type = ProtobufType.Float32; }
public ProtobufValue(double value) : this() { this.Float64 = value; this.Type = ProtobufType.Float64; }
public ProtobufValue(bool value) : this() { this.Boolean = value; this.Type = ProtobufType.Boolean; }