当前位置: 首页>>代码示例>>C#>>正文


C# ObjectManager.RegisterObject方法代码示例

本文整理汇总了C#中ObjectManager.RegisterObject方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectManager.RegisterObject方法的具体用法?C# ObjectManager.RegisterObject怎么用?C# ObjectManager.RegisterObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObjectManager的用法示例。


在下文中一共展示了ObjectManager.RegisterObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
		ClsType1 cls1;
		ClsType2 cls2;
		Int32 iValue;
		MemberInfo[] classMembers1;
		MemberInfo[] classMembers2;
		try {
			strLoc = "Loc_734rgt";			
			iCountTestcases++;
			cls1 = new ClsType1();
			cls2 = new ClsType2();
			iValue = 10;
			classMembers1 = FormatterServices.GetSerializableMembers(typeof(ClsType1), context);
			classMembers2 = FormatterServices.GetSerializableMembers(typeof(ClsType2), context);
			manager = new ObjectManager(selector, context);
			manager.RecordFixup(2, classMembers2[0], 3);
			manager.RecordFixup(1, classMembers1[0], 2);
			manager.RegisterObject(cls1, 1);
			manager.RegisterObject(cls2, 2);			
			manager.RegisterObject(iValue, 3);
			manager.DoFixups();
			if(cls1.ClsTp2.I != 10){
				iCountErrors++;
				Console.WriteLine("Err_374sdg! Change of behavioue, unexpected value returned, " + cls1.ClsTp2.I);
			}
			manager.RaiseDeserializationEvent();
			if(cls1.ClsTp2.I != 15){
				iCountErrors++;
				Console.WriteLine("Err_987345sg! Change of behavioue, unexpected value returned, " + cls1.ClsTp2.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;
		}
	}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:53,代码来源:co8627raisedeserializationevent.cs

示例2: NestedValueTypes

 public static bool NestedValueTypes() {
 ObjectManager manager = new ObjectManager(null, new StreamingContext(StreamingContextStates.All));
 Val1 val1 = new Val1(2);
 manager.RegisterObject(val1, 1);
 manager.RegisterObject(val1.val, 2, null, 1, Val1.valFieldInfo);
 manager.RegisterObject(val1.val.Foo, 3, null, 2, Val2.fooFieldInfo);
 manager.RegisterObject(val1.val.Bar, 4, null, 2, Val2.barFieldInfo);
 manager.RecordFixup(4, Val3.aFieldInfo, 5);
 int newValue = 42;
 A a = new A(newValue);
 manager.RegisterObject(a, 5);
 manager.DoFixups();
 Val1 valPost = (Val1)manager.GetObject(1);
 return (valPost.Int32Value==newValue);
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:15,代码来源:covaluetypefixup.cs

示例3: Bug

 private static bool Bug() {
 ObjectManager objmgr1;
 StreamingContext sc1;
 ObjectIDGenerator objid1;
 TestFixup tstfxp1;
 Int64 iRootID;
 Int64 iChildID;
 String strValue;
 MemberInfo[] members;
 Boolean fFirstTime;
 sc1 = new StreamingContext(StreamingContextStates.All);
 tstfxp1 = new TestFixup();
 strValue = "Hello World";
 objid1 = new ObjectIDGenerator();
 iRootID = objid1.GetId(tstfxp1, out fFirstTime);
 iChildID = objid1.GetId(strValue, out fFirstTime);
 members = FormatterServices.GetSerializableMembers(tstfxp1.GetType()); 
 objmgr1 = new ObjectManager(null, sc1);
 objmgr1.RecordFixup(iRootID, members[0], iChildID);
 try {
 objmgr1.RegisterObject(strValue, iChildID);	
 return true;
 } catch(Exception ex){
 Console.WriteLine("Bug:Exception thrown, " + ex);
 return false;
 }
 }
开发者ID:ArildF,项目名称:masters,代码行数:27,代码来源:coserializationregression.cs

示例4: DriverSetup

 public override void DriverSetup()
 {
     _mngObject = gobSystemManager.GetComponent<ObjectManager>();
     transMyTransform = gameObject.transform;
     _mngObject.RegisterObject(gameObject, this);
     AdditionalSetup();
 }
开发者ID:thomasslee97,项目名称:musicvisualizer,代码行数:7,代码来源:ObjectDriver.cs

示例5: TestObjectManagerRegisterObject

	// Test object registration.
	public void TestObjectManagerRegisterObject()
			{
				ObjectManager mgr = new ObjectManager
					(null, new StreamingContext(StreamingContextStates.All));

				// Test error cases.
				try
				{
					mgr.RegisterObject(null, 0);
					Fail("RegisterObject (1)");
				}
				catch(ArgumentNullException)
				{
					// Success.
				}
				try
				{
					mgr.RegisterObject(new Object(), 0);
					Fail("RegisterObject (2)");
				}
				catch(ArgumentOutOfRangeException)
				{
					// Success.
				}
				try
				{
					mgr.RegisterObject(new Object(), -1);
					Fail("RegisterObject (3)");
				}
				catch(ArgumentOutOfRangeException)
				{
					// Success.
				}
				mgr.RegisterObject(new Object(), 1);
				try
				{
					// Register a different object with the same ID.
					mgr.RegisterObject(new Object(), 1);
					Fail("RegisterObject (4)");
				}
				catch(SerializationException)
				{
					// Success.
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:46,代码来源:TestObjectManager.cs

示例6: 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));
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:20,代码来源:TestObjectManager.cs

示例7: 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;
		StreamingContext sc1 = new StreamingContext(StreamingContextStates.All);
		ObjectIDGenerator objid1 = null;
		TestFixup tstfxp1;
		Int64 iRootID;
		Int64 iChildID;
		String strValue;
		bool fFirstTime;
		MemberInfo[] members = null;
		try {
			do
			{
				strLoc="Loc_174cds";
				tstfxp1 = new TestFixup();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tstfxp1, out fFirstTime);
				strValue = "Hello Universe";
				iChildID = objid1.GetId(strValue, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(tstfxp1.GetType());
				objmgr1 = new ObjectManager(null, sc1);
				iCountTestcases++;
				if(objmgr1.GetObject(iRootID)!=null)
				{
					iCountErrors++;
					Console.WriteLine("Err_753cd! Expected value not returned, " + objmgr1.GetObject(iRootID));
				}
				objmgr1.RecordFixup(iRootID, members[0], iChildID);
				iCountTestcases++;
				if(objmgr1.GetObject(iRootID)!=null)
				{
					iCountErrors++;
					Console.WriteLine("Err_048fd! Expected value not returned, " + objmgr1.GetObject(iRootID));
				}
				objmgr1.RegisterObject(tstfxp1, iRootID);
				iCountTestcases++;
				if(objmgr1.GetObject(iRootID)==null)
				{
					iCountErrors++;
					Console.WriteLine("Err_0943fd! Null returned");
				}
				iCountTestcases++;
				if(!((TestFixup)(objmgr1.GetObject(iRootID))).strFixupValue.Equals("Hello World"))
				{
					iCountErrors++;
					Console.WriteLine("Err_047fe! wrong value returned returned, " + ((TestFixup)(objmgr1.GetObject(iRootID))).strFixupValue);
				}
				objmgr1.RegisterObject(strValue, iChildID);
				iCountTestcases++;
				if(objmgr1.GetObject(iChildID)==null)
				{
					iCountErrors++;
					Console.WriteLine("Err_90853vdf! Null returned");
				}
				iCountTestcases++;
				if(!objmgr1.GetObject(iChildID).Equals("Hello Universe"))
				{
					iCountErrors++;
					Console.WriteLine("Err_1084cs! wrong value returned returned, " + objmgr1.GetObject(iChildID));
				}
				try{
					iCountTestcases++;
					objmgr1.GetObject(-5);
					iCountErrors++;
					Console.WriteLine("Err_04872d! Exception not thrown");
					}catch(ArgumentOutOfRangeException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_1083xs! Wrong Exception thrown, " + ex);
				}
			} while (false);
			} 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;
		}
	}
