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


C# Base.GetType方法代码示例

本文整理汇总了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;

    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:30,代码来源:typegethashcode.cs

示例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);
     }
 }
开发者ID:masroore,项目名称:db4o,代码行数:12,代码来源:COR57TestCase.cs

示例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;
     }
 }
开发者ID:arturcp,项目名称:boycott,代码行数:14,代码来源:ValidatesPresenceOfAttribute.cs

示例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();
  }
开发者ID:Reticulatas,项目名称:MochaEngineFinal,代码行数:30,代码来源:director_classes_runme.cs

示例5: CreateSODA

 private IQuery CreateSODA(Base template)
 {
     var q = NewQuery(template.GetType());
     q.Descend("name").Constrain(template.name);
     return q;
 }
开发者ID:masroore,项目名称:db4o,代码行数:6,代码来源:COR57TestCase.cs


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