コード例 #1
0
ファイル: AmValidator.cs プロジェクト: nickvane/OpenEHR
 protected void Validate(CDomainType cDomainType)
 {
     this.Validate((CDefinedObject)cDomainType);
 }
コード例 #2
0
ファイル: AmXmlSerializer.cs プロジェクト: nickvane/OpenEHR
        private void WriteXml(CDomainType cDomainType)
        {
            if (cDomainType == null)
                throw new ArgumentNullException(string.Format(CommonStrings.XIsNull, cDomainType));

            const string methodName = "WriteXml";

            try
            {
                System.Reflection.MethodInfo method = this.GetType().GetMethod(methodName,
                    System.Reflection.BindingFlags.ExactBinding | System.Reflection.BindingFlags.NonPublic
                    | System.Reflection.BindingFlags.Instance, Type.DefaultBinder,
                               new Type[] { cDomainType.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 != lastMethodWriteXmlCDomainType || cDomainType != lastCDomainWrite)
                    {
                        lastMethodWriteXmlCDomainType = method;
                        lastCDomainWrite = cDomainType;

                        method.Invoke(this, new Object[] { cDomainType });

                    }
                    else
                    {
                        string message = string.Format(CommonStrings.LoopingMethodTerminated,
                            methodName, cDomainType.GetType().ToString());
                        System.Diagnostics.Debug.WriteLine(message);
                        throw new ApplicationException(message);
                    }
                }
                else
                {
                    string message = string.Format(CommonStrings.MethodXNotImplementedForParamTypeY,
                        methodName, cDomainType.GetType().ToString());
                    System.Diagnostics.Debug.WriteLine(message);
                    throw new ApplicationException(message);
                }
            }
            catch (System.Reflection.TargetInvocationException ex)
            {
                if (ex.InnerException != null)
                    throw new ApplicationException(ex.InnerException.Message, ex.InnerException);
                else
                    throw new ApplicationException(ex.Message, ex);
            }
        }