public GetProperties ( string identifier, |
||
identifier | string | |
parameters | ||
return | System.Property[] |
///<summary> /// This method is used when the classType does not contain a parameterless /// constructor. It searches for the first constructor that ``fits'' and /// according to the defined Style in uiStyle for the uiPart. ///</summary> private Window CreateWithParams(Type classType, Part uiPart, Style uiStyle, Window parent) { System.Object wxObject = null; Param[] parameters = Voc.GetParams(CONSTRUCTOR, uiPart.Class); Type[] tparamTypes = new Type[parameters.Length + 1]; tparamTypes[0] = typeof(Window); int i = 1; foreach(Param p in parameters) { int j = 0; while(tparamTypes[i] == null) { try { tparamTypes[i] = ((Assembly)ExternalLibraries.Instance.Assemblies[j++]).GetType(p.Type, true, true); } catch(TypeLoadException tle) { } catch { Console.WriteLine("Error in vocabulary: parameter {3} of type {0} for constructor of {1} is specified incorrect for part {2}", p.Type, uiPart.Class, uiPart.Identifier, p.Identifier); Environment.Exit(-1); } } i++; } ConstructorInfo construct = classType.GetConstructor(tparamTypes); if(construct == null) { Console.WriteLine("Error in vocabulary: constructor for {0} is not correctly defined.", uiPart.Class); Environment.Exit(-1); } Property[] tempProps = uiStyle.GetProperties(uiPart.Identifier, parameters); Property[] props = new Property[tempProps.Length + 1]; for(int teller=1; teller< props.Length; teller++) props[teller] = tempProps[teller-1]; if(props.Length-1 != parameters.Length) { String paramsString = ""; for(int j=0; j< parameters.Length; j++) paramsString += parameters[j].Identifier + ":" + parameters[j].Type + ", "; Console.WriteLine("Error in uiml document: required properties \"{0}\" are not available for {1} ({2})", paramsString, uiPart.Identifier, uiPart.Class); Environment.Exit(-1); return null; //useless statement } else { //if the first type is Window, insert "parent" in props[0] if( tparamTypes[0].Equals(typeof(Window))) { props[0] = new Property(); props[0].Name = "window"; props[0].PartName = "wx.Window"; props[0].PartName = "wx.Window"; props[0].Value = parent; } //create the arguments for the constructor from the property array //and pass it to the constuctor immediately try{ return (Window)construct.Invoke(Decoder.GetMultipleArgs(props,tparamTypes));} catch { //TODO: remove redundant statements!! String paramsString = ""; for(int j=0; j< parameters.Length; j++) paramsString += parameters[j].Identifier + ":" + parameters[j].Type + ", "; Console.WriteLine("Error in uiml document: required properties \"{0}\" are not available for {1} ({2})", paramsString, uiPart.Identifier, uiPart.Class); Environment.Exit(-1); return null; //useless statement } } }
///<summary> /// This method is used when the classType does not contain a parameterless /// constructor. It searches for the first constructor that ``fits'' and /// according to the defined Style in uiStyle for the uiPart. ///</summary> private System.Object CreateLayoutWithParams(Type classType, Part uiPart, Style uiStyle) { Param[] parameters = Voc.GetParams(CONSTRUCTOR, uiPart.Class); Type[] tparamTypes = new Type[parameters.Length]; int i = 0; foreach(Param p in parameters) { int j = 0; while(tparamTypes[i] == null) { try { tparamTypes[i] = ((Assembly)ExternalLibraries.Instance.Assemblies[j++]).GetType(p.Type, true, true); } catch(TypeLoadException tle) { } catch(Exception aiobe)//replace by ArrayIndexOutOfBounds { Console.WriteLine("Error in vocabulary: parameter {3} of type {0} for constructor of {1} is specified incorrect for part {2}", p.Type, uiPart.Class, uiPart.Identifier, p.Identifier); Environment.Exit(-1); } } i++; } ConstructorInfo construct = classType.GetConstructor(tparamTypes); if(construct == null) { Console.WriteLine("Error in vocabulary: constructor for {0} is not correctly defined.", uiPart.Class); Environment.Exit(-1); } Property[] props = null; if(uiStyle != null) props = uiStyle.GetProperties(uiPart.Identifier, parameters); if(props.Length != parameters.Length) { String paramsString = ""; for(int j=0; j< parameters.Length; j++) paramsString += parameters[j].Identifier + ":" + parameters[j].Type + ", "; Console.WriteLine("Error in uiml document: required properties \"{0}\" are not available for {1} ({2})", paramsString, uiPart.Identifier, uiPart.Class); Environment.Exit(-1); return null; //useless statement } else { //create the arguments for the constructor from the property array //and pass it to the constuctor immediately try{ return construct.Invoke(Decoder.GetMultipleArgs(props,tparamTypes));} catch { //TODO: remove redundant statements!! String paramsString = ""; for(int j=0; j< parameters.Length; j++) paramsString += parameters[j].Identifier + ":" + parameters[j].Type + ", "; Console.WriteLine("Error in uiml document: required properties \"{0}\" are not available for {1} ({2})", paramsString, uiPart.Identifier, uiPart.Class); Environment.Exit(-1); return null; //useless statement } } }