public static ObjectWrapper ReadObject(ObjectReader reader, XmlElement elem) { string className = elem.GetAttribute("class"); ClassDescriptor klass; if (reader.Format == FileFormat.Native) { klass = Registry.LookupClassByName(className); } else { klass = Registry.LookupClassByCName(className); } if (klass == null) { ErrorWidget we = new ErrorWidget(className, elem.GetAttribute("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper)Create(reader.Project, we); wrap.Read(reader, elem); return(wrap); } if (!klass.SupportsGtkVersion(reader.Project.TargetGtkVersion)) { ErrorWidget we = new ErrorWidget(className, klass.TargetGtkVersion, reader.Project.TargetGtkVersion, elem.GetAttribute("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper)Create(reader.Project, we); wrap.Read(reader, elem); return(wrap); } ObjectWrapper wrapper = klass.CreateWrapper(); wrapper.classDescriptor = klass; wrapper.proj = reader.Project; return(ReadObject(reader, elem, wrapper)); }
public override XmlElement Write(ObjectWriter writer) { if (writer.Format != this.format) { ErrorWidget ew = (ErrorWidget)Wrapped; XmlElement elem = writer.XmlDocument.CreateElement("widget"); elem.SetAttribute("class", "Gtk.Label"); elem.SetAttribute("id", Wrapped.Name); XmlElement ce = writer.XmlDocument.CreateElement("property"); string msg; if (ew.Exception != null) { msg = "Invalid widget"; } else { msg = "Unknown widget: " + ew.ClassName; } ce.SetAttribute("name", "LabelProp"); ce.InnerText = msg; elem.AppendChild(ce); return(elem); } else { return((XmlElement)writer.XmlDocument.ImportNode(elementData, true)); } }
public static ObjectWrapper ReadObject(ObjectReader reader, XmlElement elem) { string className = elem.GetAttribute("class"); ClassDescriptor klass; if (reader.Format == FileFormat.Native) { klass = Registry.LookupClassByName(className); } else { klass = Registry.LookupClassByCName(className); } if (klass == null) { ErrorWidget we = new ErrorWidget(className, elem.GetAttribute("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper)Create(reader.Project, we); wrap.Read(reader, elem); return(wrap); } if (!klass.SupportsGtkVersion(reader.Project.TargetGtkVersion)) { ErrorWidget we = new ErrorWidget(className, klass.TargetGtkVersion, reader.Project.TargetGtkVersion, elem.GetAttribute("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper)Create(reader.Project, we); wrap.Read(reader, elem); return(wrap); } ObjectWrapper wrapper = klass.CreateWrapper(); wrapper.classDescriptor = klass; wrapper.proj = reader.Project; try { wrapper.OnBeginRead(reader.Format); wrapper.Read(reader, elem); } catch (Exception ex) { Console.WriteLine(ex); ErrorWidget we = new ErrorWidget(ex, elem.GetAttribute("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper)Create(reader.Project, we); wrap.Read(reader, elem); return(wrap); } finally { wrapper.OnEndRead(reader.Format); } return(wrapper); }
public static ObjectWrapper ReadObject(ObjectReader reader, XmlElement elem, ObjectWrapper wrapper) { try { wrapper.OnBeginRead(reader.Format); wrapper.Read(reader, elem); return(wrapper); } catch (Exception ex) { Console.WriteLine(ex); ErrorWidget we = new ErrorWidget(ex, elem.GetAttribute("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper)Create(reader.Project, we); wrap.Read(reader, elem); return(wrap); } finally { wrapper.OnEndRead(reader.Format); } }
internal protected override CodeExpression GenerateObjectCreation(GeneratorContext ctx) { ErrorWidget ew = (ErrorWidget)Wrapped; string msg; if (ew.Exception != null) { msg = Project.FolderName + ": Could not generate code for an invalid widget. The widget failed to load: " + ew.Exception.Message + ". The generated code may be invalid."; } else { msg = Project.FolderName + ": Could not generate code for widgets of type: " + ew.ClassName + ". The widget could not be found in any referenced library. The generated code may be invalid."; } if (ctx.Options.FailForUnknownWidgets) { throw new InvalidOperationException(msg); } else { ctx.ReportWarning(msg); return(new CodePrimitiveExpression(null)); } }
public static ObjectWrapper ReadObject (ObjectReader reader, XmlElement elem, ObjectWrapper wrapper) { try { wrapper.OnBeginRead (reader.Format); wrapper.Read (reader, elem); return wrapper; } catch (Exception ex) { Console.WriteLine (ex); ErrorWidget we = new ErrorWidget (ex, elem.GetAttribute ("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we); wrap.Read (reader, elem); return wrap; } finally { wrapper.OnEndRead (reader.Format); } }
public static ObjectWrapper ReadObject (ObjectReader reader, XmlElement elem) { string className = elem.GetAttribute ("class"); ClassDescriptor klass; if (reader.Format == FileFormat.Native) klass = Registry.LookupClassByName (className); else klass = Registry.LookupClassByCName (className); if (klass == null) { ErrorWidget we = new ErrorWidget (className, elem.GetAttribute ("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we); wrap.Read (reader, elem); return wrap; } if (!klass.SupportsGtkVersion (reader.Project.TargetGtkVersion)) { ErrorWidget we = new ErrorWidget (className, klass.TargetGtkVersion, reader.Project.TargetGtkVersion, elem.GetAttribute ("id")); ErrorWidgetWrapper wrap = (ErrorWidgetWrapper) Create (reader.Project, we); wrap.Read (reader, elem); return wrap; } ObjectWrapper wrapper = klass.CreateWrapper (); wrapper.classDescriptor = klass; wrapper.proj = reader.Project; return ReadObject (reader, elem, wrapper); }