private void SetAttributes(SaveFormatAttributes attributes)
        {
            // can not be compact & standard & expanded
            syntax = attributes & (SaveFormatAttributes.Compact | SaveFormatAttributes.Standard | SaveFormatAttributes.Expanded);

            if ((syntax != SaveFormatAttributes.Compact) && (syntax != SaveFormatAttributes.Standard) && (syntax != SaveFormatAttributes.Expanded))
            {
                throw new ArgumentException("Can only use one save format attribute out of: compact, standard and expanded");
            }

            forceDataTyping = ((attributes & SaveFormatAttributes.ForceDataTyping) == SaveFormatAttributes.ForceDataTyping);
        }
        private void PerformSaveTest(string ruleFile, SaveFormatAttributes sfa)
        {
            string inFile = ruleFilesFolder + ruleFile;

            string outFile = outFilesFolder + "outtest.ruleml";
            FileInfo fi = new FileInfo(outFile);
            if (fi.Exists) fi.Delete();

            IInferenceEngine ie = new IEImpl();
            ie.LoadRuleBase(new RuleML09NafDatalogAdapter(inFile, FileAccess.Read));
            ie.SaveRuleBase(new RuleML09NafDatalogAdapter(outFile, FileAccess.Write, sfa));

            Assert.IsTrue(TestAdapter.AreXmlOfSameLength(inFile, outFile), "Same XML file lengths");
        }
