/// <summary>
        /// Gets the member object that matches the field member.
        ///
        /// For a field:
        ///
        /// self._menuStrip.Items.AddRange()
        ///
        /// This method returns:
        ///
        /// Items
        /// </summary>
        public object GetMember(IComponentCreator componentCreator)
        {
            object obj = componentCreator.GetComponent(variableName);

            if (obj == null)
            {
                obj = componentCreator.GetInstance(variableName);
                if (obj == null)
                {
                    obj = GetInheritedObject(memberName, componentCreator.RootComponent);
                    if ((obj == null) && !IsSelfReference)
                    {
                        obj = componentCreator.GetInstance(fullMemberName);
                    }
                }
            }

            if (obj != null)
            {
                string[] memberNames = fullMemberName.Split('.');
                int      startIndex  = GetMembersStartIndex(memberNames);
                return(GetMember(obj, memberNames, startIndex, memberNames.Length - 1));
            }
            return(null);
        }
        public object Deserialize(InstanceVariable instance)
        {
            string name = instance.Name.Substring(1);
            object obj  = componentCreator.GetComponent(name);

            if (obj != null)
            {
                return(obj);
            }
            return(componentCreator.GetInstance(name));
        }
        /// <summary>
        /// Sets the property value that is referenced by this field expression.
        /// </summary>
        /// <remarks>
        /// This method checks that the name expression matches a created instance before
        /// converting the name expression as a string and setting the property value.
        /// </remarks>
        public bool SetPropertyValue(IComponentCreator componentCreator, NameExpression nameExpression)
        {
            object             component = GetComponent(componentCreator);
            PropertyDescriptor property  = GetProperty(component, memberName);

            if (property != null)
            {
                string name = nameExpression.Name;
                if (property.PropertyType != typeof(bool))
                {
                    if ("self" == name)
                    {
                        return(SetPropertyValue(component, memberName, componentCreator.RootComponent));
                    }
                    else
                    {
                        object instance = componentCreator.GetInstance(name);
                        if (instance != null)
                        {
                            return(SetPropertyValue(component, memberName, instance));
                        }
                    }
                }
                return(SetPropertyValue(component, memberName, name));
            }
            return(false);
        }
        /// <summary>
        /// Deserializes expressions of the form:
        ///
        /// 1) System.Windows.Forms.Cursors.AppStarting
        /// </summary>
        object Deserialize(MemberExpression memberExpression)
        {
            PythonControlFieldExpression field = PythonControlFieldExpression.Create(memberExpression);
            Type type = GetType(field);

            if (type != null)
            {
                if (type.IsEnum)
                {
                    return(Enum.Parse(type, field.MemberName));
                }
                else
                {
                    BindingFlags propertyBindingFlags = BindingFlags.Public | BindingFlags.GetField | BindingFlags.Static | BindingFlags.Instance;
                    PropertyInfo propertyInfo         = type.GetProperty(field.MemberName, propertyBindingFlags);
                    if (propertyInfo != null)
                    {
                        return(propertyInfo.GetValue(type, null));
                    }
                }
            }
            return(componentCreator.GetInstance(PythonControlFieldExpression.GetVariableName(field.MemberName)));
        }
        /// <summary>
        /// Gets the component that this field refers to.
        /// </summary>
        object GetComponent(IComponentCreator componentCreator)
        {
            object component = null;

            if (IsSelfReference)
            {
                component = GetObject(componentCreator);
                component = GetObjectForMemberName(component);
            }
            else
            {
                component = componentCreator.GetInstance(variableName);
            }
            return(component);
        }
		/// <summary>
		/// Gets the component that this field refers to.
		/// </summary>
		object GetComponent(IComponentCreator componentCreator)
		{
			object component = null;
			if (IsSelfReference) {
				component = GetObject(componentCreator);
				component = GetObjectForMemberName(component);
			} else {
				component = componentCreator.GetInstance(variableName);
			}
			return component;
		}
		/// <summary>
		/// Gets the member object that matches the field member.
		/// 
		/// For a field: 
		/// 
		/// self._menuStrip.Items.AddRange() 
		/// 
		/// This method returns:
		/// 
		/// Items
		/// </summary>
		public object GetMember(IComponentCreator componentCreator)
		{
			object obj = componentCreator.GetComponent(variableName);
			if (obj == null) {
				obj = componentCreator.GetInstance(variableName);
				if (obj == null) {
					obj = GetInheritedObject(memberName, componentCreator.RootComponent);
					if ((obj == null) && !IsSelfReference) {
						obj = componentCreator.GetInstance(fullMemberName);
					}
				}
			}
			
			if (obj != null) {
				string[] memberNames = fullMemberName.Split('.');
				int startIndex = GetMembersStartIndex(memberNames);
				return GetMember(obj, memberNames, startIndex, memberNames.Length - 1);
			}
			return null;
		}
		/// <summary>
		/// Sets the property value that is referenced by this field expression.
		/// </summary>
		/// <remarks>
		/// This method checks that the name expression matches a created instance before
		/// converting the name expression as a string and setting the property value.
		/// </remarks>
		public bool SetPropertyValue(IComponentCreator componentCreator, NameExpression nameExpression)
		{
			object component = GetComponent(componentCreator);
			PropertyDescriptor property = GetProperty(component, memberName);
			if (property != null) {
				string name = nameExpression.Name;
				if (property.PropertyType != typeof(bool)) {
					if ("self" == name) {
						return SetPropertyValue(component, memberName, componentCreator.RootComponent);
					} else {
						object instance = componentCreator.GetInstance(name);
						if (instance != null) {
							return SetPropertyValue(component, memberName, instance);
						}
					}
				}
				return SetPropertyValue(component, memberName, name);
			}
			return false;
		}