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


C# Part.SearchPart方法代码示例

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


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

示例1: GetValue

		///<summary>
	   /// This is the implementation of the method specified in the IPropertySetter Interface
		/// For now it is implemented in the rendering engine itself, but when it becomes
		/// too complex the IPropertySetter implementation will be isolated from
		/// this rendering class.
		///</summary>
		///<remarks>
		/// If part==null, the property will be retrieved fro the first matching part
		/// found starting from the top-part in first-order.
		///</remarks>
		public System.Object GetValue(Part part, Property prop)
		{
			if(part == null)
				part = Top;
			//search for the part, and get the widget
			Part p = part.SearchPart(prop.PartName);
			string className  = Voc.MapsOnCls(p.Class);
			Type classType = GuiAssembly.GetType(className);
			string getter = Voc.GetPropertyGetter(prop.Name, p.Class);

			System.Object targetObject = p.UiObject;
			PropertyInfo pInfo = null;
			int j = getter.IndexOf('.');
			while(j!=-1)
			{
				String parentType = getter.Substring(0,j);
				getter=getter.Substring(j+1,getter.Length-j-1);
				pInfo = classType.GetProperty(parentType);
				classType = pInfo.PropertyType;
				targetObject = pInfo.GetValue(targetObject, null);
				j = getter.IndexOf('.');
			}
			pInfo = classType.GetProperty(getter);

			//PropertyInfo pInfo = classType.GetProperty(getter);
			try
			{
				return pInfo.GetValue(targetObject, null);
			}
				catch(Exception e)
				{
					Console.WriteLine(e);
					//TODO TODO TODO
					return null;
				}
			
		}
开发者ID:jozilla,项目名称:Uiml.net,代码行数:47,代码来源:WxRenderer.cs

示例2: GetValue

		///<summary>
		/// This is the implementation of the method specified in the IPropertySetter Interface
		/// For now it is implemented in the rendering engine itself, but when it becomes
		/// too complex the IPropertySetter implementation will be isolated from
		/// this rendering class.
		///</summary>
		///<remarks>
		/// If part==null, the property will be retrieved fro the first matching part
		/// found starting from the top-part in first-order.
		///</remarks>
		public System.Object GetValue(Part part, Property prop)
		{
			if(part == null)
				part = Top;
			//search for the part, and get the widget
			Part p = part.SearchPart(prop.PartName);
			string className  = Voc.MapsOnCls(p.Class);
			Type classType = GuiAssembly.GetType(className);
			string getter = Voc.GetPropertyGetter(prop.Name, p.Class);

			System.Object targetObject = p.UiObject;
			MemberInfo mInfo = null;
			int j = getter.IndexOf('.');
			while(j!=-1)
			{
				String parentType = getter.Substring(0,j);
				getter=getter.Substring(j+1,getter.Length-j-1);			
				mInfo = ResolveProperty(classType, parentType, out classType, ref targetObject);
				//targetObject = ((PropertyInfo)mInfo).GetValue(targetObject, null);
				j = getter.IndexOf('.');
			}
			
			try{ mInfo = ResolveProperty(classType, getter, out classType, ref targetObject); }
				catch(Exception e)
				{
					Console.WriteLine("Unable to query property \"{0}\" of part \"{1}\";", prop.Name, part.Identifier);
					Console.WriteLine("Please check your UIML document or the {0} vocabulary", Voc.VocabularyName);
				}
				
			return targetObject;
		}
开发者ID:jozilla,项目名称:Uiml.net,代码行数:41,代码来源:CompactSWFRenderer.cs

