//------------------------------------------------------------------------------------- #region << Methods >> /// <summary> /// Возвращает true, если объект заглушен, false - если зарегистрирован /// </summary> /// <param name="obj"></param> /// <param name="cox"></param> /// <param name="typeid"></param> /// <param name="objid"></param> /// <returns></returns> private static bool StubGOLObject(GlobalObject obj, SerContext cox, ushort typeid, uint objid) { if(cox.asEmptyTypes.Contains(obj.GetType()) || cox.asEmptyObjects.Contains(obj)) { #region SerObjectInfo si = new SerObjectInfo(); si.typeID = (ushort)InfraTypes.PulsarEmptyStub; si.objID = objid; si.fields = new List<SerFieldInfo>(1); SerFieldInfo fsi = new SerFieldInfo(); fsi.typeID = typeid; si.fields.Add(fsi); if(obj is GlobalObject) { fsi = new SerFieldInfo(); fsi.typeID = (ushort)PrimitiveTypes.OID; fsi.name = "oid"; fsi.value = ToBytes(((GlobalObject)obj).OID); si.fields.Add(fsi); } si.Save(cox.stream); #endregion return true; } bool noStub = cox.noStubObjects.Contains(obj); if(noStub == false && cox.noStubTypes.Count > 0) { Type t = obj.GetType(); while(t != null) if((noStub = cox.noStubTypes.Contains(t)) == true) break; else t = t.BaseType; } if(typeid == 0) typeid = cox.types.GetTypeID(obj.GetType()); if(objid == 0) objid = cox.objs.GetObjID(typeid, obj); if(noStub) { cox.stream.WriteUInt16((ushort)InfraTypes.GOLObjectRegistrator); if(Pulsar.Server.ServerParamsBase.IsServer == false && GOL.Contains(obj) == false) GOL.Add(obj); } else cox.stream.WriteUInt16((ushort)InfraTypes.GOLObjectStub); cox.stream.WriteUInt16(typeid); cox.stream.WriteUInt32(objid); cox.stream.WriteBytes(ToBytes(obj.OID)); if(noStub) { if(((IReadWriteLockObject)obj).IsLocked == false) ((IReadWriteLockObject)obj).BeginRead(); cox.stack.Push(obj); } return !noStub; }