Exemple #3
0
		protected string GenerateRuleFile(string inFile, SaveFormatAttributes sfa) {
			string outFile = outFilesFolder + sfa.ToString().ToLower() + "-" + inFile;
			
			FileInfo fi = new FileInfo(outFile);
			if (fi.Exists) fi.Delete();
			
			IInferenceEngine ie = new IEImpl();
			ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + inFile, FileAccess.Read));
			ie.SaveRuleBase(new RuleML09NafDatalogAdapter(outFile, FileAccess.Write, sfa));
			
			Console.Out.WriteLine("Generated: {0}", outFile);
			
			return outFile;
		}
        protected string GenerateRuleFile(string inFile, SaveFormatAttributes sfa)
        {
            string outFile = outFilesFolder + sfa.ToString().ToLower() + "-" + inFile;

            FileInfo fi = new FileInfo(outFile);
            if (fi.Exists) fi.Delete();

            IInferenceEngine ie = new IEImpl();
            ie.LoadRuleBase(new RuleML09NafDatalogAdapter(ruleFilesFolder + inFile, FileAccess.Read));
            ie.SaveRuleBase(new RuleML09NafDatalogAdapter(outFile, FileAccess.Write, sfa));

            Console.Out.WriteLine("Generated: {0}", outFile);

            return outFile;
        }
        private void PerformSaveTest(string ruleFile, SaveFormatAttributes sfa)
        {
            string inFile = ruleFilesFolder + ruleFile;

            string   outFile = outFilesFolder + "outtest.ruleml";
            FileInfo fi      = new FileInfo(outFile);

            if (fi.Exists)
            {
                fi.Delete();
            }

            IInferenceEngine ie = new IEImpl();

            ie.LoadRuleBase(new RuleML09NafDatalogAdapter(inFile, FileAccess.Read));
            ie.SaveRuleBase(new RuleML09NafDatalogAdapter(outFile, FileAccess.Write, sfa));

            Assert.IsTrue(TestAdapter.AreSameXml(inFile, outFile), "Same XML file lengths");
        }
 /// <summary>
 /// Instantiates a RuleML 0.9 Datalog adapter for reading from or writing to an URI.
 /// </summary>
 /// <param name="uriRuleML">The URI to read from or write to.</param>
 /// <param name="mode">The FileAccess mode.</param>
 /// <param name="attributes">The RuleML format attributes, only used if writing.</param>
 /// <remarks>When reading, all formats are automatically supported.</remarks>
 public RuleML09NafDatalogAdapter(string uriRuleML, FileAccess mode, SaveFormatAttributes attributes) : base(uriRuleML, mode)
 {
     SetAttributes(attributes);
     Init(null, uriRuleML, mode);
 }
 /// <summary>
 /// Instantiates a RuleML 0.9 NafDatalog adapter for reading from or writing to a stream.
 /// </summary>
 /// <param name="streamRuleML">The stream to read from or write to.</param>
 /// <param name="mode">The FileAccess mode.</param>
 /// <param name="attributes">The RuleML format attributes, only used if writing.</param>
 /// <remarks>When reading, all formats are automatically supported.</remarks>
 public RuleML09NafDatalogAdapter(Stream streamRuleML, FileAccess mode, SaveFormatAttributes attributes) : base(streamRuleML, mode)
 {
     SetAttributes(attributes);
     Init(streamRuleML, null, mode);
 }
 /// <summary>
 /// Instantiates a RuleML 0.9 Datalog adapter for reading from or writing to an URI.
 /// </summary>
 /// <param name="uriRuleML">The URI to read from or write to.</param>
 /// <param name="mode">The FileAccess mode.</param>
 /// <param name="attributes">The RuleML format attributes, only used if writing.</param>
 /// <remarks>When reading, all formats are automatically supported.</remarks>
 public RuleML09NafDatalogAdapter(string uriRuleML, FileAccess mode, SaveFormatAttributes attributes)
     : base(uriRuleML, mode)
 {
     SetAttributes(attributes);
     Init(null, uriRuleML, mode);
 }
        private void SetAttributes(SaveFormatAttributes attributes)
        {
            // can not be compact & standard & expanded
            syntax = attributes & (SaveFormatAttributes.Compact|SaveFormatAttributes.Standard|SaveFormatAttributes.Expanded);

            if ((syntax != SaveFormatAttributes.Compact) && (syntax != SaveFormatAttributes.Standard) && (syntax != SaveFormatAttributes.Expanded))
                throw new ArgumentException("Can only use one save format attribute out of: compact, standard and expanded");

            forceDataTyping = ((attributes & SaveFormatAttributes.ForceDataTyping) == SaveFormatAttributes.ForceDataTyping);
        }
 /// <summary>
 /// Instantiates a RuleML 0.9 NafDatalog adapter for reading from or writing to a stream.
 /// </summary>
 /// <param name="streamRuleML">The stream to read from or write to.</param>
 /// <param name="mode">The FileAccess mode.</param>
 /// <param name="attributes">The RuleML format attributes, only used if writing.</param>
 /// <remarks>When reading, all formats are automatically supported.</remarks>
 public RuleML09NafDatalogAdapter(Stream streamRuleML, FileAccess mode, SaveFormatAttributes attributes)
     : base(streamRuleML, mode)
 {
     SetAttributes(attributes);
     Init(streamRuleML, null, mode);
 }
 /// <summary>
 /// Only delegates to base constructor.
 /// </summary>
 /// <param name="uriRuleML">The URI to read from or write to.</param>
 /// <param name="mode">The FileAccess mode.</param>
 /// <param name="attributes">The RuleML format attributes, only used if writing.</param>
 public AccumulatingExtendedRuleBaseAdapter(string uriRuleML, FileAccess mode, SaveFormatAttributes attributes)
     : base(uriRuleML, mode)
 {
     // NOOP
 }
 /// <summary>
 /// Only delegates to base constructor.
 /// </summary>
 /// <param name="uriRuleML">The URI to read from or write to.</param>
 /// <param name="mode">The FileAccess mode.</param>
 /// <param name="attributes">The RuleML format attributes, only used if writing.</param>
 public AccumulatingExtendedRuleBaseAdapter(string uriRuleML, FileAccess mode, SaveFormatAttributes attributes) : base(uriRuleML, mode)
 {
     // NOOP
 }
 /// <summary>
 /// Instantiates a RuleML 0.91 Datalog adapter for reading from or writing to an URI.
 /// </summary>
 /// <param name="uriRuleML">The URI to read from or write to.</param>
 /// <param name="mode">The FileAccess mode.</param>
 /// <param name="attributes">The RuleML format attributes, only used if writing.</param>
 /// <remarks>When reading, all formats are automatically supported.</remarks>
 public RuleML091NafDatalogAdapter(string uriRuleML, FileAccess mode, SaveFormatAttributes attributes) : base(uriRuleML, mode)
 {
     // NOOP
 }
 /// <summary>
 /// Instantiates a RuleML 0.91 Datalog adapter for reading from or writing to an URI.
 /// </summary>
 /// <param name="uriRuleML">The URI to read from or write to.</param>
 /// <param name="mode">The FileAccess mode.</param>
 /// <param name="attributes">The RuleML format attributes, only used if writing.</param>
 /// <remarks>When reading, all formats are automatically supported.</remarks>
 public RuleML091NafDatalogAdapter(string uriRuleML, FileAccess mode, SaveFormatAttributes attributes)
     : base(uriRuleML, mode)
 {
     // NOOP
 }