internal bool OnHandleIsReference(XmlWriterDelegator xmlWriter, DataContract contract, object obj) { if (preserveObjectReferences || !contract.IsReference || _isGetOnlyCollection) { return(false); } bool isNew = true; int objectId = SerializedObjects.GetId(obj, ref isNew); _byValObjectsInScope.EnsureSetAsIsReference(obj); if (isNew) { xmlWriter.WriteAttributeString(Globals.SerPrefix, DictionaryGlobals.IdLocalName, DictionaryGlobals.SerializationNamespace, string.Format(CultureInfo.InvariantCulture, "{0}{1}", "i", objectId)); return(false); } else { xmlWriter.WriteAttributeString(Globals.SerPrefix, DictionaryGlobals.RefLocalName, DictionaryGlobals.SerializationNamespace, string.Format(CultureInfo.InvariantCulture, "{0}{1}", "i", objectId)); return(true); } }
private void InternalSerializeWithSurrogate(XmlWriterDelegator xmlWriter, object obj, bool isDeclaredType, bool writeXsiType, int declaredTypeID, RuntimeTypeHandle declaredTypeHandle) { RuntimeTypeHandle objTypeHandle = isDeclaredType ? declaredTypeHandle : obj.GetType().TypeHandle; object oldObj = obj; int objOldId = 0; Type objType = Type.GetTypeFromHandle(objTypeHandle); Type declaredType = GetSurrogatedType(Type.GetTypeFromHandle(declaredTypeHandle)); declaredTypeHandle = declaredType.TypeHandle; obj = DataContractSerializer.SurrogateToDataContractType(_serializationSurrogateProvider, obj, declaredType, ref objType); objTypeHandle = objType.TypeHandle; if (oldObj != obj) { objOldId = SerializedObjects.ReassignId(0, oldObj, obj); } if (writeXsiType) { declaredType = Globals.TypeOfObject; SerializeWithXsiType(xmlWriter, obj, objTypeHandle, objType, -1, declaredType.TypeHandle, declaredType); } else if (declaredTypeHandle.Equals(objTypeHandle)) { DataContract contract = GetDataContract(objTypeHandle, objType); SerializeWithoutXsiType(contract, xmlWriter, obj, declaredTypeHandle); } else { SerializeWithXsiType(xmlWriter, obj, objTypeHandle, objType, -1, declaredTypeHandle, declaredType); } if (oldObj != obj) { SerializedObjects.ReassignId(objOldId, obj, oldObj); } }
void UpdateSelection() { string currentSelectionHash = SelectionEditor.GetSelectionHash(); if( lastSelectionHash != currentSelectionHash ) { //split shapes into group s based on type Shape[] shapes = SelectionEditor.GetSelectedShapes(); serializedShape = new SerializedObjects<Shape>( shapes ); lastSelectionHash = currentSelectionHash; } }