예제 #1
0
        protected override void DoNew <Root>(SchemaList <FileGroup, Root> originFields, FileGroup node)
        {
            FileGroup newNode = (FileGroup)node.Clone(originFields.Parent);

            newNode.Status = Enums.ObjectStatusType.CreateStatus;

            /*If the Logical File Name exists in another filegroup,
             * we must change the new Logical File Name.
             */
            originFields.ForEach(file =>
            {
                if (file.Status != Enums.ObjectStatusType.DropStatus)
                {
                    file.Files.ForEach(group =>
                    {
                        newNode.Files.ForEach(ngroup =>
                        {
                            if (group.CompareFullNameTo(group.FullName, ngroup.FullName) == 0)
                            {
                                newNode.Files[ngroup.FullName].Name = group.Name + "_2";
                            }
                        });
                    });
                }
            });
            originFields.Add(newNode);
        }
예제 #2
0
        public void ValidateSchema()
        {
            if (SchemaList == null || !SchemaList.Any())
            {
                return;
            }

            var settings = new XmlReaderSettings();

            settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
            settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
            settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;


            SchemaList.ForEach(
                s => settings.Schemas.Add(s.TargetNamespace, XmlReader.Create(new StringReader(s.SchemaContent))));

            settings.ValidationType          = ValidationType.Schema;
            settings.ValidationEventHandler += settings_ValidationEventHandler;
            var reader = XmlReader.Create(new StringReader(XmlToValidate), settings);

            while (reader.Read())
            {
            }
            if (string.IsNullOrEmpty(ErrorXml))
            {
                IsValid = true;
            }
            var errorBuilder = new StringBuilder();

            if (_errors.Any())
            {
                errorBuilder.Append("<errors>");
                _errors.ForEach(e => errorBuilder.AppendFormat("<Error>{0}</Error>", e));
                errorBuilder.Append("</errors>");
                ErrorXml = FdrCommon.FormatXml(errorBuilder.ToString());
            }

            IsValid = !_errors.Any();
        }