internal static void ValidateRulePackage(XDocument rulePackXDoc, string rulePackContents) { string mceExecutablePath = ClassificationDefinitionUtils.GetMceExecutablePath(true); if (mceExecutablePath == null || !File.Exists(mceExecutablePath)) { throw new COMException("Unable to locate the Microsoft Classification Engine", -2147287038); } try { using (ActivationContextActivator.FromInternalManifest(mceExecutablePath, Path.GetDirectoryName(mceExecutablePath))) { MicrosoftClassificationEngine microsoftClassificationEngine = new MicrosoftClassificationEngine(); PropertyBag propertyBag = new PropertyBag(); RulePackageLoader rulePackageLoader = new RulePackageLoader(); microsoftClassificationEngine.Init(propertyBag, rulePackageLoader); RULE_PACKAGE_DETAILS rule_PACKAGE_DETAILS = default(RULE_PACKAGE_DETAILS); rule_PACKAGE_DETAILS.RulePackageSetID = "not-used-here"; rule_PACKAGE_DETAILS.RulePackageID = "test-rule-pack"; rule_PACKAGE_DETAILS.RuleIDs = null; RULE_PACKAGE_DETAILS rule_PACKAGE_DETAILS2 = rule_PACKAGE_DETAILS; rulePackageLoader.SetRulePackage(rule_PACKAGE_DETAILS2.RulePackageID, rulePackContents); try { MicrosoftClassificationEngine microsoftClassificationEngine2 = microsoftClassificationEngine; RULE_PACKAGE_DETAILS rule_PACKAGE_DETAILS3 = rule_PACKAGE_DETAILS2; microsoftClassificationEngine2.GetClassificationDefinitions(ref rule_PACKAGE_DETAILS3); } catch (COMException ex) { if (ex.ErrorCode == -2147220978) { List <string> value = ClassificationEngineValidator.GetInvalidRegexes(microsoftClassificationEngine, rulePackageLoader, rulePackXDoc).ToList <string>(); ex.Data[ClassificationEngineValidator.BadRegexesKey] = value; } throw ex; } } } catch (ActivationContextActivatorException) { throw new COMException("Unable to instantiate the Microsoft Classification Engine", -2147164127); } }
protected override void InternalProcessRecord() { string mceExecutablePath = ClassificationDefinitionUtils.GetMceExecutablePath(true); if (mceExecutablePath == null || !File.Exists(mceExecutablePath)) { throw new ErrorCannotLoadFingerprintCreatorException(); } try { using (ActivationContextActivator.FromInternalManifest(mceExecutablePath, Path.GetDirectoryName(mceExecutablePath))) { MicrosoftFingerprintCreator microsoftFingerprintCreator = new MicrosoftFingerprintCreator(); try { base.WriteVerbose(Strings.VerboseBeginFingerprint); byte[] bytes; uint base64EncodedFingerprint = microsoftFingerprintCreator.GetBase64EncodedFingerprint(this.extractedText, ref bytes); base.WriteVerbose(Strings.VerboseEndFingerprint); this.extractedText = string.Empty; base.WriteObject(new Fingerprint(Encoding.ASCII.GetString(bytes), base64EncodedFingerprint, this.Description)); } catch (COMException innerException) { throw new ErrorCannotCreateFingerprintException(innerException); } catch (ArgumentException innerException2) { throw new ErrorCannotCreateFingerprintException(innerException2); } } } catch (ActivationContextActivatorException innerException3) { throw new ErrorCannotCreateFingerprintException(innerException3); } }