本文整理汇总了C#中Type.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Type.GetType方法的具体用法?C# Type.GetType怎么用?C# Type.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type.GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEntity
public override object GetEntity (Uri absoluteUri, string role, Type ofObjectToReturn)
{
if (absoluteUri == null)
throw new ArgumentNullException ("absoluteUri");
if (absoluteUri.IsAbsoluteUri)
throw new XmlException ("URI must be relative to the application XAP");
if (!SupportsType (absoluteUri, ofObjectToReturn))
throw new XmlException (String.Format ("Unsupported entity type '{0}'", ofObjectToReturn.GetType ()));
try {
var sri = method.Invoke (null, new object [] {absoluteUri});
if (sri == null)
throw new XmlException (String.Format ("Resource '{0}' not found", absoluteUri));
return property.GetValue (sri, new object [0]);
} catch (TargetInvocationException tie) {
// throw the original exception
throw tie.InnerException;
}
}
示例2: GetInitializer
// The SOAP extension was configured to run using a configuration file
// instead of an attribute applied to a specific XML Web service
// method.
public override object GetInitializer(Type WebServiceType)
{
// Return a file name to log the trace information to, based on the
// type.
return WebServiceType.GetType().ToString() + ".log";
}
示例3: GetRuntimeType
/// <summary>
/// The GetRuntimeType method reverses GetReflectionType to convert a reflection type
/// back into a runtime type. Historically the Type.UnderlyingSystemType property has
/// been used to return the runtime type. This isn't exactly correct, but it needs
/// to be preserved unless all type description providers are revised.
/// </summary>
public virtual Type GetRuntimeType(Type reflectionType)
{
if (_parent != null)
{
return _parent.GetRuntimeType(reflectionType);
}
if (reflectionType == null)
{
throw new ArgumentNullException(nameof(reflectionType));
}
if (reflectionType.GetType().GetTypeInfo().Assembly == typeof(object).GetTypeInfo().Assembly)
{
return reflectionType;
}
return reflectionType.GetTypeInfo().UnderlyingSystemType;
}
示例4: GetUnderlyingType
public static Type GetUnderlyingType(Type type)
{
Type underlyingType = typeof(int);
if (type.GetType().FullName.Equals("System.Workflow.ComponentModel.Compiler.DesignTimeType", StringComparison.Ordinal))// designTimeType = type as System.Workflow.ComponentModel.Compiler.DesignTimeType;
{
//this is a design time type, need to get the enum type data out of it
MethodInfo methodInfo = type.GetType().GetMethod("GetEnumType");
Debug.Assert(methodInfo != null, "Missing GetEnumType method on the DesignTimeType!");
if (methodInfo != null)
{
Type result = methodInfo.Invoke(type, new object[0]) as Type;
underlyingType = (result != null) ? result : underlyingType;
}
}
else
{
underlyingType = Enum.GetUnderlyingType(type);
}
return underlyingType;
}
示例5: Test_Update_UpdatesTypeInDatabase
public void Test_Update_UpdatesTypeInDatabase()
{
//Arrange
string name = "Aardvark";
Type testType = new Type(name);
testType.Save();
string newName = "Badger";
//Act
testType.Update(newName);
string result = testType.GetType();
//Assert
Assert.Equal(newName, result);
}