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


C# System.Type类代码示例

本文整理汇总了C#中System.Type的典型用法代码示例。如果您正苦于以下问题:C# Type类的具体用法?C# Type怎么用?C# Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CanConvertTo

		public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
		{
			if (context == null)
				return false;
			var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;
			return p != null && destinationType == typeof (string);
		}
开发者ID:nagyist,项目名称:XamlForIphone,代码行数:7,代码来源:NameReferenceConverter.cs

示例2: ConvertTo

		public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
		{
			if (context == null)
				return null;
			var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;
			return p != null ? p.GetName (value) : null;
		}
开发者ID:nagyist,项目名称:XamlForIphone,代码行数:7,代码来源:NameReferenceConverter.cs

示例3: Convert

        public object Convert(object[] values,
                              Type targetType,
                              object parameter,
                              System.Globalization.CultureInfo culture)
        {
            if (values == null ||
                values.Length != 2)
            {
                return Visibility.Collapsed;
            }

            if (values[0] is IEnumerable<string>)
            {
                var a = (IEnumerable<string>)values[0];
                var b = values[1];

                if (a.Contains(b) == true)
                {
                    return Visibility.Collapsed;
                }
            }
            else if (values[0] is ItemCollection)
            {
                var a = (ItemCollection)values[0];
                var b = values[1];

                if (a.Contains(b) == true)
                {
                    return Visibility.Collapsed;
                }
            }

            return Visibility.Visible;
        }
开发者ID:spitfire1337,项目名称:Borderlands-2-Save-Editor,代码行数:34,代码来源:ContainsToVisiblityConverter.cs

示例4: ConvertBack

 public object[] ConvertBack(object value,
                             Type[] targetTypes,
                             object parameter,
                             System.Globalization.CultureInfo culture)
 {
     throw new NotSupportedException();
 }
开发者ID:spitfire1337,项目名称:Borderlands-2-Save-Editor,代码行数:7,代码来源:ContainsToVisiblityConverter.cs

示例5: GetModule

		private IEnumerable<PluginWrapper> GetModule(string pFileName, Type pTypeInterface)
		{
			var plugins = new List<PluginWrapper>();
			try
			{
				var assembly = Assembly.LoadFrom(pFileName);
				foreach(var type in assembly.GetTypes())
				{
					try
					{
						if(!type.IsPublic || type.IsAbstract)
							continue;
						var typeInterface = type.GetInterface(pTypeInterface.ToString(), true);
						if(typeInterface == null)
							continue;
						var instance = Activator.CreateInstance(type) as IPlugin;
						if(instance != null)
							plugins.Add(new PluginWrapper(pFileName, instance));
					}
					catch(Exception ex)
					{
						Logger.WriteLine("Error Loading " + pFileName + ":\n" + ex, "PluginManager");
					}
				}
			}
			catch(Exception ex)
			{
				Logger.WriteLine("Error Loading " + pFileName + ":\n" + ex, "PluginManager");
			}
			return plugins;
		}
开发者ID:rudzu,项目名称:Hearthstone-Deck-Tracker,代码行数:31,代码来源:PluginManager.cs

示例6: Convert

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType != typeof(bool))
                throw new InvalidOperationException("The target must be boolean.");

            return !(bool)value;
        }
开发者ID:peterschen,项目名称:SMAStudio,代码行数:7,代码来源:InverseBoolConverter.cs

示例7: ClassInfo

		public ClassInfo(bool isAbstract, Type superClass, Db4objects.Db4o.Reflect.Self.FieldInfo
			[] fieldInfo)
		{
			_isAbstract = isAbstract;
			_superClass = superClass;
			_fieldInfo = fieldInfo;
		}
开发者ID:bvangrinsven,项目名称:db4o-net,代码行数:7,代码来源:ClassInfo.cs

示例8: GetLoadableTypes

 public IEnumerable<Type> GetLoadableTypes(Assembly assembly, Type ofBaseType)
 {
     var types = GetLoadableTypes(assembly);
     return types != null
                ? types.Where(ofBaseType.IsAssignableFrom)
                : null;
 }
开发者ID:juancarlospalomo,项目名称:tantumcms,代码行数:7,代码来源:DefaultAssemblyLoader.cs

示例9: CreateInOutParamTypes

		protected override Type[] CreateInOutParamTypes(Uiml.Param[] parameters, out Hashtable outputPlaceholder)
		{
			outputPlaceholder = null;
			Type[] tparamTypes =  new Type[parameters.Length]; 
			int i=0;
			try
			{
				for(i=0; i<parameters.Length; i++)
				{
					tparamTypes[i] = Type.GetType(parameters[i].Type);
					int j = 0;
					while(tparamTypes[i] == null)	
						tparamTypes[i] = ((Assembly)ExternalLibraries.Instance.Assemblies[j++]).GetType(parameters[i].Type);
					//also prepare a placeholder when this is an output parameter
					if(parameters[i].IsOut)
					{
						if(outputPlaceholder == null)
							outputPlaceholder = new Hashtable();
						outputPlaceholder.Add(parameters[i].Identifier, null);
					}
				}
				return tparamTypes;
			}
				catch(ArgumentOutOfRangeException aore)
				{
					Console.WriteLine("Can not resolve type {0} of parameter {1} while calling method {2}",parameters[i].Type ,i , Call.Name);
					Console.WriteLine("Trying to continue without executing {0}...", Call.Name);
					throw aore;					
				}
		}
开发者ID:jozilla,项目名称:Uiml.net,代码行数:30,代码来源:LocalCaller.cs