开发者ID:ArildF,项目名称:masters,代码行数:91,代码来源:co3893getobject_lng.cs

示例8: 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;
		}
	}
开发者ID:ArildF,项目名称:masters,代码行数:100,代码来源:co3894registerobject_oiser.cs

示例9: 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";
		try {
			do
			{
				ObjectManager objMan;
				String str1, str2;
				ISurrogateSelector isur = null;
				StreamingContext sc1 = new StreamingContext(StreamingContextStates.All);
				strLoc = "Loc_100aa";
				objMan = new ObjectManager(isur, sc1);
				iCountTestcases++;
				try
				{
					objMan.RegisterObject(null, 0);
					iCountErrors++;
					printerr("Error_100bb! Expected exception not thrown");
				}
				catch (ArgumentNullException) {
					}catch (Exception exc){
					iCountErrors++;
					printerr("Error_100cc! Incorrect Exception thrown: exc=="+exc.ToString());
				}
				strLoc = "Loc_200aa";
				str1 = "Test";
				objMan = new ObjectManager(isur, sc1);
				objMan.RegisterObject(str1, 1);
				iCountTestcases++;
				if(!((String)objMan.GetObject(1)).Equals(str1))
				{
					iCountErrors++;
					printerr("Error_200bb! Incorrect object returned");
				}
				strLoc = "Loc_300aa";
				str1 = "Test";
				objMan = new ObjectManager(isur, sc1);
				iCountTestcases++;
				try
				{
					objMan.RegisterObject(str1, -5);
					iCountErrors++;
					printerr("Error_300bb! Exception exception not thrown for negative Id");
				}
				catch (ArgumentException) {
					}catch (Exception exc){
					iCountErrors++;
					printerr("Error_300cc! Incorrect exception thrown : exc=="+exc.ToString());
				}
				strLoc = "Loc_400aa";
				str1 = "Test";
				objMan = new ObjectManager(isur, sc1);
				objMan.RegisterObject(str1, Int64.MaxValue);
				iCountTestcases++;
				if(!((String)objMan.GetObject(Int64.MaxValue)).Equals(str1))
				{
					iCountErrors++;
					printerr("Error_856bdf! Incorrect object returned");
				}
				strLoc = "Loc_500aa";
				str1 = "Test1";
				str2 = "Test2";
				objMan = new ObjectManager(isur, sc1);
				objMan.RegisterObject(str1, 5);
				try
				{
					objMan.RegisterObject(str2, 5);
					iCountErrors++;
					printerr("Error_493fh! Trying to register same ObjectID twice should throw exception");
				}
				catch (SerializationException)
				{
				}
				catch (Exception exc)
				{
					iCountErrors++;
					printerr("Loc8235vdr! Incorrect Exception thrown: \n"+exc.ToString());
				}
				iCountTestcases++;
				if(!((String)objMan.GetObject(5)).Equals(str1))
				{
					iCountErrors++;
					printerr("Error_500bb! Incorrect object returned");
				}
				Int16 i16SameValue = 20;
				Int32 i32SameValue = 1310740;
				objMan = new ObjectManager(isur, sc1);
				objMan.RegisterObject(i16SameValue, i16SameValue.GetHashCode());
				iCountTestcases++;
				try
				{
					objMan.RegisterObject(i32SameValue, i32SameValue.GetHashCode());
				}
				catch(SerializationException){}
				catch (Exception exc)
				{
					iCountErrors++;
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co5244registerobject_obj_lng.cs

示例10: runTest

	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
		String strLoc = "Loc_000oo";
		String strValue = String.Empty;
		int iCountErrors = 0;
		int iCountTestcases = 0;
		ObjectManager objmgr1 = null;
		ISurrogateSelector isur = null;
		StreamingContext sc1 = new StreamingContext(StreamingContextStates.All);
		ObjectIDGenerator objid1 = null;
		TestFixup tstfxp1;
		Int64 iRootID;
		Int64 iChildID;
		bool fFirstTime;
		MemberInfo[] members = null;
		try
		{
			strLoc = "Loc_9347sg";
			iCountTestcases++;
			try{
				ConstructOM(); 
				iCountErrors++;
				Console.WriteLine("Err_7349sg! No exception thrown, ");
			}catch(SecurityException){
			}catch(Exception ex){
				iCountErrors++;
				Console.WriteLine("Err_348tdg! Wrong exception thrown, " + ex.GetType().Name);
			}
			strLoc = "Loc_3946tsg";
			iCountTestcases++;
			tstfxp1 = new TestFixup();
			objid1 = new ObjectIDGenerator();
			iRootID = objid1.GetId(tstfxp1, out fFirstTime);
			strValue = "Hello World";
			iChildID = objid1.GetId(strValue, out fFirstTime);
			members = FormatterServices.GetSerializableMembers(tstfxp1.GetType());
			objmgr1 = new ObjectManager(isur, sc1);
			objmgr1.RecordFixup(iRootID, members[0], iChildID);
			objmgr1.RegisterObject(tstfxp1, iRootID);
			objmgr1.RegisterObject(strValue, iChildID);
			iCountTestcases++;
			if(!tstfxp1.strFixupValue.Equals(strValue))
			{
				iCountErrors++;
				Console.WriteLine("Err_753cd! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
			}
			objmgr1.DoFixups();
			iCountTestcases++;
			if(!tstfxp1.strFixupValue.Equals(strValue))
			{
				iCountErrors++;
				Console.WriteLine("Err_90342ddvs! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
			}
		} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL! "+s_strTFName+" ,inCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
开发者ID:ArildF,项目名称:masters,代码行数:69,代码来源:co8650objectmanager.cs

示例11: Start


//.........这里部分代码省略.........
                {
                    if (merge.drugName == entry.name)
                    {
                        bool found = false;

                        // Check dosage
						if(merge.doses != null)
						{
	                        foreach (DrugMerge.DoseOrder order in merge.doses)
	                        {
	                            if (entry.dosage == order.amount && entry.doseType == order.type)
	                            {
	                                found = true;
	                                break;
	                            }
	                        }
						}
                        if (!found)
                        {
                            // Add data to this merge entry
                            DrugMerge.DoseOrder newOrder = new DrugMerge.DoseOrder();
                            newOrder.amount = entry.dosage;
                            newOrder.type = entry.doseType;
                            merge.doses.Add(newOrder);
                        }
                        found = false;

                        // Check delivery
						if(merge.delivery != null)
						{
	                        foreach (DrugMerge.DeliveryOrder order in merge.delivery)
	                        {
	                            if (entry.delivery == order.type)
	                            {
	                                found = true;
	                                break;
	                            }
	                        }
						}
                        if (!found)
                        {
                            DrugMerge.DeliveryOrder newOrder = new DrugMerge.DeliveryOrder();
                            newOrder.type = entry.delivery;
                            merge.delivery.Add(newOrder);
                        }
                        found = false;

                        // Check Interval
						if(merge.intervals != null)
						{
	                        foreach (DrugMerge.IntervalOrder order in merge.intervals)
	                        {
	                            if (entry.time == order.amount && entry.interval == order.type)
	                            {
	                                found = true;
	                                break;
	                            }
	                        }
						}
                        if (!found)
                        {
                            DrugMerge.IntervalOrder newOrder = new DrugMerge.IntervalOrder();
                            newOrder.amount = entry.time;
                            newOrder.type = entry.interval;
                            merge.intervals.Add(newOrder);
                        }
                    }
                }
            }
        }

        objMgr = ObjectManager.GetInstance();
        if (objMgr != null)
            objMgr.RegisterObject(this);
        else
            return;

        InteractionMgr interactionMgr = InteractionMgr.GetInstance();
        if(interactionMgr != null)
        {
            character = gameObject.AddComponent<Character>();
            character.ItemResponse = new List<InteractionMap>();
            foreach (InteractionMap map in interactionMgr.Interactions)
            {
                if (map.item == "MED:ORDERDRUGS")
                {
                    character.ItemResponse.Add(map);
                    character.AllMaps = character.ItemResponse;
                    objMgr.RegisterObject(character);

                    character.Name = "PharMgr";
                    character.prettyname = "PharMgr";
                    //character.Awake();
                    character.Start();

                    return;
                }
            }
        }
    }
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:101,代码来源:PharmacyManager.cs

示例12: 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;
		}
	}
