public void Validate(ValidationContext context, XDocument rulePackXDocument)
        {
            if (context.IsPayloadOobRuleCollection)
            {
                return;
            }
            string text = context.ValidatedRuleCollectionDocument ?? XmlProcessingUtils.XDocumentToStringWithDeclaration(rulePackXDocument);

            ClassificationRuleCollectionRuntimeValidator.ValidateRulePackageContentsAgainstMce(context.CurrentOrganizationId, rulePackXDocument, text);
            if (context.ValidatedRuleCollectionDocument == null)
            {
                context.ValidatedRuleCollectionDocument = text;
            }
        }
        private static void ValidateRulePackageContentsAgainstMce(OrganizationId currentOrganizationId, XDocument rulePackXDocument, string rulePackContents)
        {
            Task task = Task.Factory.StartNew(delegate()
            {
                ClassificationEngineValidator.ValidateRulePackage(rulePackXDocument, rulePackContents);
            });

            try
            {
                task.Wait(30000);
            }
            catch (AggregateException ex)
            {
                ex.Handle((Exception exception) => ClassificationRuleCollectionRuntimeValidator.HandleClassificationEngineValidatorException(exception, currentOrganizationId));
            }
            if (task.Status != TaskStatus.RanToCompletion)
            {
                ClassificationDefinitionsDiagnosticsReporter.Instance.WriteClassificationEngineTimeoutInValidation(0, currentOrganizationId, 30000);
                throw new ClassificationRuleCollectionTimeoutException();
            }
        }