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


C# Component.GetType方法代码示例

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


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

示例1: ApplyValue

 /// <summary>
 /// Applies the value resulting from this property onto the given Component instance.
 /// </summary>
 public void ApplyValue(Component Component)
 {
     //Component Component = Entity.Components[ComponentName];
     PropertyInfo Property = Component.GetType().GetProperty(PropertyName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
     if(Property == null)
         throw new KeyNotFoundException("Unable to find a property named '" + PropertyName + "' on Component of type '" + Component.GetType().Name + "'.");
     object Value = Argument.GetValue(Component, Property);
     if(!Property.PropertyType.IsAssignableFrom(Value.GetType()))
         Value = Convert.ChangeType(Value, Property.PropertyType);
     Property.SetValue(Component, Value, null);
 }
开发者ID:Octanum,项目名称:Corvus,代码行数:14,代码来源:ComponentProperty.cs

示例2: ApplyResources

 protected override void ApplyResources(Component component, string componentName, CultureInfo culture)
 {
     foreach (PropertyDescriptor descriptor in this.GetLocalizableStringProperties(component.GetType()))
     {
         string str = this.GetString(string.Format("{0}.{1}", componentName, descriptor.Name), culture);
         if (str != null)
         {
             descriptor.SetValue(component, str);
         }
     }
     ComboBox box = component as ComboBox;
     if ((box != null) && (box.DataSource == null))
     {
         string item = this.GetString(string.Format("{0}.Items", box.Name), culture);
         if (item != null)
         {
             int selectedIndex = box.SelectedIndex;
             box.BeginUpdate();
             box.Items.Clear();
             int num2 = 1;
             while (item != null)
             {
                 box.Items.Add(item);
                 item = this.GetString(string.Format("{0}.Items{1}", box.Name, num2++), culture);
             }
             if (selectedIndex < box.Items.Count)
             {
                 box.SelectedIndex = selectedIndex;
             }
             box.EndUpdate();
         }
     }
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:33,代码来源:BasicFormStringLocalizer.cs

示例3: Construct_from_component

 public void Construct_from_component()
 {
     Dispose();
     using (var component = new Component())
     {
         DisplaySettings = new DisplaySettings(component);
         Assert.AreEqual(component.GetType().FullName, DisplaySettings.Name);
         Assert.IsFalse(DisplaySettings.IsDisposed);
     }
     Assert.IsTrue(DisplaySettings.IsDisposed);
 }
开发者ID:jjeffery,项目名称:Cesto,代码行数:11,代码来源:DisplaySettingsTests.cs

示例4: EventSuppressor

        public EventSuppressor(Component source)
        {
            if (source == null)
                throw new ArgumentNullException("control", "An instance of a control must be provided.");

            _source = source;
            _sourceType = _source.GetType();
            _sourceEventsInfo = _sourceType.GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic);
            _sourceEventHandlerList = (EventHandlerList)_sourceEventsInfo.GetValue(_source, null);
            _eventHandlerListType = _sourceEventHandlerList.GetType();
            _headFI = _eventHandlerListType.GetField("head", BindingFlags.Instance | BindingFlags.NonPublic);
        }
开发者ID:urmilaNominate,项目名称:mERP-framework,代码行数:12,代码来源:EventSuppressor.cs

示例5: AddCommandBinding

        public CommandAdapter AddCommandBinding(Component component, ICommand command, Func<object> commandParameterCallback)
        {
            if (component == null) { throw new ArgumentNullException("component"); }
            if (command == null) { throw new ArgumentNullException("command"); }
            if (commandParameterCallback == null) { throw new ArgumentNullException("commandParameterCallback"); }

            foreach (CommandBindingFactory factory in factories.Reverse())
            {
                if (factory.CanCreate(component))
                {
                    bindings.Add(factory.Create(component, command, commandParameterCallback));
                    return this;
                }
            }

            throw new NotSupportedException("This component type '" + component.GetType().Name + "' is not supported. Please provide an adapter for this component.");
        }
开发者ID:keremkusmezer,项目名称:baldursgatepartygold,代码行数:17,代码来源:CommandAdapter.cs

示例6: RemoveHandler

        protected virtual void RemoveHandler(Component extendee)
        {
            // verifico se extendee possiede l'evento click
            EventInfo clickEvent = extendee.GetType().GetEvent("Click");
            if (clickEvent != null)
            {
                clickEvent.RemoveEventHandler(extendee, clickEventHandler);
            }

            // verifico se extendee possiede l'evento CheckStateChanged
            EventInfo checkStateChangedEvent = extendee.GetType().GetEvent("CheckStateChanged");
            if (checkStateChangedEvent != null)
            {
                checkStateChangedEvent.RemoveEventHandler(extendee, checkStateChangedEventHandler);
            }

            // Casi particolari
            // verifico se extendee è un ToolbarButton
            ToolBarButton button = extendee as ToolBarButton;
            if (button != null)
            {
                button.Parent.ButtonClick -= new ToolBarButtonClickEventHandler(toolbar_ButtonClick);
            }
        }
开发者ID:divyang4481,项目名称:lextudio,代码行数:24,代码来源:Action.cs

示例7: updateProperty

 private void updateProperty(Component target, string propertyName, object value)
 {
     WorkingState = ActionWorkingState.Driving;
     try
     {
         if (ActionList != null)
         {
             if (!SpecialUpdateProperty(target, propertyName, value))
                 ActionList.TypesDescription[target.GetType()].SetValue(
                     propertyName, target, value);
         }
     }
     finally
     {
         WorkingState = ActionWorkingState.Listening;
     }            
 }
开发者ID:divyang4481,项目名称:lextudio,代码行数:17,代码来源:Action.cs

示例8: GetProvider

		public static IRawElementProviderFragment GetProvider (Component component,
		                                                       bool initialize,
		                                                       bool forceInitializeChildren)
		{
			if (component == null)
				//FIXME: we should throw new ArgumentNullException ("component");
				return null;

			// First check if we've seen this component before
			IRawElementProviderFragment provider = FindProvider (component);
			if (provider != null)
				return provider;

			// Send a WndProc message to see if the control
			// implements it's own provider.
			if (component is SWF.Control
			    // Sending WndProc to a form is broken for some reason
			    && !(component is SWF.Form)) {

				SWF.Control control = component as SWF.Control;
				IRawElementProviderSimple simpleProvider;
				IntPtr result;

				result = SWF.NativeWindow.WndProc (control.Handle, SWF.Msg.WM_GETOBJECT,
				                                   IntPtr.Zero,
				                                   new IntPtr (AutomationInteropProvider.RootObjectId));
				if (result != IntPtr.Zero) {
					simpleProvider = AutomationInteropProvider
						.RetrieveAndDeleteProvider (result);

					provider = simpleProvider as IRawElementProviderFragment;
					if (provider == null)
						provider = new FragmentControlProviderWrapper (component, simpleProvider);
				}
			}

			ComponentProviderMapperHandler handler = null;
			Type providerType = null;

			if (provider == null) {
				Type typeIter = component.GetType ();

				// Chain up the type hierarchy until we find
				// either a type or handler for mapping, or we
				// hit Control or Component.
				do {
					// First see if there's a mapping handler
					if (componentProviderMappers.TryGetValue (typeIter,
					                                          out handler))
						break;

					// Next, see if we have a type mapping
					if (providerComponentMap.TryGetValue (typeIter,
					                                      out providerType))
						break;

					typeIter = typeIter.BaseType;
				} while (typeIter != null
				         && typeIter != typeof (System.ComponentModel.Component)
				         && typeIter != typeof (SWF.Control));
			}

			if (handler != null) {
				provider = handler (component);
			}

			// Create the provider if we found a mapping type
			if (provider == null) {
				// We meet a unknown custom control type,
				// then we count it as a Pane
				if (providerType == null) {
					var dialog = component as SWF.CommonDialog;
					if (dialog != null)
						return GetProvider (dialog.form,
							initialize, forceInitializeChildren);
					providerType = typeof (PaneProvider);
				}
				try {
					provider = (FragmentControlProvider)
						Activator.CreateInstance (providerType,
									  new object [] { component });
				} catch (MissingMethodException) {
					Log.Error (
						"Provider {0} does not have a valid single parameter constructor to handle {1}.",
						providerType, component.GetType ()
					);
					return null;
				}
			}

			if (provider != null) {
				// TODO: Abstract this out?
				if (component is SWF.Form) {
					formProviders.Add ((IRawElementProviderFragmentRoot) provider);
				}

				// TODO: Make tracking in dictionary optional
				componentProviders [component] = provider;
				if (provider is FragmentControlProvider) {
					FragmentControlProvider frag = (FragmentControlProvider) provider;
//.........这里部分代码省略.........
开发者ID:mono,项目名称:uia2atk,代码行数:101,代码来源:ProviderFactory.cs

示例9: UpdateText

        private void UpdateText(Component c, string text)
        {
            try
            {
                if (null != c)
                {
                    PropertyInfo pi = c.GetType().GetProperty("Text");

                    if (null != pi)
                    {
                        pi.SetValue(c, text, null);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
开发者ID:drme,项目名称:disks-db,代码行数:18,代码来源:FormMain.cs

示例10: Remove

        // This removes the specified control from this UICommand.
        internal void Remove(Component component)
        {
            // We must be able to handle any object that UICommandProvider.CanExtend returns true for.
            _components.Remove(component);

            if (component is Control) ((Control)component).Click -= ClickForwarderDelegate;
            else if (component is ToolStripItem) ((ToolStripItem)component).Click -= ClickForwarderDelegate;
            else throw new ApplicationException("Object has unexpected type " + component.GetType());
        }
开发者ID:Stoner19,项目名称:Memory-Lifter,代码行数:10,代码来源:UICommand.cs

示例11: SetAction

        public void SetAction(Component extendee, Action action)
        {
            if (!initializing)
            {
                if (extendee == null)
                    throw new ArgumentNullException("extendee");
                if (action != null && action.ActionList != this)
                    throw new ArgumentException("The Action you selected is owned by another ActionList");
            }

            /* Se extendee appartiene gi?alla collection, rimuovo l'handler
             * sul suo evento Click e lo rimuovo dai component associati alla
             * collection */
            if (targets.ContainsKey(extendee))
            {
                targets[extendee].InternalRemoveTarget(extendee);
                targets.Remove(extendee);
            }

            /* Aggiungo extendee alla collection */
            if (action != null)
            {
                // eventualmente aggiungo le informazioni sul tipo
                if (!typesDescription.ContainsKey(extendee.GetType()))
                {
                    typesDescription.Add(extendee.GetType(),
                        new ActionTargetDescriptionInfo(extendee.GetType()));
                }

                targets.Add(extendee, action);
                action.InternalAddTarget(extendee);
            }            
        }        
开发者ID:divyang4481,项目名称:lextudio,代码行数:33,代码来源:ActionList.cs

示例12: ReflectComponent

			static void ReflectComponent( Component co ) {
				Type t = co.GetType();

      
      //FieldInfo [] fields = t.GetFields(BindingFlags.GetField | BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static );
				FieldInfo [] fields = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
				foreach( FieldInfo fld in fields ) {
					object o = fld.GetValue(co);
					if( null != o ) {
						Type tt = o.GetType();
						if( Component.CheckType(tt) ) {
							Console.WriteLine( "Field {0} [{1}] value {2}", fld.Name, tt, o );
						}
					}
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:16,代码来源:Component.cs

示例13: FindTemplateProperty

        private static PropertyInfo FindTemplateProperty(Component Template, string Name)
        {
            Name = Name.ToUpper();

            foreach (PropertyInfo i in Template.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
            {
                // Check all the parameter aliases for this parameter.
                foreach (ParameterAlias j in i.CustomAttributes<ParameterAlias>())
                    if (Name == j.Alias)
                        return i;

                // Check the name itself.
                if (Name == i.Name.ToUpper())
                    return i;
            }
            return null;
        }
开发者ID:alexbv16,项目名称:LiveSPICE,代码行数:17,代码来源:Model.cs

示例14: GetNameFromComponent

 private static string GetNameFromComponent(Component component)
 {
     Verify.ArgumentNotNull(component, "component");
     return component.GetType().FullName;
 }
开发者ID:jjeffery,项目名称:Cesto,代码行数:5,代码来源:DisplaySettings.cs

示例15: AddCommandBinding

        /// <summary>
        /// コマンドのバインディングを追加します。
        /// </summary>
        public static CommandBindingBase AddCommandBinding(Component component,
                                                           ICommand command,
                                                           Func<object> commandParameterCallback)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            if (commandParameterCallback == null)
            {
                throw new ArgumentNullException("commandParameterCallback");
            }

            foreach (var factory in factories)
            {
                if (factory.CanCreate(component))
                {
                    var binding = factory.Create(component, command,
                                                 commandParameterCallback);

                    bindings.Add(binding);
                    return binding;
                }
            }

            throw new NotSupportedException(
                string.Format(
                    "コンポ―ネント'{0}'はコマンドバインディングに対応していません。",
                    component.GetType().Name));
        }
开发者ID:leontius,项目名称:Ragnarok,代码行数:39,代码来源:CommandManager.cs


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