Esempio n. 1
0
        private String GetFontName(String fileName, UIEngine engine)
        {
            using (IXmlReader reader = this.engine.OpenXmlFile(fileName))
            {
                if (null != reader)
                {
                    IXmlElement root     = reader.RootElement;
                    String      fontName = "";

                    if ("font" == root.Name)
                    {
                        fontName = root.GetAttributeValue("name", "");
                    }

                    if ("" == fontName)
                    {
                        return(null);
                    }
                    else
                    {
                        return(fontName);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 2
0
        public object Parse(IXmlReader stream)
        {
            var xamlProtoNodes = protoParser.Parse(stream);
            var xamlNodes      = parser.Parse(xamlProtoNodes);

            return(Parse(xamlNodes));
        }
Esempio n. 3
0
        /// <summary>
        /// Loads desktop from xml file. Creates define windows as well.
        /// </summary>
        /// <param name="reader">xml document to load from.</param>
        private void Load(IXmlReader reader)
        {
            IXmlElement root = reader.RootElement;

            if ((null != root) && (root.Name == "desktop"))
            {
                this.desktopSize.Width  = UIUtils.FromString(root.GetAttributeValue("Width", ""), this.desktopSize.Width);
                this.desktopSize.Height = UIUtils.FromString(root.GetAttributeValue("Height", ""), this.desktopSize.Height);
                this.Wallpaper          = root.GetAttributeValue("wallpaper", this.Wallpaper);

                foreach (IXmlElement element in root.Elements)
                {
                    if (element.Name == "window")
                    {
                        String type = element.GetAttributeValue("type", "");

                        if (type.Length > 0)
                        {
                            NewRegisteredWindow(type);
                        }
                        else
                        {
                            NewWindow(CreationFlag.NeedLoading, element.GetAttributeValue("name", ""));
                        }

                        if (null != this.Resized)
                        {
                            this.Resized(this, EventArgs.Empty);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>Creates an instance of <c>readerType</c> if it has a constructor
        /// matching the runtime types in the <c>args</c> array of parameters.</summary>
        private static IXmlReader CreateInstance(Type readerType, Object[] args)
        {
            IXmlReader   result = null;
            BindingFlags flags  = BindingFlags.Instance | BindingFlags.Public;

            Type[] argTypes;
            if (args != null)
            {
                argTypes = new Type[args.Length];
            }
            else
            {
                argTypes = Type.EmptyTypes;
            }
            for (int indx = 0; indx < argTypes.Length; indx++)
            {
                argTypes[indx] = args[indx].GetType();
            }
            ConstructorInfo cInfo = readerType.GetConstructor(flags, null, argTypes, null);

            if (cInfo != null)
            {
                result = cInfo.Invoke(args) as IXmlReader;
            }
            return(result);
        }
Esempio n. 5
0
        public IEnumerable<ProtoXamlNode> Parse(Stream stream)
        {
            reader = new XmlCompatibilityReader(stream);
            reader.Read();

            return ParseElement();
        }
        public IEnumerable<ProtoXamlInstruction> Parse(Stream stream)
        {
            reader = new XmlCompatibilityReader(stream);
            attributeParser = new AttributeParser(reader);
            reader.Read();

            return ParseElement();
        }
        public IEnumerable <ProtoXamlInstruction> Parse(IXmlReader stream)
        {
            this.reader     = stream;
            attributeParser = new AttributeParser(reader);
            reader.Read();

            return(ParseElement());
        }
        public IEnumerable<ProtoXamlInstruction> Parse(IXmlReader stream)
        {
            this.reader = stream;
            attributeParser = new AttributeParser(reader);
            reader.Read();

            return ParseElement();
        }
Esempio n. 9
0
 public OperationDataMapper(IXmlReader xmlReader, IBinaryReader binaryReader, ISpatialRecordMapper spatialRecordMapper, ISectionMapper sectionMapper, IUniqueIdMapper uniqueIdMapper)
 {
     _spatialRecordMapper = spatialRecordMapper;
     _sectionMapper = sectionMapper;
     _uniqueIdMapper = uniqueIdMapper;
     _xmlReader = xmlReader;
     _binaryReader = binaryReader;
 }
 public CustomInteriorManager(IXmlReader xmlReader, IFilesManager filesManager,
                              IDatabase database, IHttpContextReader httpContextReader)
 {
     this.xmlReader         = xmlReader;
     this.filesManager      = filesManager;
     this.database          = database;
     this.httpContextReader = httpContextReader;
 }
Esempio n. 11
0
 public OperationDataMapper(IXmlReader xmlReader, IBinaryReader binaryReader, ISpatialRecordMapper spatialRecordMapper, ISectionMapper sectionMapper, IUniqueIdMapper uniqueIdMapper)
 {
     _spatialRecordMapper = spatialRecordMapper;
     _sectionMapper       = sectionMapper;
     _uniqueIdMapper      = uniqueIdMapper;
     _xmlReader           = xmlReader;
     _binaryReader        = binaryReader;
 }
Esempio n. 12
0
 /// <summary>
 /// Creates instance of class
 /// </summary>
 /// <param name="currencyGetterService"><see cref="ICurrencyGetterService"/></param>
 /// <param name="xmlReader"><see cref="IXmlReader"/></param>
 /// <param name="dateChecker"><see cref="IDateService"/></param>
 /// <param name="cacheDatabase"><see cref="ICacheDatabase"/></param>
 public CurrencyService(ICurrencyGetterService currencyGetterService, IXmlReader xmlReader, IDateService dateChecker,
                        ICacheDatabase cacheDatabase)
 {
     _currencyGetterService = currencyGetterService;
     _xmlReader             = xmlReader;
     _dateChecker           = dateChecker;
     _cacheDatabase         = cacheDatabase;
 }
Esempio n. 13
0
 public Plugin(IXmlReader xmlReader, IImporter importer, IExporter exporter)
 {
     _xmlReader = xmlReader;
     _importer  = importer;
     _exporter  = exporter;
     Name       = "ISO Plugin";
     Version    = "0.1.1";
     Owner      = "AgGateway & Contributors";
 }
Esempio n. 14
0
 public Plugin(IXmlReader xmlReader, IImporter importer, IExporter exporter)
 {
     _xmlReader = xmlReader;
     _importer = importer;
     _exporter = exporter;
     Name = "ISO Plugin";
     Version = "0.1.1";
     Owner = "AgGateway & Contributors";
 }
Esempio n. 15
0
 public NSXMLParser()
 {
     // TODO remove the necessity to load this assembly
     string strAssemDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
     string strAssemPath = System.IO.Path.Combine(strAssemDir, "AElfred.dll");
     Assembly assem = Assembly.LoadFrom(strAssemPath);
     _saxParser = SaxReaderFactory.CreateReader(assem, null);
     _builder = new StringBuilder();
 }
Esempio n. 16
0
File: Theme.cs Progetto: drme/thw-ui
 /// <summary>
 /// Loads theme configuration from xml file.
 /// </summary>
 /// <param name="engine"></param>
 private void LoadTheme(UIEngine engine)
 {
     using (IXmlReader reader = engine.OpenXmlFile(this.themeFolder + "theme.xml"))
     {
         if (null != reader)
         {
             Load(reader);
         }
     }
 }
        public FileReaderChain(ICsvReader csvReader,
                               IXmlReader xmlReader
                               )
        {
            rootReader = csvReader;
            rootReader.SetNext(xmlReader);

            csvReader.PropertyChanged += ReaderPropertyChange;
            xmlReader.PropertyChanged += ReaderPropertyChange;
        }
Esempio n. 18
0
 /// <summary>
 /// Check and display the value of a feature.
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="name"></param>
 private static void checkFeature(IXmlReader reader, String name)
 {
     try {
         Console.WriteLine("  " + name + " = " + reader.GetFeature(name));
     } catch (SAXNotRecognizedException e) {
         Console.WriteLine("XMLReader does not recognize feature " + name);
     } catch (SAXNotSupportedException e) {
         Console.WriteLine("XMLReader recognizes feature " + name + " but does not support checking its value");
     }
 }
Esempio n. 19
0
 private object Load(Stream stream, IXamlParser parser)
 {
     try
     {
         xmlReader = new XmlCompatibilityReader(stream);
         return(parser.Parse(xmlReader));
     }
     catch (Exception e)
     {
         throw new XamlLoadException($"Error loading XAML: {e}", xmlReader.LineNumber, xmlReader.LinePosition, e);
     }
 }
Esempio n. 20
0
 private object Load(Stream stream, IXamlParser parser)
 {
     try
     {
         xmlReader = new XmlCompatibilityReader(stream);
         return parser.Parse(xmlReader);
     }
     catch (Exception e)
     {
         throw new XamlLoadException($"Error loading XAML: {e}", xmlReader.LineNumber, xmlReader.LinePosition, e);
     }
 }
Esempio n. 21
0
        /// <summary>Creates a new instance of <see cref="IXmlReader"/> based on
        /// the constructor arguments that are passed as parameters.</summary>
        /// <remarks>The assembly and class are determined by first checking the
        /// machine configuration file's appSettings section if a default parser is
        /// specified. If that fails, the loaded assemblies are searched for a class
        /// implementing <see cref="IXmlReader"/>. The types of the objects in the
        /// <c>args</c> array must match a constructor signature of the class.</remarks>
        /// <returns><see cref="IXmlReader"/> instance.</returns>
        public static IXmlReader CreateReader(Object[] args)
        {
            try {
                AppSettingsReader confReader   = new AppSettingsReader();
                string            assemblyName =
                    (string)confReader.GetValue(ReaderAssembly, typeof(string));
                Assembly assem;
                if (File.Exists(assemblyName))
                {
                    assem = Assembly.LoadFrom(assemblyName);
                }
                else
                {
                    assem = Assembly.Load(assemblyName);
                }
                string className =
                    (string)confReader.GetValue(ReaderClass, typeof(string));
                if (className == null || className == String.Empty)
                {
                    return(CreateReader(assem, args));
                }
                else
                {
                    return(CreateReader(assem, className, args));
                }
            }
            catch {
                // ignore exception, we want to check loaded assemblies
            }

            AppDomain domain = AppDomain.CurrentDomain;

            Assembly[] assems = domain.GetAssemblies();
            // ignore the XmlFilterImpl class in this assembly
            Type xmlFilterType = typeof(XmlFilterImpl);

            foreach (Assembly assem in assems)
            {
                IXmlReader reader     = null;
                Type       readerType = FindReaderClass(assem);
                if (readerType != null && readerType != xmlFilterType && !readerType.IsSubclassOf(xmlFilterType))
                {
                    reader = CreateInstance(readerType, args);
                }
                if (reader != null)
                {
                    return(reader);
                }
            }
            string msg = Resources.GetString(RsId.NoDefaultXmlReader);

            throw new SaxException(msg);
        }
Esempio n. 22
0
        /// <summary>
        /// Opens file.
        /// </summary>
        /// <param name="fullPath">full path of file name to open.</param>
        private void OpenFile(String fullPath)
        {
            NewWindow();

            using (IXmlReader reader = this.Engine.OpenXmlFile(fullPath))
            {
                if (null != reader)
                {
                    this.activeWindow.Load(reader);
                }
            }

            this.activeFileName = fullPath;
        }
Esempio n. 23
0
        /// <summary>
        /// Loads window from xml file.
        /// </summary>
        /// <param name="reader">xml file to load from.</param>
        internal virtual void Load(IXmlReader reader)
        {
            IXmlElement root = reader.RootElement;

            if (null != root)
            {
                LoadBegin(root);
                LoadAttributes(root);
                LoadControls(root);
                LoadEnd(root);
            }

            PositionWindow();
        }
Esempio n. 24
0
        /// <summary>
        /// Constructs desktop object.
        /// </summary>
        /// <param name="engine">ui engine</param>
        /// <param name="theme">desktop theme</param>
        /// <param name="fileName">filename to load dekstop from, or empty for default desktop.</param>
        internal Desktop(UIEngine engine, Theme theme, String fileName) : base("desktop")
        {
            this.engine       = engine;
            this.theme        = theme;
            this.mousePointer = new MousePointer(this.engine);

            if (null != fileName)
            {
                using (IXmlReader reader = this.engine.OpenXmlFile(fileName))
                {
                    if (null != reader)
                    {
                        Load(reader);
                    }
                }
            }
        }
Esempio n. 25
0
        internal IXmlReader OpenXmlFile(String fileName)
        {
            IXmlReader reader = null;

            if (null != this.xmlFactory)
            {
                reader = this.xmlFactory.CreateXmlReader(this);
            }

            if (null != reader)
            {
                reader.OpenFile(fileName);

                return(reader);
            }

            return(null);
        }
Esempio n. 26
0
        /// <summary>
        /// Constructs cached font.
        /// </summary>
        /// <param name="engine">ui engine.</param>
        /// <param name="fontName">font name.</param>
        /// <param name="size">font size.</param>
        /// <param name="bold">is font bold.</param>
        /// <param name="italic">is font italic.</param>
        public WinFontCached(UIEngine engine, String fontName, int size, bool bold, bool italic) : this(fontName, size, bold, italic)
        {
            IXmlReader reader = engine.OpenXmlFile(cacheFolder + ToString() + ".xml");

            if ((null != reader) && (null != reader.RootElement))
            {
                this.letters = new WinLetterCached[256 * 256];

                foreach (IXmlElement element in reader.RootElement.Elements)
                {
                    int code  = int.Parse(element.GetAttributeValue("code", "0"));
                    int index = int.Parse(element.GetAttributeValue("index", "0"));
                    int us    = int.Parse(element.GetAttributeValue("us", "0"));
                    int vs    = int.Parse(element.GetAttributeValue("vs", "0"));
                    int ue    = int.Parse(element.GetAttributeValue("ue", "0"));
                    int ve    = int.Parse(element.GetAttributeValue("ve", "0"));
                    int w     = int.Parse(element.GetAttributeValue("width", "0"));
                    int offX  = int.Parse(element.GetAttributeValue("x", "0"));
                    int offY  = int.Parse(element.GetAttributeValue("y", "0"));

                    if ((this.cachedImages.Count <= index) || (this.cachedImages[index] != null))
                    {
                        IImage img = engine.CreateImage(cacheFolder + ToString() + "_" + index);

                        if (this.cachedImages.Count == index)
                        {
                            this.cachedImages.Add(img);
                        }
                        else
                        {
                            this.cachedImages[index] = img;
                        }
                    }

                    if (code >= 0 && code < cacheLetters)
                    {
                        this.letters[code] = new WinLetterCached(engine);
                        this.letters[code].SetCachedData(this.cachedImages[index], us, vs, ue, ve, w, offX, offY);
                    }
                }

                this.loaded = true;
            }
        }
Esempio n. 27
0
        /// <summary>Creates a new instance of <see cref="IXmlReader"/> based on the
        /// assembly and constructor arguments that are passed as parameters.</summary>
        /// <remarks>Searches the <see cref="Assembly"/> argument for classes that
        /// implement <see cref="IXmlReader"/> and have a constructor matching
        /// the types of the parameters in the <c>args</c> array. Creates a new
        /// instance of the first class it finds.</remarks>
        /// <returns><see cref="IXmlReader"/> instance.</returns>
        public static IXmlReader CreateReader(Assembly assem, Object[] args)
        {
            IXmlReader result      = null;
            Type       readerClass = FindReaderClass(assem);

            if (readerClass != null)
            {
                result = CreateInstance(readerClass, args);
            }
            if (result != null)
            {
                return(result);
            }
            else
            {
                string msg = Resources.GetString(RsId.NoXmlReaderInAssembly);
                throw new SaxException(String.Format(msg, null, assem.GetName().Name));
            }
        }
Esempio n. 28
0
 public XhtmlParser(PeterO.Support.InputStream source, string address, string charset, string lang)
 {
     if(source==null)throw new ArgumentException();
     if(address!=null && address.Length>0){
       URL url=URL.parse(address);
       if(url==null || url.getScheme().Length==0)
     throw new ArgumentException();
     }
     this.contentLang=HeaderParser.getLanguages(lang);
     this.address=address;
     try {
       this.reader=new PeterO.Support.SaxReader();
     } catch (SaxException e) {
       if(e.InnerException is IOException)
     throw (IOException)(e.InnerException);
       throw new IOException("",e);
     }
     handler=new XhtmlContentHandler(this);
     try {
       reader.SetFeature("http://xml.org/sax/features/namespaces",true);
       reader.SetFeature("http://xml.org/sax/features/use-entity-resolver2",true);
       reader.SetFeature("http://xml.org/sax/features/namespace-prefixes",true);
       reader.LexicalHandler=(handler);
     } catch (SaxException e) {
       throw new NotSupportedException("",e);
     }
     reader.ContentHandler=(handler);
     reader.EntityResolver=(handler);
     charset=TextEncoding.resolveEncoding(charset);
     if(charset==null){
       charset=sniffEncoding(source);
       if(charset==null) {
     charset="utf-8";
       }
     }
     this.isource=new InputSource<Stream>(source);
     this.isource.Encoding=(charset);
     this.encoding=charset;
 }
Esempio n. 29
0
        protected override void Context()
        {
            _individual = new Individual();
            _container  = A.Fake <IContainer>();
            _serializationContextFactory = A.Fake <ISerializationContextFactory>();
            _simulationUpdater           = A.Fake <ISimulationUpdaterAfterDeserialization>();
            _eventPublisher        = A.Fake <IEventPublisher>();
            _xmlReaderIndividual   = A.Fake <IXmlReader <Individual> >();
            _xmlWriterIndividual   = A.Fake <IXmlWriter <Individual> >();
            _xmlReaderSimulation   = A.Fake <IXmlReader <Simulation> >();
            _xmlWriterSimulation   = A.Fake <IXmlWriter <Simulation> >();
            _objectConverterFinder = A.Fake <IObjectConverterFinder>();
            _serializationContext  = A.Fake <SerializationContext>();
            A.CallTo(() => _container.Resolve <IXmlReader <Individual> >()).Returns(_xmlReaderIndividual);
            A.CallTo(() => _container.Resolve <IXmlWriter <Individual> >()).Returns(_xmlWriterIndividual);
            A.CallTo(() => _container.Resolve <IXmlReader <Simulation> >()).Returns(_xmlReaderSimulation);
            A.CallTo(() => _container.Resolve <IXmlWriter <Simulation> >()).Returns(_xmlWriterSimulation);

            _referenceResolver = A.Fake <IReferencesResolver>();
            sut = new XmlSerializationManager(_referenceResolver, _container, _objectConverterFinder, _simulationUpdater, _eventPublisher, _serializationContextFactory);
            A.CallTo(() => _serializationContextFactory.Create(null, null)).Returns(_serializationContext);
        }
Esempio n. 30
0
        /// <summary>
        /// Creates window.
        /// </summary>
        /// <param name="desktop">desktop it belongs to.</param>
        /// <param name="creationFlags">creation flags.</param>
        /// <param name="fileName">xml file name to load window from. if empty default window is created.</param>
        public Window(Desktop desktop, CreationFlag creationFlags, String fileName) : base(desktop, null, creationFlags, "window")
        {
            this.desktop = desktop;

            if (null == this.desktop)
            {
                throw new Exception("Desktop can not be null");
            }

            this.leftBorderColor  = this.Desktop.Theme.Colors.WindowTitleStart;
            this.rightBorderColor = this.Desktop.Theme.Colors.WindowTitleEnd;

            ControlSettings settings = this.Desktop.Theme.GetControlSettings(this.Type);

            this.Icon            = this.Desktop.Theme.ThemeFolder + "/images/window_icon";
            this.BackImageLayout = ImageLayout.ImageLayoutTile;

            this.IconImageOffset.X = 1;
            this.IconImageOffset.Y = 1;
            this.Moveable          = true;
            this.Sizeable          = true;
            this.TextColor         = Colors.White;
            this.TopOffset         = 20;
            this.Border            = BorderStyle.BorderRaisedDouble;
            this.Bounds            = new Rectangle(10, 10, 300, 300);

            if ((null != fileName) && (0 != fileName.Length))
            {
                using (IXmlReader reader = this.Engine.OpenXmlFile(fileName))
                {
                    if (null != reader)
                    {
                        Load(reader);
                    }
                }
            }
        }
Esempio n. 31
0
File: Theme.cs Progetto: drme/thw-ui
        /// <summary>
        /// Loads theme configuration from xml file.
        /// </summary>
        /// <param name="reader">xml document containing theme configuration.</param>
        private void Load(IXmlReader reader)
        {
            IXmlElement root = reader.RootElement;

            if (null != root)
            {
                this.skinned         = UIUtils.FromString(root.GetAttributeValue("skinned", ""), this.skinned);
                this.defaultFontName = root.GetAttributeValue("defaultfont", this.defaultFontName);

                foreach (IXmlElement element in root.Elements)
                {
                    switch (element.Name)
                    {
                    case "colors":
                        this.Colors.LoadColors(element);
                        break;

                    case "menu":
                        this.Menu.LoadMenu(element, this.Colors);
                        break;

                    case "borders":
                    case "controls":
                        LoadBorders(element);
                        break;

                    case "window":
                        this.Window.LoadWindow(element);
                        break;

                    default:
                        throw new NotSupportedException("Unknown tag: " + element.Name);
                    }
                }
            }
        }
Esempio n. 32
0
        /// <summary>Creates a new instance of <see cref="IXmlReader"/> based on the assembly,
        /// class name and constructor arguments that are passed as parameters.</summary>
        /// <remarks>The types of the objects in the <c>args</c> array must match
        /// a constructor signature of the class.</remarks>
        /// <returns><see cref="IXmlReader"/> instance.</returns>
        public static IXmlReader CreateReader(Assembly assem, string className, Object[] args)
        {
            if (assem == null)
            {
                throw new ArgumentNullException("assem");
            }
            IXmlReader result     = null;
            Type       readerType = assem.GetType(className, false);

            if (readerType != null)
            {
                result = CreateInstance(readerType, args);
            }
            if (result != null)
            {
                return(result);
            }
            else
            {
                string msg = Resources.GetString(RsId.NoXmlReaderInAssembly);
                msg = String.Format(msg, className, assem.GetName().Name);
                throw new SaxException(msg);
            }
        }
Esempio n. 33
0
 private void parseSimpleProperty(IXmlReader reader, SimpleProperty property)
 {
     property.Value = _reader.GetAttributeAsObject(Attributes.Value, property.Type);
 }
Esempio n. 34
0
 /// <summary>
 ///     Create a new XML writer.
 ///     <para>
 ///         Use the specified XML reader as the parent, and write
 ///         to the specified writer.
 ///     </para>
 /// </summary>
 /// <param name="xmlreader">
 ///     The parent in the filter chain, or null
 ///     for no parent.
 /// </param>
 /// <param name="writer">
 ///     The output destination, or null to use standard
 ///     output.
 /// </param>
 public XmlWriter(IXmlReader xmlreader, TextWriter writer) : base(xmlreader) {
   Init(writer);
 }
Esempio n. 35
0
 /// <summary>
 ///     Create a new XML writer.
 ///     <para>Use the specified XML reader as the parent.</para>
 /// </summary>
 /// <param name="xmlreader">
 ///     The parent in the filter chain, or null
 ///     for no parent.
 /// </param>
 public XmlWriter(IXmlReader xmlreader) : base(xmlreader) {
   Init(null);
 }
Esempio n. 36
0
 /* Initialize class - try to load the default SAX parser if there is one. */
 private void MainFormLoad(object sender, System.EventArgs e)
 {
     try {
     reader = SaxReaderFactory.CreateReader(null);
       }
       catch
       {
     // ignore exception
     reader = null;
       }
       if (reader != null) {
     Type readerType = reader.GetType();
     parserLbl.Text = readerType.FullName;
       }
       else
     parserLbl.Text = noParserLoaded;
       UpdateUI();
 }
Esempio n. 37
0
 private static IXmlReader LoadParser(string assemblyName, string readerName)
 {
     IXmlReader reader = null;
       if (assemblyName == null || assemblyName == String.Empty)
     reader = SaxReaderFactory.CreateReader(null);
       else {
     Assembly assem = null;
     if (File.Exists(assemblyName))
       assem = Assembly.LoadFrom(assemblyName);
     else
       assem = Assembly.Load(assemblyName);
     if (assem == null)
       throw new ApplicationException(
              String.Format("Assembly not found: {0}.", assemblyName));
     if (readerName == null || readerName == String.Empty)
       // we have only an assembly, so load whatever IXmlReader we can find
       reader = SaxReaderFactory.CreateReader(assem, null);
     else
       // class and assembly specified, we know exactly what we want
       reader = SaxReaderFactory.CreateReader(assem, readerName, null);
       }
       return reader;
 }
        protected DocumentMarkupType parseContentDocument_DTD(Project project, XmlDocument xmlDoc, TreeNode parentTreeNode, string filePath, out string dtdUniqueResourceId)
        {
            dtdUniqueResourceId = null;

            DocumentMarkupType docMarkupType = DocumentMarkupType.NA;

            //xmlNode.OwnerDocument
            string dtdID = xmlDoc.DocumentType == null ? string.Empty
            : !string.IsNullOrEmpty(xmlDoc.DocumentType.SystemId) ? xmlDoc.DocumentType.SystemId
            : !string.IsNullOrEmpty(xmlDoc.DocumentType.PublicId) ? xmlDoc.DocumentType.PublicId
            : xmlDoc.DocumentType.Name;

            string rootElemName = xmlDoc.DocumentElement.LocalName;

            if (dtdID == @"html" &&
                string.IsNullOrEmpty(xmlDoc.DocumentType.SystemId) &&
                string.IsNullOrEmpty(xmlDoc.DocumentType.PublicId))
            {
                dtdID         = @"html5";
                docMarkupType = DocumentMarkupType.XHTML5;
                DebugFix.Assert(rootElemName == @"html");
            }
            else if (dtdID.Contains(@"xhtml1")
                     //systemId.Contains(@"xhtml11.dtd")
                     //|| systemId.Contains(@"xhtml1-strict.dtd")
                     //|| systemId.Contains(@"xhtml1-transitional.dtd")
                     )
            {
                dtdID         = @"http://www.w3.org/xhtml-math-svg-flat.dtd";
                docMarkupType = DocumentMarkupType.XHTML;
                DebugFix.Assert(rootElemName == @"html");
            }
            else if (rootElemName == @"dtbook")
            {
                docMarkupType = DocumentMarkupType.DTBOOK;
            }
            else if (rootElemName == @"html")
            {
                dtdID         = @"html5";
                docMarkupType = DocumentMarkupType.XHTML5;
            }

            if (docMarkupType == DocumentMarkupType.NA)
            {
#if DEBUG
                Debugger.Break();
#endif
            }

            if (string.IsNullOrEmpty(dtdID))
            {
                return(docMarkupType);
            }

            if (!string.IsNullOrEmpty(dtdID) && !dtdID.StartsWith(@"http://"))
            {
                dtdID = @"http://www.daisy.org/" + dtdID;
            }

            bool needToLoadDTDManuallyToCheckMixedContentElements = docMarkupType == DocumentMarkupType.XHTML5;
            if (docMarkupType == DocumentMarkupType.DTBOOK)
            {
                XmlNode rootElement = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(xmlDoc, true, "book", null);
                DebugFix.Assert(rootElement != null);
                if (rootElement != null)
                {
                    XmlAttributeCollection attrs = rootElement.Attributes;
                    if (attrs != null)
                    {
                        XmlNode attr = attrs.GetNamedItem("space", XmlReaderWriterHelper.NS_URL_XML);
                        if (attr == null)
                        {
                            attr = attrs.GetNamedItem("xml:space", XmlReaderWriterHelper.NS_URL_XML);
                        }

                        if (attr != null && attr.Value == "preserve")
                        {
                            //Bookshare hack! :(
                            needToLoadDTDManuallyToCheckMixedContentElements = true;
                        }
                    }
                }
            }

            if (!needToLoadDTDManuallyToCheckMixedContentElements)
            {
                return(docMarkupType);
            }

            bool isHTML = docMarkupType == DocumentMarkupType.XHTML || docMarkupType == DocumentMarkupType.XHTML5;

#if ENABLE_DTDSHARP
            Stream dtdStream = LocalXmlUrlResolver.mapUri(new Uri(dtdID, UriKind.Absolute), out dtdUniqueResourceId);

            if (!string.IsNullOrEmpty(dtdUniqueResourceId))
            {
                DebugFix.Assert(dtdStream != null);

                List <string> list;
                m_listOfMixedContentXmlElementNames.TryGetValue(dtdUniqueResourceId, out list);

                if (list == null)
                {
                    if (dtdStream != null)
                    {
                        list = new List <string>();
                        m_listOfMixedContentXmlElementNames.Add(dtdUniqueResourceId, list);

                        initMixedContentXmlElementNamesFromDTD(dtdUniqueResourceId, dtdStream);
                    }
                    else
                    {
#if DEBUG
                        Debugger.Break();
#endif
                    }
                }
                else
                {
                    if (dtdStream != null)
                    {
                        dtdStream.Close();
                    }
                }
            }
            else
            {
#if DEBUG
                Debugger.Break();
#endif
            }
#else
            dtdUniqueResourceId = dtdID;

            List <string> list;
            m_listOfMixedContentXmlElementNames.TryGetValue(dtdUniqueResourceId, out list);

            if (list != null)
            {
                return(docMarkupType);
            }

            list = new List <string>();
            m_listOfMixedContentXmlElementNames.Add(dtdUniqueResourceId, list);

            IXmlReader reader = null;


            //string dll = @"SaxNET.dll";
            ////#if NET40
            ////                            dll = @"\SaxNET_NET4.dll";
            ////#endif
            //string appFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            //string dtdPath = Path.Combine(appFolder, dll);
            //Assembly assembly = Assembly.LoadFrom(dtdPath);
            //                            try
            //                            {
            //                                reader = SaxReaderFactory.CreateReader(assembly, null);
            //                            }
            //                            catch (Exception e)
            //                            {
            //#if DEBUG
            //                                Debugger.Break();
            //#endif
            //                            }

            bool useCSharpSaxImpl = IsRunning64(); // docMarkupType == DocumentMarkupType.XHTML5;
            if (useCSharpSaxImpl)
            {
                reader = new SaxDriver();
            }
            else
            {
                reader = new ExpatReader();
            }

            DebugFix.Assert(reader != null);
            if (reader == null)
            {
                return(docMarkupType);
            }
            //Type readerType = reader.GetType();

            reader.EntityResolver = new SaxEntityResolver();

            SaxErrorHandler errorHandler = new SaxErrorHandler();
            reader.ErrorHandler = errorHandler;


            if (reader is SaxDriver)
            {
                //"namespaces"
                try
                {
                    reader.SetFeature(Constants.NamespacesFeature, true);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debugger.Break();
#endif
                }

                //"namespace-prefixes"
                try
                {
                    reader.SetFeature(Constants.NamespacePrefixesFeature, true);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debugger.Break();
#endif
                }

                //"external-general-entities"
                try
                {
                    reader.SetFeature(Constants.ExternalGeneralFeature, true);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debugger.Break();
#endif
                }

                //"external-parameter-entities"
                try
                {
                    reader.SetFeature(Constants.ExternalParameterFeature, true);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debugger.Break();
#endif
                }

                //"xmlns-uris"
                try
                {
                    reader.SetFeature(Constants.XmlNsUrisFeature, true);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debugger.Break();
#endif
                }

                //"resolve-dtd-uris"
                try
                {
                    reader.SetFeature(Constants.ResolveDtdUrisFeature, true);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debugger.Break();
#endif
                }
            }


            if (reader is ExpatReader)
            {
                // http://xml.org/sax/features/namespaces
                try
                {
                    reader.SetFeature(Constants.NamespacesFeature, true);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debugger.Break();
#endif
                }

                // http://xml.org/sax/features/external-general-entities
                try
                {
                    reader.SetFeature(Constants.ExternalGeneralFeature, true);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debugger.Break();
#endif
                }

                // http://xml.org/sax/features/external-parameter-entities
                try
                {
                    reader.SetFeature(Constants.ExternalParameterFeature, true);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debugger.Break();
#endif
                }

                // http://xml.org/sax/features/resolve-dtd-uris
                try
                {
                    reader.SetFeature(Constants.ResolveDtdUrisFeature, true);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debugger.Break();
#endif
                }

                // http://xml.org/sax/features/lexical-handler/parameter-entities
                try
                {
                    reader.SetFeature(Constants.LexicalParameterFeature, true);
                }
                catch (Exception e)
                {
#if DEBUG
                    Debugger.Break();
#endif
                }

                if (false)
                {
                    try
                    {
                        reader.SetFeature("http://kd-soft.net/sax/features/skip-internal-entities",
                                          false);
                    }
                    catch (Exception e)
                    {
#if DEBUG
                        Debugger.Break();
#endif
                    }

                    try
                    {
                        reader.SetFeature(
                            "http://kd-soft.net/sax/features/parse-unless-standalone", true);
                    }
                    catch (Exception e)
                    {
#if DEBUG
                        Debugger.Break();
#endif
                    }

                    try
                    {
                        reader.SetFeature("http://kd-soft.net/sax/features/parameter-entities", true);
                    }
                    catch (Exception e)
                    {
#if DEBUG
                        Debugger.Break();
#endif
                    }

                    try
                    {
                        reader.SetFeature("http://kd-soft.net/sax/features/standalone-error", true);
                    }
                    catch (Exception e)
                    {
#if DEBUG
                        Debugger.Break();
#endif
                    }
                }

                // SUPPORTED, but then NOT SUPPORTED (deeper inside Expat C# wrapper code)

                //                                    // http://xml.org/sax/features/namespace-prefixes
                //                                    try
                //                                    {
                //                                        reader.SetFeature(Constants.NamespacePrefixesFeature, true);
                //                                    }
                //                                    catch (Exception e)
                //                                    {
                //#if DEBUG
                //                                        Debugger.Break();
                //#endif
                //                                    }

                //                                    // http://xml.org/sax/features/xmlns-uris
                //                                    try
                //                                    {
                //                                        reader.SetFeature(Constants.XmlNsUrisFeature, true);
                //                                    }
                //                                    catch (Exception e)
                //                                    {
                //#if DEBUG
                //                                        Debugger.Break();
                //#endif
                //                                    }
                //                                    // http://xml.org/sax/features/validation
                //                                    try
                //                                    {
                //                                        reader.SetFeature(Constants.ValidationFeature, true);
                //                                    }
                //                                    catch (Exception e)
                //                                    {
                //#if DEBUG
                //                                        Debugger.Break();
                //#endif
                //                                    }

                //                                    // http://xml.org/sax/features/unicode-normalization-checking
                //                                    try
                //                                    {
                //                                        reader.SetFeature(Constants.UnicodeNormCheckFeature, true);
                //                                    }
                //                                    catch (Exception e)
                //                                    {
                //#if DEBUG
                //                                        Debugger.Break();
                //#endif
                //                                    }


                // NOT SUPPORTED:


                // http://xml.org/sax/features/xml-1.1
                //                                    try
                //                                    {
                //                                        reader.SetFeature(Constants.Xml11Feature, true);
                //                                    }
                //                                    catch (Exception e)
                //                                    {
                //#if DEBUG
                //                                        Debugger.Break();
                //#endif
                //                                    }

                // http://xml.org/sax/features/xml-declaration
                //                                    try
                //                                    {
                //                                        reader.SetFeature(Constants.XmlDeclFeature, true);
                //                                    }
                //                                    catch (Exception e)
                //                                    {
                //#if DEBUG
                //                                        Debugger.Break();
                //#endif
                //                                    }

                // http://xml.org/sax/features/use-external-subset
                //                                    try
                //                                    {
                //                                        reader.SetFeature(Constants.UseExternalSubsetFeature, true);
                //                                    }
                //                                    catch (Exception e)
                //                                    {
                //#if DEBUG
                //                                        Debugger.Break();
                //#endif
                //                                    }

                // http://xml.org/sax/features/reader-control
                //                                    try
                //                                    {
                //                                        reader.SetFeature(Constants.ReaderControlFeature, true);
                //                                    }
                //                                    catch (Exception e)
                //                                    {
                //#if DEBUG
                //                                        Debugger.Break();
                //#endif
                //                                    }
            }

            SaxContentHandler handler = new SaxContentHandler(list);

            try
            {
                reader.DtdHandler = handler;
            }
            catch (Exception e)
            {
#if DEBUG
                Debugger.Break();
#endif
                errorHandler.AddMessage("Cannot set dtd handler: " + e.Message);
            }

            try
            {
                reader.ContentHandler = handler;
            }
            catch (Exception e)
            {
#if DEBUG
                Debugger.Break();
#endif
                errorHandler.AddMessage("Cannot set content handler: " + e.Message);
            }

            try
            {
                reader.LexicalHandler = handler;
            }
            catch (Exception e)
            {
#if DEBUG
                Debugger.Break();
#endif
                errorHandler.AddMessage("Cannot set lexical handler: " + e.Message);
            }

            try
            {
                reader.DeclHandler = handler;
            }
            catch (Exception e)
            {
#if DEBUG
                Debugger.Break();
#endif
                errorHandler.AddMessage("Cannot set declaration handler: " + e.Message);
            }

            string rootElementName = isHTML ? @"html" : @"dtbook";
            string dtdWrapper      = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE " + rootElementName + " SYSTEM \"" + dtdID + "\"><" + rootElementName + "></" + rootElementName + ">";
            //StringReader strReader = new StringReader(dtdWrapper);
            Stream      stream    = new MemoryStream(Encoding.UTF8.GetBytes(dtdWrapper));
            TextReader  txtReader = new StreamReader(stream, Encoding.UTF8);
            InputSource input     = new InputSource <TextReader>(txtReader, dtdID + "/////SYSID");
            input.Encoding = "UTF-8";
            input.PublicId = "??";

            reader.Parse(input);
#endif //ENABLE_DTDSHARP


            return(docMarkupType);
        }
Esempio n. 39
0
File: Theme.cs Progetto: drme/thw-ui
        /// <summary>
        /// Loads theme configuration from xml file.
        /// </summary>
        /// <param name="reader">xml document containing theme configuration.</param>
        private void Load(IXmlReader reader)
        {
            IXmlElement root = reader.RootElement;

            if (null != root)
            {
                this.skinned = UIUtils.FromString(root.GetAttributeValue("skinned", ""), this.skinned);
                this.defaultFontName = root.GetAttributeValue("defaultfont", this.defaultFontName);

                foreach (IXmlElement element in root.Elements)
                {
                    switch (element.Name)
                    {
                        case "colors":
                            this.Colors.LoadColors(element);
                            break;
                        case "menu":
                            this.Menu.LoadMenu(element, this.Colors);
                            break;
                        case "borders":
                        case "controls":
                            LoadBorders(element);
                            break;
                        case "window":
                            this.Window.LoadWindow(element);
                            break;
                        default:
                            throw new NotSupportedException("Unknown tag: " + element.Name);
                    }
                }
            }
        }
Esempio n. 40
0
 public TlgMapper(IXmlReader xmlReader, ITimHeaderMapper timHeaderMapper, IBinaryWriter binaryWriter)
 {
     _xmlReader       = xmlReader;
     _timHeaderMapper = timHeaderMapper;
     _binaryWriter    = binaryWriter;
 }
Esempio n. 41
0
        /// <summary>
        /// This takes the collected test information, creates the parser and attempts to run the
        /// test. In general, it is a safe process and output will be written to the output stream.
        /// The RunTest() function attempts to configure the parser based on the requirements of
        /// the test. It also increments the testCount, unsupportedCount and failCount (if applicable).
        /// </summary>
        public void RunTest(IXmlReader parser)
        {
            bool expectFatalError = true;
              bool expectError = true;
              bool optionalFatalError = false;
              bool optionalError = false;

              // Check if this matches the testPattern
              if (testPattern != null)
            if (!Regex.IsMatch(currId, testPattern))
              return;

              try
              {
            // All wrapped in a try
            try {
              Uri f = new Uri(new Uri(testLoc.SystemId), currUri);

              writer.WriteLine("<TEST ENTITIES='" + currEntities + "' " +
            "ID='" + currId + "' "+
            "NAMESPACES='" + currNamespaces + "' "+
            "RECOMMENDATION='" + currRecommendation + "' "+
            "SECTIONS='" + currSections + "' "+
            "TYPE='" + currType + "' "+
            "URI='" + f.AbsoluteUri + "' "+
            "VERSION='" + currVersion + "'>");
              writer.WriteLine("<message>" + Escape(currContent.ToString()) + "</message>");

              // Check whether or not NAMESPACES are required
              if ("yes".Equals(currNamespaces)) {
            if (!supportsNamespaces) {
              writer.WriteLine("<unsupported>Namespace processing</unsupported>");
              unsupportedCount++;
              expectFatalError = false;
              expectError = false;
              fatalCount = 0;
              errorCount = 0;
              warningCount = 0;
              return;
            } else {
              SetFeature(SaxConsts.NamespacesFeature, parser, true);
              SetFeature(SaxConsts.NamespacePrefixesFeature, parser, false);
            }
              } else {
            SetFeature(SaxConsts.NamespacesFeature, parser, false);
            SetFeature(SaxConsts.NamespacePrefixesFeature, parser, true);
              }

              // Check whether or not ENTITIES are required
              if ("both".Equals(currEntities)) {
            if (!supportsGeneralEntityResolution || !supportsParameterEntityResolution) {
              writer.WriteLine("<unsupported>Entity resolution</unsupported>");
              unsupportedCount++;
              expectFatalError = false;
              expectError = false;
              fatalCount = 0;
              errorCount = 0;
              warningCount = 0;
              return;
            } else {
              SetFeature(SaxConsts.ExternalGeneralFeature, parser, true);
              SetFeature(SaxConsts.ExternalParameterFeature, parser, true);
            }
              } else if ("parameter".Equals(currEntities)) {
            if (!supportsParameterEntityResolution) {
              writer.WriteLine("<unsupported>Parameter entity resolution</unsupported>");
              unsupportedCount++;
              expectFatalError = false;
              expectError = false;
              fatalCount = 0;
              errorCount = 0;
              warningCount = 0;
              return;
            } else {
              SetFeature(SaxConsts.ExternalParameterFeature, parser, true);
            }
              } else if ("general".Equals(currEntities)) {
            if (!supportsGeneralEntityResolution) {
              writer.WriteLine("<unsupported>General entity resolution</unsupported>");
              unsupportedCount++;
              expectFatalError = false;
              expectError = false;
              fatalCount = 0;
              errorCount = 0;
              warningCount = 0;
              return;
            } else {
              SetFeature(SaxConsts.ExternalGeneralFeature, parser, true);
            }
              }

              // Check for the RECOMMENDATION
              if ("1.1".Equals(currVersion) || "XML1.1".Equals(currRecommendation) || "NS1.1".Equals(currRecommendation)) {
            if (!supportsXml11) {
              writer.WriteLine("<unsupported>XML 1.1</unsupported>");
              unsupportedCount++;
              expectFatalError = false;
              expectError = false;
              fatalCount = 0;
              errorCount = 0;
              warningCount = 0;
              return;
            } else {
              SetFeature(SaxConsts.Xml11Feature, parser, true);
            }
              }

              // Check the TYPE
              if ("valid".Equals(currType))
              {
            expectFatalError = false;
            expectError = false;
            if (supportsValidation)
              SetFeature(SaxConsts.ValidationFeature, parser, true);
              }
              else if ("invalid".Equals(currType))
              {
            expectFatalError = false;
            if (supportsValidation)
            {
              expectError = true;
              SetFeature(SaxConsts.ValidationFeature, parser, true);
            }
            else
            {
              expectError = false;
              // This is debateable, a non-validating parser may or may not raise an Error
              optionalError = true;
            }
              }
              else if ("not-wf".Equals(currType))
              {
            // no validation
            expectFatalError = true;
            expectError = false;
            optionalError = true;
              }
              else if ("error".Equals(currType))
              {
            // not required
            expectFatalError = false;
            expectError = false;
            optionalFatalError = true;
            optionalError = true;
              }

              // reset error count
              fatalCount = 0;
              errorCount = 0;
              warningCount = 0;

              // Try to parse
              if (saxGenerate == null)
              {
            parser.ErrorHandler = this;
            parser.Parse(f.AbsoluteUri);
              }
              else
              {
            DirectoryInfo confDir = new DirectoryInfo(saxGenerate);
            Uri baseUri = new Uri(testLoc.SystemId);
            if (!baseUri.IsFile)
              throw new ApplicationException("Not a file URI");
            DirectoryInfo baseDir = new DirectoryInfo(baseUri.LocalPath);
            string basePath = "";
            while (baseDir != null && baseDir.Name != "xmlconf") {
              basePath = Path.Combine(baseDir.Name, basePath);
              baseDir = baseDir.Parent;
            }
            string confPath = Path.Combine(confDir.FullName, basePath);
            confPath = Path.GetDirectoryName(confPath);
            FileInfo confFile = new FileInfo(Path.Combine(confPath, currUri));
            Directory.CreateDirectory(confFile.DirectoryName);
            StreamWriter sw = new StreamWriter(confFile.FullName);
            sw.NewLine = "\n";
            XmlTextWriter confWriter = new XmlTextWriter(sw);
            confWriter.Formatting = Formatting.Indented;
            confWriter.Indentation = 4;
            ConformanceReportHandler handler = new ConformanceReportHandler(confWriter, this);
            handler.Initialize();
            parser.ContentHandler = handler;
            parser.DtdHandler = handler;
            parser.ErrorHandler = handler;
            parser.EntityResolver = handler;
            try
            {
              parser.Parse(f.AbsoluteUri);
            }
            catch (SaxException)
            {
            }
            catch (IOException)
            {
            }
            catch (Exception ex)
            {
              confWriter.WriteStartElement("bug");
              confWriter.WriteAttributeString("reason", "Parser should only throw SAXExceptions");
              confWriter.WriteAttributeString("type", ex.GetType().Name);
              confWriter.WriteString(Escape(ex.Message));
              confWriter.WriteEndElement();
            }
            handler.Finish();

            // Close the writer
            confWriter.Close();

            // Now, let's just go ahead and make the comparisson while we are at it
            if (saxExpected != null)
            {
              DirectoryInfo expectedDir = new DirectoryInfo(saxExpected);
              string expectedPath = Path.Combine(expectedDir.FullName, basePath);
              expectedPath = Path.GetDirectoryName(expectedPath);
              FileInfo expectedFile = new FileInfo(Path.Combine(expectedPath, currUri));
              ResultComparer rc = new ResultComparer();
              string confError = "";
              bool confPassed = rc.compare(expectedFile.FullName, confFile.FullName, out confError);
              rc.makeResultDoc(f.LocalPath, expectedFile.FullName, confFile.FullName,
                Escape(currContent.ToString()), currId, confPassed, confError);

              writer.WriteLine("<conformance>");
              if (confPassed)
                writer.WriteLine("<pass>true</pass>");
              else
              {
                writer.WriteLine("<pass>false</pass>");
                conformanceFailCount++;
              }
              writer.WriteLine("<actual>" + confFile.FullName + "</actual>");
              writer.WriteLine("<expected>" + expectedFile.FullName + "</expected>");
              writer.WriteLine("<output>" + Path.ChangeExtension(confFile.FullName, ".html") + "</output>");
              writer.WriteLine("</conformance>");

            }
              }

            } catch (Exception e) {
              writer.WriteLine("<exception>" + Escape(e.Message) + "</exception>");
              fatalCount++;
            }
              } finally {
            if ((((expectError || optionalError) && errorCount > 0) ||
             (!expectError && errorCount == 0)) &&
            (((expectFatalError || optionalFatalError) && fatalCount > 0) ||
             (!expectFatalError && fatalCount == 0))) {
              writer.WriteLine("<pass>true</pass>");
              passCount++;
            } else {
              writer.WriteLine("<pass>false</pass>");
              failCount++;
            }
            writer.WriteLine("</TEST>");
              }
        }
Esempio n. 42
0
 /// <summary>
 /// This creates the parser and attempts to set features that will be needed throughout the
 /// tests. The results are stored in booleans so that the features don't need to be rechecked
 /// for each test.
 /// </summary>
 public void PrepareTest(IXmlReader parser)
 {
     startTime = DateTime.Now;
       passCount = 0;
       failCount = 0;
       conformanceFailCount = 0;
       unsupportedCount = 0;
       writer.WriteLine("<?xml version=\"1.0\"?>");
       writer.WriteLine("<?xml-stylesheet href=\"xmlconf-results.xsl\" type=\"text/xsl\"?>");
       writer.WriteLine("<results>");
       writer.WriteLine("  <features>");
       // Try to get/set the required features
       supportsNamespaces = TryFeature(SaxConsts.NamespacesFeature, parser);
       supportsValidation = TryFeature(SaxConsts.ValidationFeature, parser);
       supportsXml11 = TryFeature(SaxConsts.Xml11Feature, parser);
       supportsParameterEntityResolution =
     TryFeature(SaxConsts.ExternalParameterFeature, parser);
       supportsGeneralEntityResolution =
     TryFeature(SaxConsts.ExternalGeneralFeature, parser);
       // Close out the features Xml
       writer.WriteLine("  </features>");
 }
Esempio n. 43
0
 ///<summary>
 ///</summary>
 ///<param name = "reader"></param>
 public XmlPropertyDeserializer(IXmlReader reader)
 {
     _reader = reader;
 }
Esempio n. 44
0
 /// <summary>
 /// Handles setting the feature.
 /// </summary>
 public void SetFeature(string feature, IXmlReader parser, bool flag)
 {
     if (parser.GetFeature(feature) != flag)
     parser.SetFeature(feature, flag);
 }
Esempio n. 45
0
 /// <summary>
 /// Handles the output of the results of trying to set the feature. Returns true if the
 /// feature can be set without exception.
 /// </summary>
 public bool TryFeature(string feature, IXmlReader parser)
 {
     int slashPos = feature.LastIndexOf('/');
       string featureName = feature.Substring(slashPos + 1);
       try {
     if (!parser.GetFeature(feature))
       parser.SetFeature(feature, true);
     writer.WriteLine("    <" + featureName + ">true</" + featureName + ">");
     return true;
       } catch {
     writer.WriteLine("    <" + featureName + ">false</" + featureName + ">");
     return false;
       }
 }
Esempio n. 46
0
 ///<summary>
 ///</summary>
 ///<param name = "reader"></param>
 public XmlPropertyDeserializer(IXmlReader reader)
 {
     _reader = reader;
 }
Esempio n. 47
0
 /// <summary>
 /// Check and display the value of a feature.
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="name"></param>
 private static void checkFeature(IXmlReader reader, String name) {
   try {
     Console.WriteLine("  " + name + " = " + reader.GetFeature(name));
   } catch (SAXNotRecognizedException e) {
     Console.WriteLine("XMLReader does not recognize feature " + name);
   } catch (SAXNotSupportedException e) {
     Console.WriteLine("XMLReader recognizes feature " + name + " but does not support checking its value");
   }
 }
Esempio n. 48
0
 public ChunkHandler(IXmlReader reader,
     TreeView tv,
     int chunkSize,
     int activeLevel)
     : base(tv)
 {
     this.reader = reader;
     this.chunkSize = chunkSize;
     this.activeLevel = activeLevel;
     elmCount = chunkSize;
 }
Esempio n. 49
0
 public TestSuite(InputSource input, Stream output, string testPattern, IXmlReader reader, string saxGenerate, string saxExpected, bool console)
 {
     this.reader = reader;
       this.saxGenerate = saxGenerate;
       this.saxExpected = saxExpected;
       this.console = console;
       this.input = input;
       this.output = output;
       this.testPattern = testPattern;
       this.writer = new StreamWriter(output);
       writer.AutoFlush = true;
       // Test features and properties
       PrepareTest(reader);
       // Set the reader for the test document and parse
       reader.ContentHandler = this;
       reader.Parse(input);
       // Write the end
       FinalizeTest();
 }
Esempio n. 50
0
 public GarminFplService(IXmlReader <GarminFpl> xmlReader)
 {
     _xmlReader = xmlReader.MustNotBeNull(nameof(xmlReader));
 }
 private void parseSimpleProperty(IXmlReader reader, SimpleProperty property)
 {
     property.Value = _reader.GetAttributeAsObject(Attributes.Value, property.Type);
 }
Esempio n. 52
0
 public TlgMapper(IXmlReader xmlReader, ITimHeaderMapper timHeaderMapper, IBinaryWriter binaryWriter)
 {
     _xmlReader = xmlReader;
     _timHeaderMapper = timHeaderMapper;
     _binaryWriter = binaryWriter;
 }
 ///<summary>
 ///</summary>
 ///<param name = "reader"></param>
 public XmlPropertyDeserializer(IXmlReader reader, SimpleTypes st)
 {
     _reader = reader;
     _simpleTypes = st;
 }
Esempio n. 54
0
 public object Parse(IXmlReader stream)
 {
     var xamlProtoNodes = protoParser.Parse(stream);
     var xamlNodes = parser.Parse(xamlProtoNodes);
     return Parse(xamlNodes);
 }
Esempio n. 55
0
 public AttributeParser(IXmlReader reader)
 {
     this.reader = reader;
 }
Esempio n. 56
0
 public AttributeParser(IXmlReader reader)
 {
     this.reader = reader;
 }
Esempio n. 57
0
 /* Load an IXmlReader instance. */
 private void ParserBtnClick(object sender, System.EventArgs e)
 {
     CheckNotSuspended();
       Assembly assem = null;
       Type readerType = null;
       // get type and assembly for existing reader and display it
       if (reader != null) {
     readerType = reader.GetType();
     assem = Assembly.GetAssembly(readerType);
       }
       PickDlg pickDlg = new PickDlg();
       if (assem != null) {
     pickDlg.ParserAssembly = assem.Location;
     pickDlg.ParserClass = readerType.FullName;
       }
       if (pickDlg.ShowDialog() != DialogResult.OK)
     return;
       // if we picked an assembly and (optionally) a class, let's load them
       string assemName = pickDlg.ParserAssembly;
       assem = null;
       if (File.Exists(assemName))
     assem = Assembly.LoadFrom(assemName);
       else
     assem = Assembly.Load(assemName);
       if (assem == null)
     throw new ApplicationException(
            String.Format("Assembly not found: {0}.", assemName));
       string readerClass = pickDlg.ParserClass;
       IXmlReader newReader = null;
       if (readerClass == null || readerClass == String.Empty)
     // we have only an assembly, so load whatever IXmlReader we can find
     newReader = SaxReaderFactory.CreateReader(assem, null);
       else
     // class and assembly specified, we know exactly what we want
     newReader = SaxReaderFactory.CreateReader(assem, readerClass, null);
       if (newReader != null) {
     reader = newReader;
     readerType = newReader.GetType();
     parserLbl.Text = readerType.FullName;
     UpdateUI();
       }
       else
     throw new ApplicationException(
         String.Format("Cannot create parser {0}.", readerClass));
 }