當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。