/// <summary> Attempts to create an instance of the given class and return /// it as a Structure. /// </summary> /// <param name="c">the Structure implementing class /// </param> /// <param name="name">an optional name of the structure (used by Generic structures; may be null) /// </param> private Structure tryToInstantiateStructure(System.Type c, System.String name) { Structure s = null; try { System.Object o = null; if (typeof(GenericSegment).IsAssignableFrom(c)) { s = new GenericSegment(this, name); } else if (typeof(GenericGroup).IsAssignableFrom(c)) { s = new GenericGroup(this, name, myFactory); } else { //first try to instantiate using contructor w/ Message arg ... try { System.Type[] argClasses = new System.Type[] { typeof(Group), typeof(ModelClassFactory) }; System.Object[] argObjects = new System.Object[] { this, myFactory }; System.Reflection.ConstructorInfo con = c.GetConstructor(argClasses); o = con.Invoke(argObjects); } catch (System.MethodAccessException) { //UPGRADE_TODO: Method 'java.lang.Class.newInstance' was converted to 'System.Activator.CreateInstance' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangClassnewInstance'" o = System.Activator.CreateInstance(c); } if (!(o is Structure)) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" throw new HL7Exception("Class " + c.FullName + " does not implement " + "ca.on.uhn.hl7.message.Structure", HL7Exception.APPLICATION_INTERNAL_ERROR); } s = (Structure)o; } } catch (System.Exception e) { if (e is HL7Exception) { throw (HL7Exception)e; } else { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" throw new HL7Exception("Can't instantiate class " + c.FullName, HL7Exception.APPLICATION_INTERNAL_ERROR, e); } } return(s); }
/// <summary> Attempts to create an instance of the given class and return /// it as a Structure. /// </summary> /// <param name="c">the Structure implementing class /// </param> /// <param name="name">an optional name of the structure (used by Generic structures; may be null) /// </param> private Structure tryToInstantiateStructure(System.Type c, System.String name) { Structure s = null; try { System.Object o = null; if (typeof(GenericSegment).IsAssignableFrom(c)) { s = new GenericSegment(this, name); } else if (typeof(GenericGroup).IsAssignableFrom(c)) { s = new GenericGroup(this, name, myFactory); } else { //first try to instantiate using contructor w/ Message arg ... try { System.Type[] argClasses = new System.Type[]{typeof(Group), typeof(ModelClassFactory)}; System.Object[] argObjects = new System.Object[]{this, myFactory}; System.Reflection.ConstructorInfo con = c.GetConstructor(argClasses); o = con.Invoke(argObjects); } catch (System.MethodAccessException) { //UPGRADE_TODO: Method 'java.lang.Class.newInstance' was converted to 'System.Activator.CreateInstance' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangClassnewInstance'" o = System.Activator.CreateInstance(c); } if (!(o is Structure)) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" throw new HL7Exception("Class " + c.FullName + " does not implement " + "ca.on.uhn.hl7.message.Structure", HL7Exception.APPLICATION_INTERNAL_ERROR); } s = (Structure) o; } } catch (System.Exception e) { if (e is HL7Exception) { throw (HL7Exception) e; } else { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" throw new HL7Exception("Can't instantiate class " + c.FullName, HL7Exception.APPLICATION_INTERNAL_ERROR, e); } } return s; }