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


C# Type.GetType方法代码示例

本文整理汇总了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;
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:19,代码来源:XmlXapResolver.cs

示例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";    
	}
开发者ID:louislatreille,项目名称:xsp,代码行数:9,代码来源:TraceExtension.cs

示例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;
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:25,代码来源:TypeDescriptionProvider.cs

示例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;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:21,代码来源:Helpers.cs

示例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);
        }
开发者ID:CharlesEwel,项目名称:animalshelter2,代码行数:16,代码来源:TypeTest.cs


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