Inheritance: IXmlDocumentProvider
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                Debug.Initialize();

                ISerializationSettings settings = SerializationContext.Default.GetService<ISerializationSettings>();
                settings.ParsingMode = ParsingModeType.Loose;
                settings.EnsureAccurateLineNumbers = true;
                settings.StoreExtraSerializationData = true;

                _Arguments = new CommandLineArgumentList(args, StringComparison.CurrentCultureIgnoreCase);

                IXmlDocumentProvider docProvider = null;

                // Initialize our xml document provider
                if (File.Exists("icalvalidSchema.zip"))
                    docProvider = new ZipXmlDocumentProvider("icalvalidSchema.zip");
                else if (Directory.Exists("icalvalidSchema"))
                    docProvider = new DirectoryXmlDocumentProvider("icalvalidSchema");
                else
                    throw new Exception("A valid schema directory or zip file could not be located!");

                IValidationRuleset selectedRuleset = null;
                try
                {
                    // Setup the language to use for validation/tests
                    SetupLanguage(docProvider);
                    selectedRuleset = LoadRuleset(docProvider);
                }
                catch (ValidationRuleLoadException ex)
                {
                    _ValidationRuleLoadException = ex;
                }

                if (_Arguments.Contains(_SchemaValidationArgument))
                {
                    SchemaTest(docProvider);
                    LanguageKeyValidation(docProvider);
                }
                else if (_ValidationRuleLoadException == null)
                {
                    // Determine whether we are performing a self test, or
                    // validating an iCalendar file...
                    if (_Arguments.Contains(_TestArgument))
                    {
                        SelfTest(docProvider, selectedRuleset);
                    }
                    else
                    {
                        ValidateFile(docProvider, selectedRuleset);
                    }
                }
                else
                {
                    Console.WriteLine("The icalvalid schema did not load successfully: " + _ValidationRuleLoadException.Message +
                        Environment.NewLine +
                        Environment.NewLine +
                        "Try 'icalvalid /s' for more information.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
        protected byte[] Setup()
        {
            byte[] bytes = new byte[0];

            Debug = new Debug();
            Debug.Initialize();

            ISerializationSettings settings = SerializationContext.Default.GetService<ISerializationSettings>();
            settings.ParsingMode = ParsingModeType.Loose;
            settings.EnsureAccurateLineNumbers = true;
            settings.StoreExtraSerializationData = true;

            DocumentProvider = new DirectoryXmlDocumentProvider(Path.Combine(Request.PhysicalApplicationPath, "icalvalidSchema"));

            SelectedRuleset = null;
            try
            {
                ResourceManager = new ResourceManager();

                // Setup the language to use for validation/tests
                SetupLanguage();
                SelectedRuleset = LoadRuleset();
            }
            catch (ValidationRuleLoadException e)
            {
                Utils.StoreExceptionBlob("Setup: " + e.Message + e.StackTrace);
                bytes = Response.Output.Encoding.GetBytes(e.Message);
            }

            return bytes;
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                Debug.Initialize();

                // Adjust default serialization settings
                ISerializationSettings settings = SerializationContext.Default.GetService<ISerializationSettings>();
                settings.ParsingMode = ParsingModeType.Loose;
                settings.EnsureAccurateLineNumbers = true;
                settings.StoreExtraSerializationData = true;

                for (int i = 0; i < 10000; i++)
                {
                    IXmlDocumentProvider docProvider = null;

                    // Initialize our xml document provider
                    if (File.Exists("icalvalidSchema.zip"))
                        docProvider = new ZipXmlDocumentProvider("icalvalidSchema.zip");
                    else if (Directory.Exists("icalvalidSchema"))
                        docProvider = new DirectoryXmlDocumentProvider("icalvalidSchema");
                    else
                        throw new Exception("A valid schema directory or zip file could not be located!");

                    IValidationRuleset selectedRuleset = null;

                    // Setup the language to use for validation/tests
                    SetupLanguage(docProvider);
                    selectedRuleset = LoadRuleset(docProvider);

                    ValidateFile(@"Calendars\Test1.ics", docProvider, selectedRuleset);
                    ValidateFile(@"Calendars\Test2.ics", docProvider, selectedRuleset);
                    ValidateFile(@"Calendars\Test3.ics", docProvider, selectedRuleset);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }