protected override void Write(ICKBinaryWriter w, KeyOperations?restrictedOperations) { base.Write(w, restrictedOperations); w.Write((byte)0); w.WriteNonNegativeSmallInt32(_key.Length); w.Write(_key); }
/// <summary> /// Initializes a new object pool for a writer. /// </summary> /// <param name="w">The binary writer. Must not be null.</param> /// <param name="comparer">The comparer to use.</param> public ObjectPool(ICKBinaryWriter w, IEqualityComparer <T> comparer = null) { if (w == null) { throw new ArgumentNullException(nameof(w)); } _pool = new Dictionary <T, int>(comparer); _w = w; }
/// <summary> /// Writes this database into a binary stream. /// </summary> /// <param name="w">The writer to use.</param> public void Write(ICKBinaryWriter w) { var ctx = new SerializerContext(w, 0); _instances.Write(ctx); ctx.Writer.WriteNonNegativeSmallInt32(_feeds.Count); foreach (var kv in _feeds) { kv.Value.Write(_instances, ctx); } ctx.Writer.Write(_lastUpdate); }
/// <summary> /// Writes this requirement. /// </summary> /// <param name="w">The writer.</param> /// <param name="withInitiatorAlgorithmName">Optionally writes the <see cref="InitiatorAlgorithmName"/> if any.</param> public void Write(ICKBinaryWriter w, bool withInitiatorAlgorithmName = false) { w.Write((byte)0); w.WriteEnum(KeyType); w.WriteEnum(Operations); w.WriteNullableInt32(KeySizeInBits); HelperAndExtensions.WriteNullableOid(w, CurveName); if (withInitiatorAlgorithmName && InitiatorAlgorithmName != null) { w.Write(true); w.Write(InitiatorAlgorithmName); } else { w.Write(false); } }
/// <summary> /// Writes the <see cref="Name"/> and <see cref="Separator"/> so that <see cref="Read(ICKBinaryReader)"/> can /// rebuild or rebind to the context. /// </summary> /// <param name="w">The binary writer to use.</param> /// <param name="writeAllTags">True to write all existing tags.</param> public void Write(ICKBinaryWriter w, bool writeAllTags = false) { byte version = 0; if (IsShared) { version |= 128; } if (writeAllTags) { version |= 64; } w.Write(version); if (IsShared) { w.WriteSharedString(Name); } else { w.Write(Name); } w.Write(Separator); if (writeAllTags) { // ConcurrentDictionary.Values is a napshot in a ReadOnlyCollection<CKTrait> that wraps a List<CKTrait>. // Using Values means concretizing the list of all the traits where we only need atomic ones and internally locking // the dictionary. // Using the GetEnumerator has no lock. var atomics = new List <string>(); foreach (var t in _tags) { if (t.Value.IsAtomic && !t.Value.IsEmpty) { atomics.Add(t.Key); } } w.Write(atomics.Count); foreach (var s in atomics) { w.Write(s); } } }
/// <summary> /// This method must not be called directly: the static <see cref="Write(ICKBinaryWriter, KeyBase, KeyOperations?)"/> must be used. /// </summary> /// <param name="w">The target writer.</param> /// <param name="restrictedOperations">Optional replacement for <see cref="Operations"/>.</param> protected virtual void Write(ICKBinaryWriter w, KeyOperations?restrictedOperations) { KeyOperations o = Operations; if (restrictedOperations.HasValue) { if (!Operations.Supports(restrictedOperations.Value)) { throw new ArgumentException($"'{Operations}' must support '{restrictedOperations}'.", nameof(restrictedOperations)); } o = restrictedOperations.Value; } w.Write((byte)0); w.WriteEnum(Kty); w.Write(Kid.ToString()); w.WriteEnum(o); w.Write(CreationDate); w.Write(BestBefore); w.Write(MaxUseCount); w.Write(_oUseCount); }
public SerializerContext(ICKBinaryWriter writer, int version) { (Writer = writer).WriteNonNegativeSmallInt32(version); TraitContextPool = new CKBinaryWriter.ObjectPool <CKTraitContext>(Writer, PureObjectRefEqualityComparer <CKTraitContext> .Default); TraitPool = new CKBinaryWriter.ObjectPool <CKTrait>(Writer, PureObjectRefEqualityComparer <CKTrait> .Default); }
protected override void Write(ICKBinaryWriter w, KeyOperations?restrictedOperations) { base.Write(w, restrictedOperations); w.Write((byte)0); }
/// <summary> /// Serializes this password. /// </summary> /// <param name="w">The writer.</param> public void Write(ICKBinaryWriter w) { w.Write((byte)0); w.Write(Password); w.Write(Expiration); }
public void Write(ICKBinaryWriter writer, IAmNotAService service) { }
public void Write(ICKBinaryWriter writer, FrontService1 service) { }