public static void Serialize(SerializationWriter writer, Color color) { BitVector32 flags = new BitVector32(); if (color.IsKnownColor) flags[ColorIsKnown] = true; else if (color.IsNamedColor) flags[ColorHasName] = true; else if (!color.IsEmpty) { flags[ColorHasValue] = true; flags[ColorHasRed] = color.R != 0; flags[ColorHasGreen] = color.G != 0; flags[ColorHasBlue] = color.B != 0; flags[ColorHasAlpha] = color.A != 0; } writer.WriteOptimized(flags); if (color.IsKnownColor) writer.WriteOptimized((int) color.ToKnownColor()); else if (color.IsNamedColor) writer.WriteOptimized(color.Name); else if (!color.IsEmpty) { byte component; if ( (component = color.R) != 0) writer.Write(component); if ( (component = color.G) != 0) writer.Write(component); if ( (component = color.B) != 0) writer.Write(component); if ( (component = color.A) != 0) writer.Write(component); } }
public void TestNull() { using (MemoryStream ms = new MemoryStream()) using (SerializationWriter sw = new SerializationWriter(ms)) using (SerializationReader sr = new SerializationReader(ms)) { sw.Write<object>(null); sw.Write<int[]>(null); sw.Write<List<int>>(null); sw.Write<Dictionary<int, string>>(null); sw.Write<TestSerializable>(null); } }
public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { using (SerializationWriter writer = new SerializationWriter()) { writer.Write(_name); writer.WriteObject(_dataType); writer.WriteObject(_value); info.AddValue("d", writer.ToArray()); } }
public void WriteToStream(SerializationWriter sw) { int count = beatmapInfo.Count; sw.Write(count); for (int i = 0; i < count; i++) { beatmapInfo[i].WriteToStream(sw); } }
public static void EncodeCollectionDatabase(string path, CollectionDatabase db) { using (SerializationWriter writer = new SerializationWriter(new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))) { writer.Write(db.OsuVersion); writer.Write(db.CollectionCount); foreach (var collection in db.Collections) { writer.Write(collection.Name); writer.Write(collection.Count); foreach (var hash in collection.MD5Hashes) { writer.Write(hash); } } } }
public override void GetObjectData(SerializationInfo info, StreamingContext context) { #if FAST_SERIALIZATION using (SerializationWriter writer = new SerializationWriter()) { string[] ids; writer.Write(UniqueId); writer.Write(_alias); writer.Write(ScriptBase.GetUniqueIds(Columns)); writer.Write(_enabled); writer.Write(_isUserDefined); writer.Write(_name); //writer.WriteObject(_parent); writer.Write(ScriptBase.GetUniqueIds(ReferencedColumns)); if (ReferencedKey == null) { writer.WriteObject(null); } else { writer.WriteObject(ReferencedKey.UniqueId); } if (ReferencedTable == null) { writer.WriteObject(null); } else { writer.WriteObject(ReferencedTable.UniqueId); } writer.Write(_type); writer.WriteObject(_userOptions); info.AddValue("d", writer.ToArray()); } #else info.AddValue("SerializationVersion", SerializationVersion); info.AddValue("Alias", _alias); info.AddValue("Columns", _columns); info.AddValue("Enabled", _enabled); //info.AddValue("ExposedUserOptions", this._exposedUserOptions); info.AddValue("IsUserDefined", _isUserDefined); info.AddValue("Name", _name); info.AddValue("Parent", _parent); info.AddValue("ReferencedColumns", _referencedColumns); info.AddValue("ReferencedKey", _referencedKey); info.AddValue("ReferencedTable", _referencedTable); info.AddValue("Type", _type); info.AddValue("UserOptions", _userOptions); info.AddValue("Description", _description); #endif }
public static async Task ChatChannelAvailable(this Presence p, string name, string topic, short userCount, SerializationWriter writer) { var packet = new Packet { Type = PacketType.ServerChatChannelAvailable }; writer.Write(name); writer.Write(topic); writer.Write(userCount); packet.Data = ((MemoryStream)writer.BaseStream).ToArray(); writer.BaseStream.SetLength(0); writer.BaseStream.Position = 0; p.PacketEnqueue(packet); }
public void Save(SerializationWriter writer) { if (ReadResource()) { writer.Write(0);//parameter writer.Write(_idx.Count); foreach (var aKV in _idx) { writer.WriteObject(aKV.Key); writer.Write(aKV.Value.Id); } FinishReadResource(); return; } throw new CollisionException(); }
public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { using (SerializationWriter writer = new SerializationWriter()) { writer.Write(_name); writer.WriteObject(_dataType); writer.WriteObject(_value); info.AddValue("d", writer.ToArray()); } }
/// <summary> /// Implementing the ISerializable to provide a faster, more optimized /// serialization for the class. /// </summary> public void GetObjectData(SerializationInfo info, StreamingContext context) { SerializationWriter writer = new SerializationWriter(); writer.Write(_stampId); writer.WriteObject(_receiverId); writer.WriteObject(_senderId); // Put to the info. info.AddValue("data", writer.ToArray()); }
public void WriteToStream(SerializationWriter writer) { writer.Write(Source.ToString()); writer.Write(Message); var value = Target; if (Target != null) { if (Target.StartsWith("#mp_")) { value = "#multiplayer"; } else if (Target.StartsWith("#spect_")) { value = "#spectator"; } } writer.Write(value); writer.Write(SenderId); }
public void WriteToStream(SerializationWriter w) { w.Write(PlayerId); w.Write(PlayerName); w.Write(UtcOffset); w.Write(CountryByte); int rankPart = (byte)PlayerRank & 0b0001_1111; int modePart = ((byte)GameMode << 5) & 0b1110_0000; w.Write((byte)(rankPart | modePart)); w.Write(Longitude); w.Write(Latitude); w.Write(GlobalRank); w.Write(LastUpdate); }
public override void GetObjectData(SerializationInfo info, StreamingContext context) { #if FAST_SERIALIZATION using (SerializationWriter writer = new SerializationWriter()) { writer.Write(UniqueId); writer.Write(_alias); writer.Write(_enabled); //writer.Write(_exposedUserOptions); writer.Write(Filter.UniqueId); //writer.Write(_foreignColumns); writer.Write(ScriptBase.GetUniqueIds(ForeignColumns)); writer.Write(ForeignRelationship.UniqueId); writer.Write(ForeignScriptObject.UniqueId); writer.Write(_isUserDefined); writer.Write(_name); //writer.WriteObject(_parent); //writer.Write(_primaryColumns); writer.Write(ScriptBase.GetUniqueIds(PrimaryColumns)); //writer.WriteObject(_primaryScriptObject); writer.WriteObject(_userOptions); info.AddValue("d", writer.ToArray()); } #else info.AddValue("SerializationVersion", SerializationVersion); info.AddValue("Alias", _alias); info.AddValue("Enabled", _enabled); //info.AddValue("ExposedUserOptions", _exposedUserOptions); info.AddValue("Filter", _filter); info.AddValue("ForeignColumns", _foreignColumns); info.AddValue("ForeignRelationship", _foreignRelationship); info.AddValue("ForeignScriptObject", _foreignScriptObject); info.AddValue("IsUserDefined", _isUserDefined); info.AddValue("Name", _name); info.AddValue("Parent", _parent); info.AddValue("PrimaryColumns", _primaryColumns); info.AddValue("PrimaryScriptObject", _primaryScriptObject); info.AddValue("UserOptions", _userOptions); info.AddValue("Description", _description); #endif }
/// <summary> /// Implementing the ISerializable to provide a faster, more optimized /// serialization for the class. /// </summary> public void GetObjectData(SerializationInfo info, StreamingContext context) { SerializationWriter writer = new SerializationWriter(); lock (_stamps) { writer.Write((object[])_stamps.ToArray()); } // Put to the info. info.AddValue("data", writer.ToArray()); }
public static async Task FriendList(this Presence p, int[] friendIds) { var packet = new Packet { Type = PacketType.ServerFriendsList }; await using var writer = new SerializationWriter(new MemoryStream()); friendIds ??= Array.Empty <int>(); writer.Write((short)friendIds.Length); foreach (var t in friendIds) { writer.Write(t); } packet.Data = ((MemoryStream)writer.BaseStream).ToArray(); p.PacketEnqueue(packet); }
public virtual void Serialize(SerializationWriter writer) { writer.Write(intCount); // info.AddValue("intCount", intCount); if (rbTree == null) { writer.WritePointer(null); // info.AddValue("rbTree", null); } else { writer.WritePointer(rbTree); // info.AddValue("rbTree", rbTree); } }
/// <summary> /// Saves the graph element bunch. /// </summary> /// <returns> The path to the graph element bunch </returns> /// <param name='range'> Range. </param> /// <param name='graphElements'> Graph elements. </param> /// <param name='pathToSavePoint'> Path to save point basis. </param> private static String SaveBunch(Tuple <Int32, Int32> range, BigList <AGraphElement> graphElements, String pathToSavePoint) { var partitionFileName = pathToSavePoint + Constants.GraphElementsSaveString + range.Item1 + "_to_" + range.Item2; using (var partitionFile = File.Create(partitionFileName, Constants.BufferSize, FileOptions.SequentialScan)) { var partitionWriter = new SerializationWriter(partitionFile); partitionWriter.Write(range.Item1); partitionWriter.Write(range.Item2); for (var i = range.Item1; i < range.Item2; i++) { AGraphElement aGraphElement; //there can be nulls if (!graphElements.TryGetElementOrDefault(out aGraphElement, i)) { partitionWriter.WriteOptimized(SerializedNull); // 2 for null continue; } //code if it is an vertex or an edge if (aGraphElement is VertexModel) { WriteVertex((VertexModel)aGraphElement, partitionWriter); } else { WriteEdge((EdgeModel)aGraphElement, partitionWriter); } } partitionWriter.UpdateHeader(); partitionWriter.Flush(); partitionFile.Flush(); } return(Path.GetFileName(partitionFileName)); }
public void WriteToStream(SerializationWriter writer) { writer.Write(Id); Status.WriteToStream(writer); writer.Write(totalScore); writer.Write(Accuracy); writer.Write(playCount); writer.Write(rankedScore); writer.Write(rankPosition); writer.Write(perfomancePoints); }
public void WriteToStream(SerializationWriter w) { w.Write(UserId); Status.WriteToStream(w); w.Write(RankedScore); w.Write(Accuracy); w.Write(Playcount); w.Write(TotalScore); w.Write(Rank); w.Write(Performance); }
public void Serialize(SerializationWriter writer) { writer.Write(Id); Status.Serialize(writer); writer.Write(RankedScore); writer.Write(Accuracy / 100f); writer.Write(PlayCount); writer.Write(TotalScore); writer.Write(Rank); writer.Write(PP); }
public virtual void Save(SerializationWriter SW) { SW.WriteType(this); SW.WriteStartElement("Container"); SW.WriteVersion(0); SW.Write("Name", Name); SW.Write("Owner", Owner); SW.Write("NbrX", NbrX); SW.Write("NbrY", NbrY); for (int i = 0; i < NbrX * NbrY; i++) { if (Entitys[i] == null) { SW.WriteEmpty(); } else { Entitys[i].Save(SW); } } SW.WriteEndElement(); }
public virtual void Save(SerializationWriter SW) { SW.WriteStartElement("EntityList"); SW.WriteVersion(0); SW.Write("Length", Entitys.Length); for (int i = 0; i < Entitys.Length; i++) { Entitys[i].Save(SW); } SW.WriteEndElement(); }
public void WriteToStream(SerializationWriter w) { w.Write(UsesOsuClient ? UserId : -UserId); w.Write(Username); w.Write((byte)(Timezone + 24)); w.Write(CountryCode); w.Write((((byte)Permissions & 0b00011111) | (((byte)PlayMode & 0b00000111) << 5))); //bitwise and isn't needed, but it looks cool and is consistent with the reading w.Write(Longitude); w.Write(Latitude); w.Write(Rank); }
public void WriteToStream(SerializationWriter sw) { sw.Write(userId); status.WriteToStream(sw); sw.Write(rankedScore); sw.Write(accuracy); sw.Write(playcount); sw.Write(totalScore); sw.Write(rank); sw.Write(performance); }
public void SerializeCommands(Stream outStream) { if (CommandQueue.IsEmpty) { return; } var writer = new SerializationWriter(outStream); Command command; while (outStream.Length < 6144L && this.CommandQueue.TryDequeue(out command)) { var begin = writer.BaseStream.Position; writer.Write(command.Id); writer.Write((byte)0); writer.Write(0); if (command.noHasData) { continue; } if (command.Serializable != null) { command.Serializable.WriteToStream(writer); } else { writer.method_0(command.RegularType); //TODO: Improve this } writer.BaseStream.Position = begin + 3; //this is weird >_> writer.Write((int)(writer.BaseStream.Length - begin) - 7); writer.Seek(0, SeekOrigin.End); } //Debug.WriteLine($"Sent: {Utils.ByteArrayRepr((writer.BaseStream as MemoryStream).ToArray())}"); outStream.Position = 0; }
public override void GetObjectData(SerializationInfo info, StreamingContext context) { #if FAST_SERIALIZATION using (SerializationWriter writer = new SerializationWriter()) { foreach (FilterColumn col in _filterColumns) { col.Parent = this; } writer.Write(UniqueId); writer.Write(_alias); writer.Write(_createStoredProcedure); writer.Write(_customWhere); writer.Write(_enabled); //writer.WriteObject(_exposedUserOptions); writer.WriteObject(_filterColumns); writer.Write(_isReturnTypeCollection); writer.Write(_isUserDefined); writer.Write(_name); writer.WriteObject(_orderByColumns); //writer.WriteObject(_parent); writer.Write(_useCustomWhere); writer.WriteObject(_userOptions); info.AddValue("d", writer.ToArray()); } info.AddValue("UserOptions", this._userOptions); #else info.AddValue("SerializationVersion", SerializationVersion); info.AddValue("Alias", _alias); info.AddValue("CreateStoredProcedure", _createStoredProcedure); info.AddValue("CustomWhere", _customWhere); info.AddValue("Enabled", _enabled); info.AddValue("FilterColumns", _filterColumns); info.AddValue("IsReturnTypeCollection", _isReturnTypeCollection); info.AddValue("IsUserDefined", _isUserDefined); info.AddValue("Name", _name); info.AddValue("OrderByColumns", _orderByColumns); info.AddValue("Parent", _parent); info.AddValue("UserCustomWhere", _useCustomWhere); info.AddValue("UserOptions", _userOptions); info.AddValue("Description", _description); #endif }
public void WriteToStream(Stream s) { SerializationWriter sw = new SerializationWriter(s); sw.Write((short)id); sw.Write(beatmapId); sw.Write(beatmapSetId); sw.Write(threadId); sw.Write((byte)ranked); sw.Write((byte)playerRank); sw.Write(checksum); }
public static async Task ChatChannelJoinSuccess(this Presence p, string channel) { var packet = new Packet { Type = PacketType.ServerChatChannelJoinSuccess }; await using var writer = new SerializationWriter(new MemoryStream()); writer.Write(channel); packet.Data = ((MemoryStream)writer.BaseStream).ToArray(); p.PacketEnqueue(packet); }
public static async Task UserPermissions(this Presence p, BanchoPermissions perms) { var packet = new Packet { Type = PacketType.ServerUserPermissions }; await using var writer = new SerializationWriter(new MemoryStream()); writer.Write((int)perms); packet.Data = ((MemoryStream)writer.BaseStream).ToArray(); p.PacketEnqueue(packet); }
public static async Task UserPresenceSingle(this Presence p, int userId) { var packet = new Packet { Type = PacketType.ServerUserPresenceSingle }; await using var writer = new SerializationWriter(new MemoryStream()); writer.Write(userId); packet.Data = ((MemoryStream)writer.BaseStream).ToArray(); p.PacketEnqueue(packet); }
public static async Task ChatChannelListingComplete(this Presence p, int i) { var packet = new Packet { Type = PacketType.ServerChatChannelListingComplete }; await using var writer = new SerializationWriter(new MemoryStream()); writer.Write(i); packet.Data = ((MemoryStream)writer.BaseStream).ToArray(); p.PacketEnqueue(packet); }
public void WriteToStream(SerializationWriter sw) { sw.Write(sendingClient.ToString()); sw.Write(message); //cloak multiplayer channels before serialising any messages. string targetCloaked = target; if (target != null) { if (target.StartsWith("#mp_")) { targetCloaked = "#multiplayer"; } else if (target.StartsWith("#spect_")) { targetCloaked = "#spectator"; } } sw.Write(targetCloaked); sw.Write(senderId); }
public static async Task LoginReply(this Presence p, int reply) { var packet = new Packet { Type = PacketType.ServerLoginReply }; await using var writer = new SerializationWriter(new MemoryStream()); writer.Write((int)reply); packet.Data = ((MemoryStream)writer.BaseStream).ToArray(); p.PacketEnqueue(packet); }
public void TestUTF16Chars() { using (MemoryStream ms = new MemoryStream()) using (SerializationWriter sw = new SerializationWriter(ms, new UnicodeEncoding())) using (SerializationReader sr = new SerializationReader(ms, new UnicodeEncoding())) { for (int i = 0; i < 55296; i++) sw.Write((char)i); sw.Flush(); ms.Position = 0; for (int i = 0; i < 55296; i++) Assert.AreEqual((char)i, sr.Read<char>()); } }
public void TestUTF16String() { using (MemoryStream ms = new MemoryStream()) using (SerializationWriter sw = new SerializationWriter(ms, new UnicodeEncoding())) using (SerializationReader sr = new SerializationReader(ms, new UnicodeEncoding())) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < 55296; i++) sb.Append((char)i); string res = sb.ToString(); sw.Write(res); sw.Flush(); ms.Position = 0; Assert.AreEqual(res, sr.Read<string>()); } }
public void TestBytes() { Random rand = new Random(); using (MemoryStream ms = new MemoryStream()) using (SerializationWriter sw = new SerializationWriter(ms)) using (SerializationReader sr = new SerializationReader(ms)) { byte[] values = new byte[Config.MULTI_TEST_COUNT]; rand.NextBytes(values); for (int i = 0; i < Config.MULTI_TEST_COUNT; i++) sw.Write(values[i]); sw.Flush(); ms.Position = 0; for (int i = 0; i < Config.MULTI_TEST_COUNT; i++) Assert.AreEqual(values[i], sr.Read<byte>()); } }
public void TestBasicDictionary() { Random rand = new Random(); using (MemoryStream ms = new MemoryStream()) using (SerializationWriter sw = new SerializationWriter(ms)) using (SerializationReader sr = new SerializationReader(ms)) { Dictionary<int, float> dict = new Dictionary<int, float>(Config.MULTI_TEST_COUNT); for (int i = 0; i < Config.MULTI_TEST_COUNT; i++) dict[rand.Next(int.MinValue, int.MaxValue)] = (float)rand.NextDouble(); sw.Write(dict); sw.Flush(); ms.Position = 0; Dictionary<int, float> ret = sr.Read<Dictionary<int, float>>(); foreach (KeyValuePair<int, float> kvp in dict) Assert.AreEqual(kvp.Value, ret[kvp.Key]); } }
public void TestBasicArray() { Random rand = new Random(); using (MemoryStream ms = new MemoryStream()) using (SerializationWriter sw = new SerializationWriter(ms)) using (SerializationReader sr = new SerializationReader(ms)) { int[] array = new int[Config.MULTI_TEST_COUNT]; for (int i = 0; i < Config.MULTI_TEST_COUNT; i++) array[i] = rand.Next(int.MinValue, int.MaxValue); sw.Write(array); sw.Flush(); ms.Position = 0; int[] ret = sr.Read<int[]>(); for (int i = 0; i < ret.Length; i++) Assert.AreEqual(array[i], ret[i]); } }
public void TestBasicList() { Random rand = new Random(); using (MemoryStream ms = new MemoryStream()) using (SerializationWriter sw = new SerializationWriter(ms)) using (SerializationReader sr = new SerializationReader(ms)) { List<int> list = new List<int>(Config.MULTI_TEST_COUNT); for (int i = 0; i < Config.MULTI_TEST_COUNT; i++) list.Add(rand.Next(int.MinValue, int.MaxValue)); sw.Write(list); sw.Flush(); ms.Position = 0; List<int> ret = sr.Read<List<int>>(); for (int i = 0; i < list.Count; i++) Assert.AreEqual(list[i], ret[i]); } }
public void TestBools() { Random rand = new Random(); using (MemoryStream ms = new MemoryStream()) using (SerializationWriter sw = new SerializationWriter(ms)) using (SerializationReader sr = new SerializationReader(ms)) { bool[] values = new bool[Config.MULTI_TEST_COUNT]; for (int i = 0; i < Config.MULTI_TEST_COUNT; i++) { values[i] = rand.Next(0, 2) == 1; sw.Write(values[i]); } sw.Flush(); ms.Position = 0; for (int i = 0; i < Config.MULTI_TEST_COUNT; i++) Assert.AreEqual(values[i], sr.Read<bool>()); } }
public void TestDateTimes() { Random rand = new Random(); using (MemoryStream ms = new MemoryStream()) using (SerializationWriter sw = new SerializationWriter(ms)) using (SerializationReader sr = new SerializationReader(ms)) { DateTime[] values = new DateTime[Config.MULTI_TEST_COUNT]; for (int i = 0; i < Config.MULTI_TEST_COUNT; i++) { values[i] = new DateTime(rand.Next(1970, 5623), rand.Next(1, 13), rand.Next(1, 29), rand.Next(0, 24), rand.Next(0, 60), rand.Next(0, 60), DateTimeKind.Utc); sw.Write(values[i]); } sw.Flush(); ms.Position = 0; for (int i = 0; i < Config.MULTI_TEST_COUNT; i++) Assert.AreEqual(values[i], sr.Read<DateTime>()); } }
private void Serialize(ref SerializationWriter mySerializationWriter, DirectoryEntry myDirectoryEntry) { try { #region Write the InlineData mySerializationWriter.Write(myDirectoryEntry._InlineData); #endregion #region Write the INodePositions mySerializationWriter.WriteUInt32((UInt32)myDirectoryEntry.INodePositions.Count); foreach (var _ExtendedPosition in myDirectoryEntry.INodePositions) { _ExtendedPosition.StorageUUID.Serialize(ref mySerializationWriter); mySerializationWriter.WriteUInt64(_ExtendedPosition.Position); } #endregion #region Write the ObjectStreamsList mySerializationWriter.WriteUInt32((UInt32)myDirectoryEntry.ObjectStreamsList.Count); foreach (var _ObjectStreamType in myDirectoryEntry.ObjectStreamsList) mySerializationWriter.WriteString(_ObjectStreamType); #endregion myDirectoryEntry.isDirty = false; } catch (SerializationException e) { throw new SerializationException(e.Message); } }
protected override void GetObjectData(SerializationWriter sw) { if (sw == null) { throw new ArgumentNullException("sw"); } base.GetObjectData(sw); sw.Write(_IsOp); sw.Write(_IsVoice); }
public override void GetObjectData(SerializationInfo info, StreamingContext context) { #if FAST_SERIALIZATION using (SerializationWriter writer = new SerializationWriter()) { writer.Write(_alias); writer.Write(_characterMaximumLength); writer.Write(_dataType); writer.Write(_direction); writer.Write(_enabled); writer.Write(_isUserDefined); writer.Write(_name); writer.Write(_ordinalPosition); writer.WriteObject(_userOptions); writer.Write(_precision); writer.Write(_scale); info.AddValue("d", writer.ToArray()); } #else info.AddValue("SerializationVersion", SerializationVersion); info.AddValue("Alias", _alias); info.AddValue("CharacterMaximumLength", _characterMaximumLength); info.AddValue("DataType", _dataType); info.AddValue("Direction", _direction); info.AddValue("Enabled", _enabled); //info.AddValue("ExposedUserOptions", _exposedUserOptions); info.AddValue("IsUserDefined", _isUserDefined); info.AddValue("Name", _name); info.AddValue("OrdinalPosition", _ordinalPosition); info.AddValue("UserOptions", _userOptions); info.AddValue("Precision", _precision); info.AddValue("Scale", _scale); #endif }
public override void GetObjectData(SerializationInfo info, StreamingContext context) { #if FAST_SERIALIZATION using (SerializationWriter writer = new SerializationWriter()) { _ColumnsSortedByName = null; int i = _database.StoredProcedures.Length; writer.Write(UniqueId); writer.Write(_alias); writer.Write(_aliasPlural); writer.WriteObject(_columns); //writer.WriteObject(_database); writer.Write(_enabled); writer.WriteObject(_filters); writer.Write(_isUserDefined); writer.WriteObject(_manyToManyRelationships); writer.WriteObject(_manyToOneRelationships); writer.Write(_name); writer.WriteObject(_oneToManyRelationships); writer.WriteObject(_oneToOneRelationships); writer.WriteObject(_parameters); writer.WriteObject(_userOptions); writer.Write(_Schema); writer.WriteObject(_Associations); info.AddValue("d", writer.ToArray()); } #else info.AddValue("SerializationVersion", SerializationVersion); info.AddValue("Alias", _alias); info.AddValue("AliasPlural", _aliasPlural); info.AddValue("Columns", _columns); info.AddValue("Database", _database); info.AddValue("Enabled", _enabled); //info.AddValue("ExposedUserOptions", _exposedUserOptions); info.AddValue("Filters", _filters); info.AddValue("IsUserDefined", _isUserDefined); info.AddValue("ManyToManyRelationships", _manyToManyRelationships); info.AddValue("ManyToOneRelationships", _manyToOneRelationships); info.AddValue("Name", _name); info.AddValue("OneToManyRelationships", _oneToManyRelationships); info.AddValue("OneToOneRelationships", _oneToOneRelationships); info.AddValue("Parameters", _parameters); info.AddValue("UserOptions", _userOptions); info.AddValue("Schema", _Schema); info.AddValue("Errors", _Errors); info.AddValue("Associations", _Associations); info.AddValue("Description", _description); #endif }
public override void Serialize(ref SerializationWriter mySerializationWriter) { try { mySerializationWriter.WriteString(_ContentType); mySerializationWriter.Write(_ObjectData); } catch (SerializationException e) { throw new SerializationException(e.Message); } }
/// <summary> /// Saves the service /// </summary> /// <param name="serviceName">Service name.</param> /// <param name="service">Service.</param> /// <param name="path">Path.</param> /// <returns>The filename of the persisted service.</returns> private static String SaveService(string serviceName, IService service, string path) { var serviceFileName = path + Constants.ServiceSaveString + serviceName; using (var serviceFile = File.Create(serviceFileName, Constants.BufferSize, FileOptions.SequentialScan)) { var serviceWriter = new SerializationWriter(serviceFile); serviceWriter.Write(serviceName); serviceWriter.Write(service.PluginName); service.Save(serviceWriter); serviceWriter.UpdateHeader(); serviceWriter.Flush(); serviceFile.Flush(); } return Path.GetFileName(serviceFileName); }
public static void Serialize(SerializationWriter writer, Unit unit) { var state = new BitVector32(); if (unit.IsEmpty) { writer.WriteOptimized(state); return; } state[UnitType] = (int) unit.Type; var integerValue = (int) Math.Round(unit.Value); var writeAsDouble = unit.Type != System.Web.UI.WebControls.UnitType.Pixel && Math.Abs(unit.Value - integerValue) > Epsilon; if (writeAsDouble) { state[UnitIsDoubleValue] = true; writer.WriteOptimized(state); writer.Write(unit.Value); } else if (integerValue == 0) { state[UnitIsZeroValue] = 1; writer.WriteOptimized(state); } else { var complementedValue = integerValue > 0 ? integerValue : -(integerValue + 1); if (complementedValue > SerializationWriter.HighestOptimizable16BitValue) { writer.WriteOptimized(state); writer.Write((short) integerValue); } else { state[UnitIsOptimizedValue] = 1; state[UnitIsNegativeValue] = integerValue > 0 ? 0 : 1; writer.WriteOptimized(state); writer.WriteOptimized(complementedValue); } } }
protected virtual void GetObjectData(SerializationWriter sw) { sw.Write(f_Value); }
public virtual void Serialize(SerializationWriter writer) { writer.WritePointer(arena); writer.Write(salience); }
public void Serialize(SerializationWriter writer) { writer.Write(definition); writer.WriteList(phrases); writer.WriteList(attributes); }
/// <summary> /// Writes the vertex. /// </summary> /// <param name='vertex'> Vertex. </param> /// <param name='writer'> Writer. </param> private static void WriteVertex(VertexModel vertex, SerializationWriter writer) { writer.Write(SerializedVertex); WriteAGraphElement(vertex, writer); #region edges var outgoingEdges = vertex._outEdges; if (outgoingEdges == null) { writer.Write(0); } else { writer.Write(outgoingEdges.Count); foreach (var aOutEdgeProperty in outgoingEdges) { writer.Write(aOutEdgeProperty.EdgePropertyId); writer.Write(aOutEdgeProperty.Edges.Count); foreach (var aOutEdge in aOutEdgeProperty.Edges) { writer.Write(aOutEdge.Id); } } } var incomingEdges = vertex._inEdges; if (incomingEdges == null) { writer.Write(0); } else { writer.Write(incomingEdges.Count); foreach (var aIncEdgeProperty in incomingEdges) { writer.Write(aIncEdgeProperty.EdgePropertyId); writer.Write(aIncEdgeProperty.Edges.Count); foreach (var aIncEdge in aIncEdgeProperty.Edges) { writer.Write(aIncEdge.Id); } } } #endregion }
protected override void GetObjectData(SerializationWriter sw) { base.GetObjectData(sw); sw.Write((Int32) UrlProtocol.Unknown); sw.Write(_Url); }
/// <summary> /// Writes A graph element. /// </summary> /// <param name='graphElement'> Graph element. </param> /// <param name='writer'> Writer. </param> private static void WriteAGraphElement(AGraphElement graphElement, SerializationWriter writer) { writer.Write(graphElement.Id); writer.Write(graphElement.CreationDate); writer.Write(graphElement.ModificationDate); var properties = graphElement.GetAllProperties(); writer.Write(properties.Count); foreach (var aProperty in properties) { writer.Write(aProperty.PropertyId); writer.WriteObject(aProperty.Value); } }
public void Save(SerializationWriter writer) { if (ReadResource()) { try { writer.Write(0);//parameter writer.Write(_idx.Count); foreach (var aKV in _idx) { writer.WriteObject(aKV.Key); writer.Write(aKV.Value.Count); foreach (var aItem in aKV.Value) { writer.Write(aItem.Id); } } } finally { FinishReadResource(); } return; } throw new CollisionException(this); }
protected override void GetObjectData(SerializationWriter sw) { base.GetObjectData(sw); sw.Write((Int32) _Protocol); }
/// <summary> /// Writes the edge. /// </summary> /// <param name='edge'> Edge. </param> /// <param name='writer'> Writer. </param> private static void WriteEdge(EdgeModel edge, SerializationWriter writer) { writer.Write(SerializedEdge); WriteAGraphElement(edge, writer); writer.Write(edge.SourceVertex.Id); writer.Write(edge.TargetVertex.Id); }
public void Serialize(SerializationWriter writer) { writer.Write(strength); writer.Write(weight); }
protected virtual void GetObjectData(SerializationWriter sw) { if (IsCompactable) { // OPT: compact all parts before serialization Compact(); } sw.Write(f_TimeStamp); sw.Write(f_MessageParts); sw.Write((Int32) f_MessageType); }
protected virtual void GetObjectData(SerializationWriter sw) { sw.Write(f_IsHighlight); }