本文整理汇总了C#中Base.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Base.GetType方法的具体用法?C# Base.GetType怎么用?C# Base.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base
的用法示例。
在下文中一共展示了Base.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PosTest2
public bool PosTest2()
{
bool retVal = true;
Type tpA;
int ActualResult;
TestLibrary.TestFramework.BeginScenario("PosTest2: the same type get hash code");
try
{
Base test1 = new Base();
Base test2 = new Base();
tpA = test1.GetType();
Type tpB = test2.GetType();
ActualResult = tpA.GetHashCode();
int ActualResult2 = tpB.GetHashCode();
if (ActualResult != ActualResult2)
{
TestLibrary.TestFramework.LogError("003","the ActualResult is not the ExpectResult");
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
retVal = false;
}
return retVal;
}
示例2: AssertQueryResult
private void AssertQueryResult(int expectedCount, Base expectedTemplate
, IObjectSet result)
{
Assert.AreEqual(expectedCount, result.Count, SimpleName(expectedTemplate.GetType(
)));
while (result.HasNext())
{
var actual = (Base) result.Next();
Assert.AreEqual(expectedTemplate.name, actual.name);
Assert.IsInstanceOf(expectedTemplate.GetType(), actual);
}
}
示例3: Validate
public override void Validate(Base value)
{
var property = value.GetType().GetProperty(PropertyName);
var propertyValue = property.GetValue(value, null);
var code = Type.GetTypeCode(property.PropertyType);
switch (code) {
case TypeCode.DateTime:
ValidateDateTime(propertyValue, value.Errors);
break;
default:
ValidateDefault(propertyValue, value.Errors);
break;
}
}
示例4: makeCalls
void makeCalls(Caller myCaller, Base myBase)
{
string NAMESPACE = "director_classesNamespace.";
myCaller.set(myBase);
DoubleHolder dh = new DoubleHolder(444.555);
// Class pointer, reference and pass by value tests
if (myCaller.ValCall(dh).val != dh.val) throw new Exception("failed");
if (myCaller.RefCall(dh).val != dh.val) throw new Exception("failed");
if (myCaller.PtrCall(dh).val != dh.val) throw new Exception("failed");
// Fully overloaded method test (all methods in base class are overloaded)
if (NAMESPACE + myCaller.FullyOverloadedCall(10) != myBase.GetType() + "::FullyOverloaded(int)") throw new Exception("failed");
if (NAMESPACE + myCaller.FullyOverloadedCall(true) != myBase.GetType() + "::FullyOverloaded(bool)") throw new Exception("failed");
// Semi overloaded method test (some methods in base class are overloaded)
if (NAMESPACE + myCaller.SemiOverloadedCall(-678) != myBase.GetType() + "::SemiOverloaded(int)") throw new Exception("failed");
if (myCaller.SemiOverloadedCall(true) != "Base" + "::SemiOverloaded(bool)") throw new Exception("failed");
// Default parameters methods test
if (NAMESPACE + myCaller.DefaultParmsCall(10, 2.2) != myBase.GetType() + "::DefaultParms(int, double)") throw new Exception("failed");
if (myBase.GetType() == typeof(CSharpDerived)) { // special handling for C# derived classes, there is no way to do this any other way
if (NAMESPACE + myCaller.DefaultParmsCall(10) != myBase.GetType() + "::DefaultParms(int, double)") throw new Exception("failed");
} else {
if (NAMESPACE + myCaller.DefaultParmsCall(10) != myBase.GetType() + "::DefaultParms(int)") throw new Exception("failed");
}
myCaller.reset();
}
示例5: CreateSODA
private IQuery CreateSODA(Base template)
{
var q = NewQuery(template.GetType());
q.Descend("name").Constrain(template.name);
return q;
}