public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { IList list = (IList) value; writer.WriteAttribute(LIST_TYPE, value.GetType().FullName); foreach (object o in list) context.ConvertOriginal(o); }
public override void WriteUpdate(Transaction transaction, IUpdateDepth updatedepth ) { if (!this._firstUpdate) { base.WriteUpdate(transaction, updatedepth); return; } this._firstUpdate = false; ObjectContainerBase container = transaction.Container(); this.SetStateClean(); MarshallingContext context = new MarshallingContext(transaction, this, updatedepth , false); Handlers4.Write(this.ClassMetadata().TypeHandler(), context, this.GetObject()); int length = this.Container().BlockConverter().BlockAlignedBytes(context.MarshalledLength ()); Slot slot = context.AllocateNewSlot(length); Pointer4 pointer = new Pointer4(this.GetID(), slot); ByteArrayBuffer buffer = context.ToWriteBuffer(pointer); container.WriteUpdate(transaction, pointer, this.ClassMetadata(), ArrayType.None, buffer); if (this.IsActive()) { this.SetStateClean(); } }
public override void WriteUpdate(Transaction transaction, IUpdateDepth updatedepth ) { if (!_firstUpdate) { base.WriteUpdate(transaction, updatedepth); return; } _firstUpdate = false; var container = transaction.Container(); SetStateClean(); var context = new MarshallingContext(transaction, this, updatedepth , false); Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject()); var length = Container().BlockConverter().BlockAlignedBytes(context.MarshalledLength ()); var slot = context.AllocateNewSlot(length); var pointer = new Pointer4(GetID(), slot); var buffer = context.ToWriteBuffer(pointer); container.WriteUpdate(transaction, pointer, ClassMetadata(), ArrayType.None, buffer); if (IsActive()) { SetStateClean(); } }
public _MarshallingInfoTraverseAspectCommand_122(MarshallingContext context, object obj, Transaction trans, IMarshallingInfo baseArg1) : base(baseArg1) { this.context = context; this.obj = obj; this.trans = trans; }
private void BlockAlign(MarshallingContext context, int precedingLength) { int totalLength = context.Container().BlockConverter().BlockAlignedBytes(precedingLength + Length()); int newLength = totalLength - precedingLength; BlockAlign(newLength); }
public virtual void MarshallAspects(object obj, MarshallingContext context) { Transaction trans = context.Transaction(); ITraverseAspectCommand command = new _MarshallingInfoTraverseAspectCommand_122(context , obj, trans, EnsureFieldList(context)); TraverseAllAspects(context, command); }
private static void WriteNode(XStreamWriter writer, MarshallingContext context, string node, object value) { writer.StartNode(node); Type type = value != null?value.GetType() : typeof(object); writer.WriteAttribute(Attributes.classType, type.AssemblyQualifiedName); context.ConvertAnother(value); writer.EndNode(); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { Array array = (Array) value; string typeName = value.GetType().AssemblyQualifiedName; int lastIndexOfBrackets = typeName.LastIndexOf("[]"); string arrayType = string.Concat(typeName.Substring(0, lastIndexOfBrackets), typeName.Substring(lastIndexOfBrackets + 2)); writer.WriteAttribute(ARRAY_TYPE, arrayType); foreach (object o in array) context.ConvertOriginal(o); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { IList list = (IList)value; writer.WriteAttribute(LIST_TYPE, value.GetType().FullName); foreach (object o in list) { context.ConvertOriginal(o); } }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { byte[] bytes = (byte[])value; string base64 = Convert.ToBase64String(bytes); writer.StartNode("byte-array"); writer.SetValue(base64); writer.EndNode(); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { IList list = (IList)value; // classType is not valid for cross platform usage //writer.WriteAttribute(LIST_TYPE, value.GetType().FullName); foreach (object o in list) { context.ConvertOriginal(o); } }
public virtual void WriteUpdate(Db4objects.Db4o.Internal.Transaction transaction, IUpdateDepth updatedepth) { ContinueSet(transaction, updatedepth); // make sure, a concurrent new, possibly triggered by objectOnNew // is written to the file // preventing recursive if (!BeginProcessing()) { return; } object obj = GetObject(); if (!ObjectCanUpdate(transaction, obj) || !IsActive() || obj == null || !ClassMetadata ().IsModified(obj)) { EndProcessing(); return; } MarshallingContext context = new MarshallingContext(transaction, this, updatedepth , false); if (context.UpdateDepth().Negative()) { EndProcessing(); return; } ObjectContainerBase container = transaction.Container(); LogEvent(container, "update", Const4.State); SetStateClean(); context.PurgeFieldIndexEntriesOnUpdate(transaction, container._handlers.ArrayType (obj)); Handlers4.Write(_class.TypeHandler(), context, obj); if (context.UpdateDepth().CanSkip(this)) { EndProcessing(); return; } Pointer4 pointer = context.AllocateSlot(); ByteArrayBuffer buffer = context.ToWriteBuffer(pointer); container.WriteUpdate(transaction, pointer, _class, container._handlers.ArrayType (obj), buffer); if (IsActive()) { SetStateClean(); } EndProcessing(); container.Callbacks().ObjectOnUpdate(transaction, this); ClassMetadata().DispatchEvent(transaction, obj, EventDispatchers.Update); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { IDictionary dictionary = (IDictionary)value; DoSpecificStuff(dictionary, writer); foreach (DictionaryEntry entry in dictionary) { writer.StartNode("entry"); WriteNode(writer, context, BaseDictionaryConverter <Hashtable> .KEY, entry.Key); WriteNode(writer, context, BaseDictionaryConverter <Hashtable> .VALUE, entry.Value); writer.EndNode(); } }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { Array array = (Array)value; string typeName = value.GetType().AssemblyQualifiedName; int lastIndexOfBrackets = typeName.LastIndexOf("[]"); string arrayType = string.Concat(typeName.Substring(0, lastIndexOfBrackets), typeName.Substring(lastIndexOfBrackets + 2)); writer.WriteAttribute(ARRAY_TYPE, arrayType); foreach (object o in array) { context.ConvertOriginal(o); } }
private static void MergeChildren(MarshallingContext context, int masterAddress, MarshallingBuffer writeBuffer, MarshallingBuffer parentBuffer, int linkOffset) { if (parentBuffer._children == null) { return; } IEnumerator i = new Iterator4Impl(parentBuffer._children); while (i.MoveNext()) { Merge(context, masterAddress, writeBuffer, parentBuffer, (MarshallingBuffer)i.Current , linkOffset); } }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { IDictionary dictionary = (IDictionary)value; DoSpecificStuff(dictionary, writer); foreach (DictionaryEntry entry in dictionary) { writer.StartNode("entry"); context.ConvertOriginal(entry.Key); context.ConvertOriginal(entry.Value); writer.EndNode(); } }
public override void Marshall(MarshallingContext context, object obj) { // alive needs to be checked by all callers: Done IUpdateDepth updateDepth = context.UpdateDepth(); if (obj != null && CascadeOnUpdate(context.ClassConfiguration())) { context.UpdateDepth(AdjustUpdateDepthForCascade(obj, updateDepth)); } context.WriteObjectWithCurrentState(GetHandler(), obj); context.UpdateDepth(updateDepth); if (HasIndex()) { context.AddIndexEntry(this, obj); } }
private void WriteIndex(MarshallingContext context, int masterAddress, int position ) { if (_indexedField != null) { // for now this is a String index only, it takes the entire slot. StatefulBuffer buffer = new StatefulBuffer(context.Transaction(), UnblockedLength ()); int blockedPosition = context.Container().BlockConverter().BytesToBlocks(position ); int indexID = masterAddress + blockedPosition; buffer.SetID(indexID); buffer.Address(indexID); TransferContentTo(buffer, UnblockedLength()); _indexedField.AddIndexEntry(context.Transaction(), context.ObjectID(), buffer); } }
private static void Merge(MarshallingContext context, int masterAddress, MarshallingBuffer writeBuffer, MarshallingBuffer parentBuffer, MarshallingBuffer childBuffer, int linkOffset) { int childPosition = writeBuffer.Offset(); writeBuffer.Reserve(childBuffer.BlockedLength()); MergeChildren(context, masterAddress, writeBuffer, childBuffer, linkOffset); int savedWriteBufferOffset = writeBuffer.Offset(); writeBuffer.Seek(childPosition); childBuffer.TransferContentTo(writeBuffer._delegate); writeBuffer.Seek(savedWriteBufferOffset); parentBuffer.WriteLink(childBuffer, childPosition + linkOffset, childBuffer.UnblockedLength ()); childBuffer.WriteIndex(context, masterAddress, childPosition + linkOffset); }
public override void Marshall(MarshallingContext context, object obj) { context.CreateIndirectionWithinSlot(); if (IsNotHandlingConcreteType(context)) { _typeHandler.Write(context, obj); return; } if (_typeHandler is IInstantiatingTypeHandler) { IInstantiatingTypeHandler instantiating = (IInstantiatingTypeHandler)_typeHandler; instantiating.WriteInstantiation(context, obj); instantiating.Write(context, obj); } else { _typeHandler.Write(context, obj); } }
/// <summary>return false if class not completely initialized, otherwise true</summary> internal virtual bool ContinueSet(Db4objects.Db4o.Internal.Transaction trans, IUpdateDepth updateDepth) { if (!BitIsTrue(Const4.Continue)) { return(true); } if (!_class.StateOK()) { return(false); } if (!_class.AspectsAreInitialized()) { return(false); } if (DTrace.enabled) { DTrace.Continueset.Log(GetID()); } BitFalse(Const4.Continue); MarshallingContext context = new MarshallingContext(trans, this, updateDepth, true ); Handlers4.Write(ClassMetadata().TypeHandler(), context, GetObject()); Pointer4 pointer = context.AllocateSlot(); ByteArrayBuffer buffer = context.ToWriteBuffer(pointer); ObjectContainerBase container = trans.Container(); container.WriteNew(trans, pointer, _class, buffer); object obj = _object; ObjectOnNew(trans, obj); if (_class.HasIdentity()) { _object = container.NewWeakReference(this, obj); } SetStateClean(); EndProcessing(); return(true); }
public virtual void Write(IWriteContext context, object obj) { if (obj == null) { context.WriteInt(0); return; } MarshallingContext marshallingContext = (MarshallingContext)context; ClassMetadata classMetadata = ClassMetadataFor(obj); if (classMetadata == null) { context.WriteInt(0); return; } MarshallingContextState state = marshallingContext.CurrentState(); marshallingContext.CreateChildBuffer(false); context.WriteInt(classMetadata.GetID()); WriteObject(context, classMetadata.TypeHandler(), obj); marshallingContext.RestoreState(state); }
public virtual MarshallingBuffer CheckBlockAlignment(MarshallingContext context, MarshallingBuffer precedingBuffer, IntByRef precedingLength) { _lastOffSet = Offset(); if (DoBlockAlign()) { precedingBuffer.BlockAlign(context, precedingLength.value); } if (precedingBuffer != null) { precedingLength.value += precedingBuffer.Length(); } precedingBuffer = this; if (_children != null) { IEnumerator i = new Iterator4Impl(_children); while (i.MoveNext()) { precedingBuffer = ((MarshallingBuffer)i.Current).CheckBlockAlignment(context, precedingBuffer , precedingLength); } } return(precedingBuffer); }
private object WriteAndRead(object obj) { int imaginativeID = 500; ObjectReference @ref = new ObjectReference(ClassMetadataForObject(obj), imaginativeID ); @ref.SetObject(obj); MarshallingContext marshallingContext = new MarshallingContext(Trans(), @ref, Container ().UpdateDepthProvider().ForDepth(int.MaxValue), true); Handlers4.Write(@ref.ClassMetadata().TypeHandler(), marshallingContext, obj); Pointer4 pointer = marshallingContext.AllocateSlot(); ByteArrayBuffer buffer = marshallingContext.ToWriteBuffer(pointer); buffer.Seek(0); // String str = new String(buffer._buffer); // System.out.println(str); UnmarshallingContext unmarshallingContext = new UnmarshallingContext(Trans(), @ref , Const4.AddToIdTree, false); unmarshallingContext.Buffer(buffer); unmarshallingContext.ActivationDepth(new LegacyActivationDepth(5)); return(unmarshallingContext.Read()); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { writer.WriteAttribute(Attributes.Null, true.ToString()); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { // classType is not valid for cross platform usage // writer.WriteAttribute(Attributes.AttributeType, value.GetType().AssemblyQualifiedName); writer.SetValue(value.ToString()); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { writer.WriteAttribute(Attributes.AttributeType, value.GetType().AssemblyQualifiedName); writer.SetValue(value.ToString()); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { writer.WriteAttribute(Attributes.Null, true.ToString()); }
private bool IsNotHandlingConcreteType(MarshallingContext context) { return(context.ClassMetadata() != _ownerMetadata); }
public virtual void MergeChildren(MarshallingContext context, int masterAddress, int linkOffset) { MergeChildren(context, masterAddress, this, this, linkOffset); }
// do nothing public override void Marshall(MarshallingContext context, object obj) { Marshall(context.Transaction(), context.Reference(), context, context.IsNew()); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { writer.SetValue(value.ToString()); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { writer.WriteAttribute(Attributes.AttributeType, value.GetType().AssemblyQualifiedName); writer.SetValue(value.ToString()); }
public abstract void Marshall(MarshallingContext context, object child);