示例3: link

		///<summary>
		///Searches the parts that are used in the condition of Rule r. Events of a certain type emitted
		///by thow parts are connected to the condition of Rule r so it can be evaluated if such an event
		///occurs
		///</summary>
		///<param name="r">The rule with a condition and action</param>
		///<param name="p">A part where p itself or one of it subparts will emit events that are of interest
		///for the condition of Rule r</param>
		///<param name="gel">Links the renderer with the condition so appropriate queries can be executed by the condition.
		///It also allows the action to use the renderer afterwards to change properties in the user interface at runtime</param>

		protected void link(Rule r, Part p, CompactSWFEventLink sel)
		{
			IEnumerator eventsEnum = r.Condition.GetEvents().GetEnumerator();			
			while(eventsEnum.MoveNext())
			{
				Event e = (Event)eventsEnum.Current;
				Part thePart = p.SearchPart(e.PartName);
				if(thePart == null)
				{
					if(e.PartName == "")
						Console.WriteLine("Error in behavior specification: no part name given for {0}", e.Class);
					else
						Console.WriteLine("Error in behavior specification: {0} does not exist for event {0}", e.PartName, e.Class);
					return;
				}
				Control w = (Control)thePart.UiObject;

				string concreteEventName = m_renderer.Voc.MapsOnCls(e.Class);
				/* TODO: eventhandling is done with an ugly hack: 
				 * see the comments in the GTK# event handling classes for details.
				 */
				
					try
					{
						//Delegate handler = Delegate.CreateDelegate(typeof(EventHandler), sel, EXECUTE_METHOD);
						Delegate handler = new EventHandler(sel.Execute);
						string eventId = m_renderer.Voc.GetEventFor(thePart.Class,concreteEventName);

						//Sometimes eventId is a composed event:
						//it is an event of a property of widget w
						//so first load the property of w, and then link with
						//the event of this property
						//<property>.<event>
						
						Type theType = w.GetType();
						int j = eventId.IndexOf('.');
						System.Object targetObject = thePart.UiObject;
						while(j!=-1)
						{
							String parentType = eventId.Substring(0,j);
							eventId=eventId.Substring(j+1,eventId.Length-j-1);
							PropertyInfo pInfo = theType.GetProperty(parentType);
							theType = pInfo.PropertyType;
							targetObject = pInfo.GetValue(targetObject, null);
							j = eventId.IndexOf('.');
						}
						EventInfo eInfo = theType.GetEvent(eventId);
						//load the event info as provided by the mappings of Widget w
						eInfo.AddEventHandler(targetObject, handler);
					}
						catch(ArgumentException ae)
						{
							Console.WriteLine("Invalid argument: {0}", ae);
							//Console.WriteLine("Caused by: {0}", ae.ParamName);
						}
						catch(Exception be)
						{
							Console.WriteLine("Unexpected failure:");
							Console.WriteLine(be);
							Console.WriteLine("Please contact the uiml.net maintainer with the above output.");
						}
			}
		}
开发者ID:jozilla,项目名称:Uiml.net,代码行数:74,代码来源:CompactSWFEventLinker.cs

示例4: ApplyProperty

		///<summary>
		///This is the implementation of the method specified in the IPropertySetter Interface
		///For now it is implemented in the rendering engine itself, but when it becomes
		///too complex the IPropertySetter implementation will be isolated from
		///this rendering class.
		///</summary>
		 ///<param name="part">The part on which prop will be applied</param>
		///<param name="prop">the property that will be applied</param>
		///<remarks>
		/// If part is null, the top part will be assumed
		///</remarks>
		public void ApplyProperty(Part part, Property prop)
		{
			if(part == null)
				part = m_top;
			Part p = part.SearchPart(prop.PartName);
			/*if(prop.Lazy) // not necessary because ApplyProperty will do it anyway!
				prop.Resolve(this);*/ 
			string className  = Voc.MapsOnCls(p.Class);
			Type classType = GuiAssembly.GetType(className);
			System.Object uiObj =  p.UiObject;
			ApplyProperty(ref uiObj, prop, p, classType);	
		}
开发者ID:jozilla,项目名称:Uiml.net,代码行数:23,代码来源:Renderer.cs

