예제 #1
0
        public void ValidateHelper(XmlWriter s, IGraphable o, ITypeFormatter formatter, XmlIts1FormatterGraphResult resultContext)
        {
            IResultDetail[] details = null;

            if (ValidateConformance && (!formatter.Validate(o, s.ToString(), out details)))
                resultContext.AddResultDetail(details.Length > 0 ? details : new IResultDetail[] { new DatatypeValidationResultDetail(ValidateConformance ? ResultDetailType.Error : ResultDetailType.Warning, o.GetType().ToString(), s.ToString()) });
        }
예제 #2
0
        protected virtual void GraphObject(XmlWriter s, IGraphable o, Type useType, IGraphable context, XmlIts1FormatterGraphResult resultContext)
        {

            // Find the HL7 alias for the type and build the cache for the type
            string typeName = GetStructureName(useType);

            // Find a helper
            IXmlStructureFormatter ixsf = (IXmlStructureFormatter)this.GraphAides.Find(t => t.HandleStructure.Contains(typeName));

            // Does the helper graph aide have a handler?
            if (ixsf != null)
            {
                ixsf.Host = this;
                var rv = ixsf.Graph(s, o);

                resultContext.AddResultDetail(rv.Details);

                return;
            }

#if WINDOWS_PHONE
            ITypeFormatter formatter = m_codeGeneratorFormatter.GetFormatter(useType);
            if (formatter == null)
                formatter = new ReflectFormatter();
#else
            ITypeFormatter formatter = m_codeGeneratorFormatter.GetFormatter(useType);
            // Is there a formatter and if there is not a formatter 
            // can we create one?
            if (formatter == null && (Settings & SettingsType.UseGeneratorFormat) == SettingsType.UseGeneratorFormat)
                s_threadPool.QueueUserWorkItem((WaitCallback)delegate(object state)
                {
                    BuildCache(new Type[] { (Type)state });
                }, useType);
            // If there is no connector can we use reflection?
            if (formatter == null && (Settings & SettingsType.UseReflectionFormat) == SettingsType.UseReflectionFormat)
                formatter = new ReflectFormatter();
            else if (formatter == null && (Settings & SettingsType.UseGeneratorFormat) == SettingsType.UseGeneratorFormat)
            {
                s_threadPool.WaitOne();
                formatter = m_codeGeneratorFormatter.GetFormatter(useType);
            }
#endif
            if(formatter == null)
                throw new InvalidOperationException(string.Format("Couldn't format '{0}' at {1}, verify formatter settings!", useType.FullName, s.ToString()));

            // Validate the instance
            formatter.Host = this;
            
            // Graph using helper
            formatter.Graph(s, o, context, resultContext);

        }