Beispiel #1
0
        /// <summary>
        /// Validates the type dictionary.
        /// </summary>
        /// <param name="dictionary"></param>
        private void Validate(byte[] dictionary)
        {
            MemoryStream istrm = new MemoryStream(dictionary);

            if (m_typeSystemId == Objects.XmlSchema_TypeSystem)
            {
                Schema.Xml.XmlSchemaValidator validator = new Schema.Xml.XmlSchemaValidator();

                try {
                    validator.Validate(istrm);
                } catch (Exception e) {
                    Utils.Trace(e, "Could not validate schema.");
                }

                m_validator = validator;
            }

            if (m_typeSystemId == Objects.OPCBinarySchema_TypeSystem)
            {
                Schema.Binary.BinarySchemaValidator validator = new Schema.Binary.BinarySchemaValidator();

                try {
                    validator.Validate(istrm);
                } catch (Exception e) {
                    Utils.Trace(e, "Could not validate schema.");
                }

                m_validator = validator;
            }
        }
        /// <summary>
        /// Validates the type dictionary.
        /// </summary>
        /// <param name="dictionary">The encoded dictionary to validate.</param>
        /// <param name="throwOnError">Throw if an error occurred.</param>
        internal async Task Validate(byte[] dictionary, bool throwOnError = false)
        {
            MemoryStream istrm = new MemoryStream(dictionary);

            if (TypeSystemId == Objects.XmlSchema_TypeSystem)
            {
                Schema.Xml.XmlSchemaValidator validator = new Schema.Xml.XmlSchemaValidator();

                try
                {
                    validator.Validate(istrm);
                }
                catch (Exception e)
                {
                    Utils.Trace(e, "Could not validate schema.");
                    if (throwOnError)
                    {
                        throw;
                    }
                }

                m_validator = validator;
            }

            if (TypeSystemId == Objects.OPCBinarySchema_TypeSystem)
            {
                Schema.Binary.BinarySchemaValidator validator = new Schema.Binary.BinarySchemaValidator();

                try
                {
                    await validator.Validate(istrm).ConfigureAwait(false);
                }
                catch (Exception e)
                {
                    Utils.Trace(e, $"Could not validate schema. {e.Message}");
                    if (throwOnError)
                    {
                        throw;
                    }
                }

                m_validator    = validator;
                TypeDictionary = validator.Dictionary;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Validates the type dictionary.
        /// </summary>
        /// <param name="dictionary">The encoded dictionary to validate.</param>
        /// <param name="throwOnError">Throw if an error occurred.</param>
        internal async Task Validate(byte[] dictionary, bool throwOnError = false)
        {
            MemoryStream istrm = new MemoryStream(dictionary);

            if (TypeSystemId == Objects.XmlSchema_TypeSystem)
            {
                Schema.Xml.XmlSchemaValidator validator = new Schema.Xml.XmlSchemaValidator();

                try
                {
                    validator.Validate(istrm);
                }
                catch (Exception e)
                {
                    if (throwOnError)
                    {
                        throw;
                    }
                    Utils.LogWarning(e, "Could not validate XML schema, error is ignored.");
                }

                m_validator = validator;
            }

            if (TypeSystemId == Objects.OPCBinarySchema_TypeSystem)
            {
                Schema.Binary.BinarySchemaValidator validator = new Schema.Binary.BinarySchemaValidator();

                try
                {
                    await validator.Validate(istrm).ConfigureAwait(false);
                }
                catch (Exception e)
                {
                    if (throwOnError)
                    {
                        throw;
                    }
                    Utils.LogWarning(e, "Could not validate binary schema, error is ignored.");
                }

                m_validator    = validator;
                TypeDictionary = validator.Dictionary;
            }
        }
        /// <summary>
        /// Validates the type dictionary.
        /// </summary>
        /// <param name="dictionary"></param>
        private async Task Validate(byte[] dictionary)
        {
            MemoryStream istrm = new MemoryStream(dictionary);

            if (TypeSystemId == Objects.XmlSchema_TypeSystem)
            {
                Schema.Xml.XmlSchemaValidator validator = new Schema.Xml.XmlSchemaValidator();

                try
                {
                    validator.Validate(istrm);
                }
                catch (Exception e)
                {
                    Utils.Trace(e, "Could not validate schema.");
                }

                m_validator = validator;
            }

            if (TypeSystemId == Objects.OPCBinarySchema_TypeSystem)
            {
                Schema.Binary.BinarySchemaValidator validator = new Schema.Binary.BinarySchemaValidator();

                try
                {
                    await validator.Validate(istrm);
                }
                catch (Exception e)
                {
                    Utils.Trace(e, $"Could not validate schema. {e.Message}");
                }

                m_validator    = validator;
                TypeDictionary = validator.Dictionary;
            }
        }
        /// <summary>
        /// Validates the type dictionary.
        /// </summary>
        /// <param name="dictionary"></param>
        private async Task Validate(byte[] dictionary)
        {
            MemoryStream istrm = new MemoryStream(dictionary);

            if (m_typeSystemId == Objects.XmlSchema_TypeSystem)
            {
                Schema.Xml.XmlSchemaValidator validator = new Schema.Xml.XmlSchemaValidator();

                try
                {
                    validator.Validate(istrm);
                }
                catch (Exception e)
                {
                    Utils.Trace(e, "Could not validate schema.");
                }

                m_validator = validator;
            }

            if (m_typeSystemId == Objects.OPCBinarySchema_TypeSystem)
            {
                Schema.Binary.BinarySchemaValidator validator = new Schema.Binary.BinarySchemaValidator();

                try
                {
                    await validator.Validate(istrm);
                }
                catch (Exception e)
                {
                    Utils.Trace(e, "Could not validate schema.");
                }

                m_validator = validator;
            }
        }