示例5: LinkProperty

        private void LinkProperty(Property p, Part part)
        {
            // check if not already linked
            if (!PropertyLinked(p.Name, p.PartName))
            {
                m_propertyLinked[p.Name] = p.PartName;
                //Console.WriteLine("////////////// NOT LINKED: " + p.Name + " // " + p.PartName);

                Part thePart = part.SearchPart(p.PartName);
                if (thePart == null)
                {
                    if (p.PartName == "")
                        Console.WriteLine("Error in behavior specification: no part name given for {0}", p.PartClass);
                    else
                        Console.WriteLine("Error in behavior specification: {0} does not exist for event {0}", p.PartName, p.PartClass);
                    return;
                }
                Object w = (Object)thePart.UiObject;

                // register all events of this part => lots of overhead
                foreach (EventInfo ei in w.GetType().GetEvents())
                {
                    //Console.WriteLine("Adding event {0} to {1}", ei.Name, thePart.UiObject.GetType());
                    try
                    {
                        ei.AddEventHandler(thePart.UiObject, m_conditions.CreateHandlerWrapper(ei.Name, p.PartName));
                    }
                    catch (Exception ex) { }
                }
            }
        }
开发者ID:jozilla,项目名称:Uiml.net,代码行数:31,代码来源:ConditionLinker.cs

示例6: LinkEvent

        private void LinkEvent(Object ie, Part part)
        {
            Event e = (Event)ie;
            Part thePart = part.SearchPart(e.PartName);

            if (e.Class == "init")
            {
                // special case: init event
                string fullEventName = m_renderer.Voc.MapsOnCls(e.Class);
                string typeName = fullEventName.Substring(0, fullEventName.LastIndexOf('.'));
                string eventName = fullEventName.Substring(fullEventName.LastIndexOf('.') + 1);

                // get the top part
                Part top = m_renderer.Top;

                // get the current rendered instances
                IRenderedInstance instance = m_renderer.TopWindow;
                Type type = instance.GetType();

                /*Type type = null;
                foreach (Assembly a in ExternalLibraries.Instance.Assemblies)
                {
                    try
                    {
                        type = a.GetType(typeName, true);
                        break;
                    }
                    catch
                    {
                    }
                }

                if (type == null)
                {
                    Console.WriteLine("Error in behavior specification: init event cannot be linked. Please check your vocabulary (e.g. the maps-to attribute of the 'init' d-class).");
                    return;
                }*/

                EventInfo init = type.GetEvent(eventName);
                // now create a correct handler
                EventHandler handler = delegate(object sender, EventArgs args)
                {
                    // add the top part as the part-name
                    m_conditions.Execute(instance, args, "init", top.Identifier);
                };

                // add the handler to the event
                init.AddEventHandler(instance, handler);

                // tada!
                return;

                /*// get the connected object                
                IEnumerator enumObjects = ExternalObjects.Instance.LoadedObjects;
                while (enumObjects.MoveNext())
                {
                    object obj = enumObjects.Current;
                    Type objType = obj.GetType();
                    if (objType.Equals(type) || objType.IsSubclassOf(type))
                    {
                        // found it
                        // now create a correct handler
                        EventHandler handler = delegate(object sender, EventArgs args) 
                        { 
                            // add the top part as the part-name
                            m_conditions.Execute(obj, args, "init", "top");
                        };

                        // add the handler to the event
                        init.AddEventHandler(obj, handler);

                        // tada!
                        return;
                    }
                }*/
            }

            if (thePart == null)
            {
                if (e.PartName == "")
                    Console.WriteLine("Error in behavior specification: no part name given for {0}", e.Class);
                else
                    Console.WriteLine("Error in behavior specification: {0} does not exist for event {0}", e.PartName, e.Class);
                return;
            }
            Object w = (Object)thePart.UiObject;

            string concreteEventName = m_renderer.Voc.MapsOnCls(e.Class);
            /* TODO: eventhandling is done with an ugly hack: 
             * see the comments in the GTK# event handling classes for details.
             */

            string eventId = m_renderer.Voc.GetEventFor(thePart.Class, concreteEventName);

            EventHandler wrapper = m_conditions.CreateHandlerWrapper(ConditionManager.GetEventName(concreteEventName), e.PartName);

            //Sometimes eventId is a composed event:
            //it is an event of a property of widget w
            //so first load the property of w, and then link with
            //the event of this property
//.........这里部分代码省略.........
开发者ID:jozilla,项目名称:Uiml.net,代码行数:101,代码来源:ConditionLinker.cs


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