public static bool AddDestination(String destination, Object[] args) { if (destinations.ContainsKey(destination)) { return(true); } String thisClass = "Legacy.Text.rtf.parser.destinations." + (String)args[0]; if (thisClass.IndexOf("RtfDestinationNull") >= 0) { destinations[destination] = RtfDestinationNull.GetInstance(); return(true); } Type value = null; try { value = Type.GetType(thisClass); } catch { return(false); } if (value == null) { return(false); } RtfDestination c = null; if (destinationObjects.ContainsKey(value.Name)) { c = (RtfDestination)destinationObjects[value.Name]; } else { try { c = (RtfDestination)value.GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, new Type[0], null).Invoke(null); } catch { return(false); } } c.SetParser(rtfParser); if (value.Equals(typeof(RtfDestinationInfo))) { ((RtfDestinationInfo)c).SetElementName(destination); } if (value.Equals(typeof(RtfDestinationStylesheetTable))) { ((RtfDestinationStylesheetTable)c).SetElementName(destination); ((RtfDestinationStylesheetTable)c).SetType((String)args[1]); } destinations[destination] = c; destinationObjects[value.Name] = c; return(true); }
public static RtfDestination GetDestination(String destination) { RtfDestination dest = null; if (destinations.ContainsKey(destination)) { dest = (RtfDestination)destinations[destination]; } else { if (ignoreUnknownDestinations) { dest = (RtfDestination)destinations[DESTINATION_NULL]; } else { dest = (RtfDestination)destinations[DESTINATION_DOCUMENT]; } } dest.SetParser(RtfDestinationMgr.rtfParser); return(dest); }