本文整理汇总了C#中ObjectManager.RecordDelayedFixup方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectManager.RecordDelayedFixup方法的具体用法?C# ObjectManager.RecordDelayedFixup怎么用?C# ObjectManager.RecordDelayedFixup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectManager
的用法示例。
在下文中一共展示了ObjectManager.RecordDelayedFixup方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestObjectManagerGetObject
// Test object retrieval.
public void TestObjectManagerGetObject()
{
ObjectManager mgr = new ObjectManager
(null, new StreamingContext(StreamingContextStates.All));
// Register a particular object and then look for it.
Object obj = new Object();
mgr.RegisterObject(obj, 1234);
AssertSame("GetObject (1)", obj, mgr.GetObject(1234));
// Look for a non-existent object.
AssertNull("GetObject (2)", mgr.GetObject(1235));
// Record a delayed fixup for some other object.
mgr.RecordDelayedFixup(1236, "x", 1234);
// Object 1236 shouldn't exist yet.
AssertNull("GetObject (3)", mgr.GetObject(1236));
}
示例2: runTest
public bool runTest()
{
Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
int iCountErrors = 0;
int iCountTestcases = 0;
String strLoc = "Loc_000oo";
IFormatter formatter;
SurrogateSelector selector;
MySerializationSurrogate surrogate;
StreamingContext context = new StreamingContext(StreamingContextStates.All);
MemoryStream stream;
Int32 iValue;
A a;
ObjectManager manager;
ObjectIDGenerator generator;
Int64 rootId;
Int64 childId;
Boolean firstTime;
MemberInfo[] members;
try {
strLoc = "Loc_29457sdg";
iCountTestcases++;
selector = new SurrogateSelector();
surrogate = new MySerializationSurrogate();
selector.AddSurrogate(typeof(A), context, surrogate);
formatter = new BinaryFormatter();
formatter.SurrogateSelector = selector;
stream = new MemoryStream();
a = new A();
a.I = 10;
formatter.Serialize(stream, a);
stream.Position = 0;
A a1 = (A)formatter.Deserialize(stream);
if(a1.I != 30){
iCountErrors++;
Console.WriteLine("Err_753ffd! Unexpected value returned, Value: <{0}>", a1.I);
}
strLoc = "Loc_8394tfsg";
iCountTestcases++;
generator = new ObjectIDGenerator();
a = new A();
iValue = 500;
rootId = generator.GetId(a, out firstTime);
childId = generator.GetId(iValue, out firstTime);
selector = new SurrogateSelector();
surrogate = new MySerializationSurrogate();
selector.AddSurrogate(typeof(A), context, surrogate);
manager = new ObjectManager(selector, context);
members = FormatterServices.GetSerializableMembers(typeof(A));
manager.RecordDelayedFixup(rootId, "Int32Twist", childId);
try{
SerializationInfo serInfo1 = new SerializationInfo(typeof(A), new FormatterConverter());
manager.RegisterObject(a, rootId, serInfo1);
manager.RegisterObject(iValue, childId);
Console.WriteLine(a.I);
}catch(Exception ex){
iCountErrors++;
Console.WriteLine(ex);
}
strLoc = "Loc_87sgsfd";
iCountTestcases++;
generator = new ObjectIDGenerator();
a = new A();
iValue = 500;
rootId = generator.GetId(a, out firstTime);
childId = generator.GetId(iValue, out firstTime);
manager = new ObjectManager(null, context);
members = FormatterServices.GetSerializableMembers(typeof(A));
manager.RecordFixup(rootId, members[0], childId);
manager.RegisterObject(a, rootId);
manager.RegisterObject(iValue, childId);
if(a.I != 500){
iCountErrors++;
Console.WriteLine("Err_93745sg! Unexpected value returned, Value: <{0}>", a1.I);
}
} catch (Exception exc_general ) {
++iCountErrors;
Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general==\n"+exc_general.StackTrace);
}
if ( iCountErrors == 0 )
{
Console.WriteLine( "paSs. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
return true;
}
else
{
Console.WriteLine("FAiL! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
return false;
}
}
示例3: runTest
public bool runTest()
{
Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
int iCountErrors = 0;
int iCountTestcases = 0;
String strLoc = "Loc_000oo";
ObjectManager objmgr1 = null;
ISurrogateSelector isur = null;
StreamingContext sc1 = new StreamingContext(StreamingContextStates.All);
ObjectIDGenerator objid1 = null;
TestFixup tstfxp1;
Int64 iRootID;
Int64 iChildID;
Int32 iValue;
bool fFirstTime;
MemberInfo[] members = null;
SerializationInfo serInfo1;
try {
do
{
strLoc = "Loc_8345vdfv";
tstfxp1 = new TestFixup();
iValue = 10;
objid1 = new ObjectIDGenerator();
iRootID = objid1.GetId(tstfxp1, out fFirstTime);
iChildID = objid1.GetId(iValue, out fFirstTime);
members = FormatterServices.GetSerializableMembers(tstfxp1.GetType());
objmgr1 = new ObjectManager(isur, sc1);
objmgr1.RecordDelayedFixup(iRootID, "iFixupValue", iChildID);
serInfo1 = new SerializationInfo(typeof(TestFixup), new FormatterConverter());
objmgr1.RegisterObject(tstfxp1, iRootID, serInfo1);
iCountTestcases++;
if(objmgr1.GetObject(iRootID)==null)
{
iCountErrors++;
Console.WriteLine("Err_0943fd! Null returned");
}
objmgr1.RegisterObject(iValue, iChildID);
objmgr1.DoFixups();
strLoc = "Loc_017ged";
iCountTestcases++;
if(tstfxp1.iFixupValue != iValue)
{
iCountErrors++;
Console.WriteLine("Err_753cd! Expected value not returned, " + tstfxp1.iFixupValue.ToString() + ", expected, " + iValue.ToString());
}
strLoc = "Loc_0358vdf";
try
{
iCountTestcases++;
objmgr1.RegisterObject(null, iRootID, serInfo1);
iCountErrors++;
Console.WriteLine("Err_034cd! exception not thrown");
}
catch(ArgumentNullException){}
catch(Exception ex)
{
iCountErrors++;
Console.WriteLine("Err_03472fd! Unexpected exception, " + ex.ToString());
}
try
{
iCountTestcases++;
objmgr1.RegisterObject(tstfxp1, -5, serInfo1);
iCountErrors++;
Console.WriteLine("Err_037csd! exception not thrown");
}
catch(ArgumentOutOfRangeException){}
catch(Exception ex)
{
iCountErrors++;
Console.WriteLine("Err_710ca! Unexpected exception, " + ex.ToString());
}
try
{
iCountTestcases++;
objmgr1.RegisterObject(tstfxp1, 5, null);
Console.WriteLine("Loc_048cs! exception not thrown");
}
catch(Exception ex)
{
iCountErrors++;
Console.WriteLine("Err_079cd! Unexpected exception, " + ex.ToString());
}
} while (false);
} catch (Exception exc_general ) {
++iCountErrors;
Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general==\n"+exc_general.ToString());
}
if ( iCountErrors == 0 )
{
Console.WriteLine( "paSs. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases);
return true;
}
else
{
Console.WriteLine("FAiL! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors+" , BugNums?: "+s_strActiveBugNums );
return false;
}
}
示例4: runTest
public Boolean runTest()
{
Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
int iCountErrors = 0;
int iCountTestcases = 0;
String strLoc = "Loc_000oo";
ObjectManager manager;
ISurrogateSelector selector = null;
StreamingContext context = new StreamingContext(StreamingContextStates.All);
ClsType cls1;
ValType val1;
Int32 iValue;
MemberInfo[] valueMembers;
MemberInfo[] classMembers;
MemberInfo[] classMembers1;
ClsType1 cls2;
ClsType2 cls3;
ClsType3 cls4;
ValType1 val2;
SerializationInfo info;
try {
strLoc = "Loc_97356tsg";
iCountTestcases++;
cls1 = new ClsType();
val1 = new ValType();
iValue = 10;
classMembers = FormatterServices.GetSerializableMembers(typeof(ClsType), context);
valueMembers = FormatterServices.GetSerializableMembers(typeof(ValType), context);
manager = new ObjectManager(selector, context);
manager.RecordFixup(2, valueMembers[0], 3);
manager.RecordFixup(1, classMembers[0], 2);
manager.RegisterObject(cls1, 1);
manager.RegisterObject(val1, 2);
manager.RegisterObject(iValue, 3);
if(cls1.ValueType.I != 0){
iCountErrors++;
Console.WriteLine("Err_853rwtg! Change of behavioue, unexpected value returned, " + cls1.ValueType.I);
}
strLoc = "Loc_7934sgd";
iCountTestcases++;
cls1 = new ClsType();
val1 = new ValType();
iValue = 10;
classMembers = FormatterServices.GetSerializableMembers(typeof(ClsType), context);
valueMembers = FormatterServices.GetSerializableMembers(typeof(ValType), context);
manager = new ObjectManager(selector, context);
manager.RecordFixup(2, valueMembers[0], 3);
manager.RecordFixup(1, classMembers[0], 2);
manager.RegisterObject(cls1, 1);
manager.RegisterObject(val1, 2, null, 1, classMembers[0]);
manager.RegisterObject(iValue, 3);
if(cls1.ValueType.I != 10){
iCountErrors++;
Console.WriteLine("Err_23450sdg! Unexpected value returned, " + cls1.ValueType.I);
}
strLoc = "Loc_734rgt";
iCountTestcases++;
cls2 = new ClsType1();
cls3 = new ClsType2();
iValue = 10;
classMembers = FormatterServices.GetSerializableMembers(typeof(ClsType1), context);
classMembers1 = FormatterServices.GetSerializableMembers(typeof(ClsType2), context);
manager = new ObjectManager(selector, context);
manager.RecordFixup(2, classMembers1[0], 3);
manager.RecordFixup(1, classMembers[0], 2);
manager.RegisterObject(cls2, 1);
manager.RegisterObject(cls3, 2);
manager.RegisterObject(iValue, 3);
if(cls2.Cls2.I != 10){
iCountErrors++;
Console.WriteLine("Err_987345sg! Change of behavioue, unexpected value returned, " + cls2.Cls2.I);
}
strLoc = "Loc_9743sg";
iCountTestcases++;
cls4 = new ClsType3();
val2 = new ValType1();
iValue = 10;
classMembers = FormatterServices.GetSerializableMembers(typeof(ClsType3), context);
manager = new ObjectManager(selector, context);
manager.RecordDelayedFixup(2, "SerializationTest", 3);
manager.RecordFixup(1, classMembers[0], 2);
manager.RegisterObject(cls4, 1);
info = new SerializationInfo(typeof(ValType1), new FormatterConverter());
manager.RegisterObject(val2, 2, info, 1, classMembers[0]);
manager.RegisterObject(iValue, 3);
try{
manager.DoFixups();
}catch(ArgumentException){
}catch(Exception ex){
iCountErrors++;
Console.WriteLine("Err_3497tsdg! Wrong exception thrown, " + ex.GetType().Name);
}
strLoc = "Loc_8932745rsdf";
iCountTestcases++;
cls1 = new ClsType();
val1 = new ValType();
iValue = 10;
classMembers = FormatterServices.GetSerializableMembers(typeof(ClsType), context);
valueMembers = FormatterServices.GetSerializableMembers(typeof(ValType), context);
manager = new ObjectManager(selector, context);
//.........这里部分代码省略.........