开发者ID:ArildF,项目名称:masters,代码行数:90,代码来源:co8626ctor_is.cs

示例13: 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);
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:co8628registerobject_oisim.cs

示例14: 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;
		String strValue;
		bool fFirstTime;
		MemberInfo[] members = null;
		TestReference tst1;
		ThisImplementsIObjectReference tst2;
		try {
			do
			{
				strLoc="Loc_174cds";
				tstfxp1 = new TestFixup();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tstfxp1, out fFirstTime);
				strValue = "Hello World";
				iChildID = objid1.GetId(strValue, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(tstfxp1.GetType());
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordFixup(iRootID, members[0], iChildID);
				objmgr1.RegisterObject(tstfxp1, iRootID);
				objmgr1.RegisterObject(strValue, iChildID);
				iCountTestcases++;
				if(!tstfxp1.strFixupValue.Equals(strValue))
				{
					iCountErrors++;
					Console.WriteLine("Err_753cd! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
				}
				objmgr1.DoFixups();
				iCountTestcases++;
				if(!tstfxp1.strFixupValue.Equals(strValue))
				{
					iCountErrors++;
					Console.WriteLine("Err_90342ddvs! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
				}
				strLoc="Loc_5720xs";
				tst1 = new TestReference();
				tst2 = new ThisImplementsIObjectReference();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tst1, out fFirstTime);
				iChildID = objid1.GetId(tst2, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(typeof(TestReference));
				Console.WriteLine("<<" + members[0].Name + ">>");
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordFixup(iRootID, members[0], iChildID);
				objmgr1.RegisterObject(tst1, iRootID);
				objmgr1.RegisterObject(tst2, iChildID);
				try{
					iCountTestcases++;
					objmgr1.DoFixups();
					iCountErrors++;
					Console.WriteLine("Err_753fvdf! exception not thrown!!");
				}catch(SerializationException){
				}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_04523cd! 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.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;
		}
	}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:83,代码来源:co3892dofixups.cs

示例15: 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;
		String strValue;
		bool fFirstTime;
		MemberInfo[] members = null;
		Test1 tst1;
		A a1;
		Int32 iOurMan;
		Boolean fChildFound;
		Test2 tst2;
		Test3 tst3;
		B b1;
		try {
			do
			{
				tstfxp1 = new TestFixup();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tstfxp1, out fFirstTime);
				strValue = "Hello World";
				iChildID = objid1.GetId(strValue, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(tstfxp1.GetType());
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordFixup(iRootID, members[0], iChildID);
				objmgr1.RegisterObject(tstfxp1, iRootID);
				objmgr1.RegisterObject(strValue, iChildID);
				iCountTestcases++;
				if(!tstfxp1.strFixupValue.Equals(strValue))
				{
					iCountErrors++;
					Console.WriteLine("Err_753cd! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
				}
				objmgr1.DoFixups();
				iCountTestcases++;
				if(!tstfxp1.strFixupValue.Equals(strValue))
				{
					iCountErrors++;
					Console.WriteLine("Err_90342ddvs! Expected value not returned, " + tstfxp1.strFixupValue + ", expected, " + strValue);
				}
				tst1 = new Test1();
				a1 = new A();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tst1, out fFirstTime);
				iChildID = objid1.GetId(a1, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(typeof(Test1));
				iOurMan = -1;
				fChildFound=false;
				for(int i=0; i<members.Length;i++){
					if(members[i].Name.Equals("a")){
						fChildFound=true;
						iOurMan=i;
						break;
					}
				}
				if(!fChildFound)
				throw new Exception("Loc_342ds! didn't find the member");
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordFixup(iRootID, members[iOurMan], iChildID);
				try{
					iCountTestcases++;
					objmgr1.RegisterObject(a1, iChildID);
					objmgr1.RegisterObject(tst1, iRootID);
					objmgr1.DoFixups();
					Console.WriteLine("Loc_0283! exception not thrown");
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_04523cd! Unexpected exception, " + ex.ToString());
				}
				tst1 = new Test1();
				objid1 = new ObjectIDGenerator();
				iRootID = objid1.GetId(tst1, out fFirstTime);
				a1 = new A();
				iChildID = objid1.GetId(a1, out fFirstTime);
				members = FormatterServices.GetSerializableMembers(typeof(Test1));
				iOurMan = -1;
				fChildFound=false;
				for(int i=0; i<members.Length;i++){
					if(members[i].Name.Equals("a")){
						fChildFound=true;
						iOurMan=i;
						break;
					}
				}
				if(!fChildFound)
				throw new Exception("Loc_342ds! didn't find the member");
				objmgr1 = new ObjectManager(isur, sc1);
				objmgr1.RecordFixup(iRootID, members[iOurMan], iChildID);
				try{
					iCountTestcases++;
					objmgr1.DoFixups();
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:co3861recordfixup.cs


注:本文中的ObjectManager.RegisterObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。