protected virtual void CloneTree(openehr.openehr.am.archetype.constraint_model.C_COMPLEX_OBJECT adlComplexObject, C_COMPLEX_OBJECT parentComplexObject, int depth) { CloneConstraintVisitor nodeVisitor = NewInstance(); openehr.openehr.am.archetype.constraint_model.C_ATTRIBUTE adlAttribute; parentComplexObject.attributes = new C_ATTRIBUTE[adlComplexObject.attributes().count()]; for (int i = 1; i <= adlComplexObject.attributes().count(); i++) { adlAttribute = adlComplexObject.attributes().i_th(i) as openehr.openehr.am.archetype.constraint_model.C_ATTRIBUTE; C_ATTRIBUTE attributeNode = nodeVisitor.CloneAttribute(adlAttribute); attributeNode.children = new C_OBJECT[adlAttribute.children().count()]; parentComplexObject.attributes[i - 1] = attributeNode; for (int j = 1; j <= adlAttribute.children().count(); j++) { openehr.openehr.am.archetype.constraint_model.C_OBJECT child = adlAttribute.children().i_th(j) as openehr.openehr.am.archetype.constraint_model.C_OBJECT; object childNode = nodeVisitor.Visit(child, depth); attributeNode.children[j - 1] = childNode as C_OBJECT; if (child is openehr.openehr.am.archetype.constraint_model.Impl.C_COMPLEX_OBJECT) { CloneTree(child as openehr.openehr.am.archetype.constraint_model.C_COMPLEX_OBJECT, childNode as C_COMPLEX_OBJECT, ++depth); } } } }
protected virtual void CloneC_Object(C_OBJECT cloneObject, openehr.openehr.am.archetype.constraint_model.C_OBJECT o) { if (!o.node_id().to_cil().StartsWith("unknown")) //hack for xml conversion { cloneObject.node_id = o.node_id().to_cil(); } else { cloneObject.node_id = ""; } cloneObject.rm_type_name = o.rm_type_name().to_cil(); cloneObject.occurrences = CloneIntervalOfInteger(o.occurrences()); }
protected virtual object Visit(openehr.openehr.am.archetype.constraint_model.C_OBJECT o, int depth) { if (o == null) { throw new ArgumentNullException("CObject parameter must not be null. depth = " + depth); } try { System.Reflection.MethodInfo method = this.GetType().GetMethod("Visit", System.Reflection.BindingFlags.ExactBinding | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, Type.DefaultBinder, new Type[] { o.GetType(), depth.GetType() }, new System.Reflection.ParameterModifier[0]); if (method != null) { // Avoid StackOverflow exceptions by executing only if the method and visitable // are different from the last parameters used. if (method != lastMethod || o != lastObject) { lastMethod = method; lastObject = o; object itemObject = method.Invoke(this, new object[] { o, depth }); return(itemObject); } } } catch (System.Reflection.TargetInvocationException ex) { if (ex.InnerException != null) { if (ex.InnerException.InnerException != null) { //System.Diagnostics.Debug.WriteLine(ex.InnerException.InnerException.ToString() + Environment.NewLine); //throw ex.InnerException; throw new InvalidOperationException("Visit Exeception. depth = " + depth, ex.InnerException.InnerException); } System.Diagnostics.Debug.WriteLine(ex.InnerException.ToString() + Environment.NewLine); //throw ex.InnerException; throw new InvalidOperationException("Visit Exeception", ex.InnerException); } System.Diagnostics.Debug.WriteLine(ex.ToString() + Environment.NewLine + depth); //throw; throw new InvalidOperationException("Visit Exeception", ex); } catch (InvalidOperationException ex) { if (ex.InnerException != null) { System.Diagnostics.Debug.WriteLine(ex.InnerException.ToString() + Environment.NewLine); //throw ex.InnerException; throw new InvalidOperationException("Visit Exeception", ex.InnerException); } System.Diagnostics.Debug.WriteLine(ex.ToString() + Environment.NewLine + depth); //throw; throw new InvalidOperationException("Visit Exeception", ex); } throw new NotImplementedException("The Visitor method 'Visit' with parameter type '" + o.GetType().ToString() + "' is not implemented."); }
protected virtual object Visit(openehr.openehr.am.archetype.constraint_model.C_OBJECT o, int depth) { if (o == null) throw new ArgumentNullException("CObject parameter must not be null. depth = " + depth); try { System.Reflection.MethodInfo method = this.GetType().GetMethod("Visit", System.Reflection.BindingFlags.ExactBinding | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, Type.DefaultBinder, new Type[] { o.GetType(), depth.GetType() }, new System.Reflection.ParameterModifier[0]); if (method != null) // Avoid StackOverflow exceptions by executing only if the method and visitable // are different from the last parameters used. if (method != lastMethod || o != lastObject) { lastMethod = method; lastObject = o; object itemObject = method.Invoke(this, new object[] { o, depth }); return itemObject; } } catch (System.Reflection.TargetInvocationException ex) { if (ex.InnerException != null) { if (ex.InnerException.InnerException != null) { //System.Diagnostics.Debug.WriteLine(ex.InnerException.InnerException.ToString() + Environment.NewLine); //throw ex.InnerException; throw new InvalidOperationException("Visit Exeception. depth = " + depth, ex.InnerException.InnerException); } System.Diagnostics.Debug.WriteLine(ex.InnerException.ToString() + Environment.NewLine); //throw ex.InnerException; throw new InvalidOperationException("Visit Exeception", ex.InnerException); } System.Diagnostics.Debug.WriteLine(ex.ToString() + Environment.NewLine + depth); //throw; throw new InvalidOperationException("Visit Exeception", ex); } catch (InvalidOperationException ex) { if (ex.InnerException != null) { System.Diagnostics.Debug.WriteLine(ex.InnerException.ToString() + Environment.NewLine); //throw ex.InnerException; throw new InvalidOperationException("Visit Exeception", ex.InnerException); } System.Diagnostics.Debug.WriteLine(ex.ToString() + Environment.NewLine + depth); //throw; throw new InvalidOperationException("Visit Exeception", ex); } throw new NotImplementedException("The Visitor method 'Visit' with parameter type '" + o.GetType().ToString() + "' is not implemented."); }