/// <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> /// Deserializes a call expression where the target is an array expression. /// /// System.Array[String](["a", "b"]) /// </summary> object DeserializeCreateArrayExpression(CallExpression callExpression, IndexExpression target) { ListExpression list = callExpression.Args[0].Expression as ListExpression; Type arrayType = GetType(target.Index as MemberExpression); Array array = Array.CreateInstance(arrayType, list.Items.Count); for (int i = 0; i < list.Items.Count; ++i) { Expression listItemExpression = list.Items[i]; ConstantExpression constantExpression = listItemExpression as ConstantExpression; MemberExpression memberExpression = listItemExpression as MemberExpression; NameExpression nameExpression = listItemExpression as NameExpression; CallExpression listItemCallExpression = listItemExpression as CallExpression; if (constantExpression != null) { array.SetValue(constantExpression.Value, i); } else if (memberExpression != null) { string name = PythonControlFieldExpression.GetVariableName(memberExpression.Name); array.SetValue(componentCreator.GetComponent(name), i); } else if (nameExpression != null) { array.SetValue(componentCreator.GetInstance(nameExpression.Name), i); } else if (listItemCallExpression != null) { Type arrayInstanceType = GetType(listItemCallExpression.Target as MemberExpression); object instance = componentCreator.CreateInstance(arrayInstanceType, GetArguments(listItemCallExpression), null, false); array.SetValue(instance, i); } } return(array); }
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> /// Gets the object that the field expression variable refers to. /// </summary> /// <remarks> /// This method will also check form's base class for any inherited objects that match /// the object being referenced. /// </remarks> public object GetObject(IComponentCreator componentCreator) { if (variableName.Length > 0) { object component = componentCreator.GetComponent(variableName); if (component != null) { return(component); } return(GetInheritedObject(variableName, componentCreator.RootComponent)); } return(componentCreator.RootComponent); }
/// <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> /// Gets the object that the field expression variable refers to. /// </summary> /// <remarks> /// This method will also check form's base class for any inherited objects that match /// the object being referenced. /// </remarks> public object GetObject(IComponentCreator componentCreator) { if (variableName.Length > 0) { object component = componentCreator.GetComponent(variableName); if (component != null) { return component; } return GetInheritedObject(variableName, componentCreator.RootComponent); } return componentCreator.RootComponent; }