示例10: TestRoute

        public void TestRoute(string url, string verb, Type type, string actionName)
        {
            //Arrange
            url = url.Replace("{apiVersionNumber}", this.ApiVersionNumber);
            url = Host + url;

            //Act
            HttpRequestMessage request = new HttpRequestMessage(new HttpMethod(verb), url);

            IHttpControllerSelector controller = this.GetControllerSelector();
            IHttpActionSelector action = this.GetActionSelector();

            IHttpRouteData route = this.Config.Routes.GetRouteData(request);
            request.Properties[HttpPropertyKeys.HttpRouteDataKey] = route;
            request.Properties[HttpPropertyKeys.HttpConfigurationKey] = this.Config;

            HttpControllerDescriptor controllerDescriptor = controller.SelectController(request);

            HttpControllerContext context = new HttpControllerContext(this.Config, route, request)
            {
                ControllerDescriptor = controllerDescriptor
            };

            var actionDescriptor = action.SelectAction(context);

            //Assert
            Assert.NotNull(controllerDescriptor);
            Assert.NotNull(actionDescriptor);
            Assert.Equal(type, controllerDescriptor.ControllerType);
            Assert.Equal(actionName, actionDescriptor.ActionName);
        }
开发者ID:abinabrahamanchery,项目名称:mixerp,代码行数:31,代码来源:GetPartyTypeIdByPartyCodeRouteTests.cs

示例11: InternalGetAjaxMethods

        private static Dictionary<string, AsyncMethodInfo> InternalGetAjaxMethods(Type type)
        {
            var ret = new Dictionary<string, AsyncMethodInfo>();
            var mis = CoreHelper.GetMethodsFromType(type);
            foreach (MethodInfo mi in mis)
            {
                string methodName = mi.Name;
                var method = CoreHelper.GetMemberAttribute<AjaxMethodAttribute>(mi);
                if (method != null)
                {
                    if (!string.IsNullOrEmpty(method.Name))
                    {
                        methodName = method.Name;
                    }

                    if (!ret.ContainsKey(methodName))
                    {
                        AsyncMethodInfo asyncMethod = new AsyncMethodInfo();
                        asyncMethod.Method = mi;
                        asyncMethod.Async = method.Async;
                        ret[methodName] = asyncMethod;
                    }
                }
            }

            return ret;
        }
开发者ID:rajayaseelan,项目名称:mysoftsolution,代码行数:27,代码来源:AjaxMethodHelper.cs

示例12: DeleteById

        public void DeleteById(Type type, string key, string value)
        {
            string sql = "delete from " + type.Name;
            sql += " where " + key + "=" + value;

            DBExtBase.ExeNonQueryBySqlText(this.dataCtx, sql);
        }
开发者ID:zitjubiz,项目名称:terryCBM,代码行数:7,代码来源:BaseService.cs

示例13: Help

 /// <summary>
 /// Displays help for the specified command.
 /// <param name="Command">Command type.</param>
 /// </summary>
 public static void Help(Type Command)
 {
     string Description;
     List<string> Params;
     GetTypeHelp(Command, out Description, out Params);
     LogHelp(Command, Description, Params);
 }
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:11,代码来源:HelpUtils.cs

示例14: GetSchema

        public override List<ExplorerItem> GetSchema(IConnectionInfo connectionInfo, Type customType)
        {
            var indexDirectory = connectionInfo.DriverData.FromXElement<LuceneDriverData>().IndexDirectory;

            //TODO: Fields with configured delimiters should show up as a tree
            //TODO: Show Numeric and String fields with their types
            //TODO: If the directory selected contains sub-directories, maybe we should show them all...

            using (var directory = FSDirectory.Open(new DirectoryInfo(indexDirectory)))
            using (var indexReader = IndexReader.Open(directory, true))
            {
                return indexReader
                    .GetFieldNames(IndexReader.FieldOption.ALL)
                    .Select(fieldName =>
                    {
                        //var field = //TODO: Get the first document with this field and get its types.
                        return new ExplorerItem(fieldName, ExplorerItemKind.QueryableObject, ExplorerIcon.Column)
                        {
                            IsEnumerable = false,       //TODO: Should be true when its a multi-field
                            ToolTipText = "Cool tip"
                        };
                    })
                    .ToList();
            }
        }
开发者ID:ChristopherHaws,项目名称:LinqPad-Lucene-Driver,代码行数:25,代码来源:LuceneIndexDriver.cs

示例15: Deserialize

        // public methods
        /// <summary>
        /// Deserializes an object from a BsonReader.
        /// </summary>
        /// <param name="bsonReader">The BsonReader.</param>
        /// <param name="nominalType">The nominal type of the object.</param>
        /// <param name="actualType">The actual type of the object.</param>
        /// <param name="options">The serialization options.</param>
        /// <returns>An object.</returns>
        public override object Deserialize(
            BsonReader bsonReader,
            Type nominalType,
            Type actualType,
            IBsonSerializationOptions options)
        {
            VerifyTypes(nominalType, actualType, typeof(double));
            var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);

            var bsonType = bsonReader.GetCurrentBsonType();
            switch (bsonType)
            {
                case BsonType.Double:
                    return bsonReader.ReadDouble();
                case BsonType.Int32:
                    return representationSerializationOptions.ToDouble(bsonReader.ReadInt32());
                case BsonType.Int64:
                    return representationSerializationOptions.ToDouble(bsonReader.ReadInt64());
                case BsonType.String:
                    return XmlConvert.ToDouble(bsonReader.ReadString());
                default:
                    var message = string.Format("Cannot deserialize Double from BsonType {0}.", bsonType);
                    throw new FileFormatException(message);
            }
        }
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:34,代码来源:DoubleSerializer.cs


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