private void ProcessWidgets_Recrusive(List <UEditorWidgetBase> CurrentContainer) { List <UEditorWidgetBase> __nestedWidgets = new List <UEditorWidgetBase>(); foreach (var item in CurrentContainer) { UEditorWidgetBase __castWidget = (UEditorWidgetBase)item; UWidgetCodeGen __cGen = new UWidgetCodeGen(__castWidget); _widgetDeclarations.Add(__cGen.WidgetDeclaration); _widgetPropertySetters.Add("\t//Property setters for ->" + item.Name); foreach (var setter in __cGen.PropertySetters) { _widgetPropertySetters.Add("\t" + setter); } _widgetPropertySetters.Add("\t" + __cGen.WidgetParent); _widgetPropertySetters.Add(""); _widgetPropertySetters.Add(""); if (item.GetType().IsSubclassOf(typeof(UEditorPanelBase))) { UEditorPanelBase __castPanel = (UEditorPanelBase)item; __nestedWidgets.AddRange(__castPanel.Children.Cast <UEditorWidgetBase>().ToList()); } } if (__nestedWidgets.Count > 0) { ProcessWidgets_Recrusive(__nestedWidgets); } }
private void ProcessMember(MemberInfo WidgetMember) { object __propObject; string __newPropSetter; //Find the attribute tag UWidgetPropertyAttribute __propertyAttribute = null;; object[] __attributes = WidgetMember.GetCustomAttributes(typeof(UWidgetPropertyAttribute), false); if (__attributes.Length == 1) { __propertyAttribute = (UWidgetPropertyAttribute)__attributes[0]; } if (__propertyAttribute == null) { throw new Exception("Failed to find property attribute for ->" + this.Widget.Name + ":" + WidgetMember.Name); } //Get a clear reference to the reflected property switch (WidgetMember.MemberType) { case MemberTypes.Field: __propObject = ((FieldInfo)WidgetMember).GetValue(this.Widget); break; case MemberTypes.Property: __propObject = ((PropertyInfo)WidgetMember).GetValue(this.Widget, null); break; default: throw new Exception("UWidgetCodeGen failed to convert MemberInfo to pharseable input"); } //Bail out if we got nothing back if (__propObject == null) { throw new Exception("UWidgetCodeGen failed to convert MemberInfo to pharseable input"); } //The the property is a widget then we need to nest the call. if (__propObject.GetType().IsSubclassOf(typeof(UEditorWidgetBase))) { UWidgetCodeGen __cgSubGen = new UWidgetCodeGen((UEditorWidgetBase)__propObject, false); __cgSubGen.PropertyRoot = this.PropertyRoot + _widget.Name + "."; __cgSubGen.PharseWidget(); foreach (var item in __cgSubGen.PropertySetters) { _propertySetters.Add(item); } return; } //If the Property has a code gen class assigned, then use that. if (__propertyAttribute.PropCodeGen != null) { ICodeGenerator __codeGenerator; try { __codeGenerator = (ICodeGenerator)Activator.CreateInstance(__propertyAttribute.PropCodeGen); } catch { throw new Exception("Failed to create code gen class for " + WidgetMember.Name + "\r\nDoes the specified code generator implement the ICodeGenerator inferface?"); } List <string> __generatedPropSetters = __codeGenerator.CGenPropertySetters(this.PropertyRoot + _widget.Name + "." + WidgetMember.Name, __propObject); foreach (var item in __generatedPropSetters) { _propertySetters.Add(item); } return; } //Generic property construction code __newPropSetter = this.PropertyRoot + this.WidgetName + "." + WidgetMember.Name + " = "; string __propValue = GenericPharseValue(__propObject); __newPropSetter += __propValue; __newPropSetter += ";"; _propertySetters.Add(__newPropSetter); }