コード例 #1
0
        /// <summary>
        /// The read structure workspace.
        /// </summary>
        /// <param name="file">
        /// The file.
        /// </param>
        /// <param name="test">
        /// The test.
        /// </param>
        protected static void ReadStructureMutable(string file, Action<ISdmxObjects> test)
        {
            IStructureParsingManager parsingManager = new StructureMutableParsingManager();
            var sw = new Stopwatch();
            sw.Start();
            ISdmxObjects structureBeans;
            using (IReadableDataLocation fileReadableDataLocation = new FileReadableDataLocation(file))
            {
                IStructureWorkspace structureWorkspace = parsingManager.ParseStructures(fileReadableDataLocation);
                Assert.NotNull(structureWorkspace);
                structureBeans = structureWorkspace.GetStructureObjects(false);
                Assert.NotNull(structureBeans);
            }

            sw.Stop();
            Trace.WriteLine(string.Format(CultureInfo.InvariantCulture, "StructureParser : Reading {0} took {1}", file, sw.Elapsed));
            test(structureBeans);
        }
コード例 #2
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// Could not load Structure objects
        /// </exception>
        public static void Main(string[] args)
        {
            // 1. Initialize the StructureMutableParsingManager. This implementation supports only 2.0. It also supports the SdmxXmlStream
            IStructureParsingManager parsingManager = new StructureMutableParsingManager();

            // 2. Create a SdmxXmlStream. It provides a non-buffered, forward only access to an existing XmlReader or XmlWriter. 
            using (var stream = File.OpenRead("ESTAT_CPI_v1.0.xml"))
            using (var reader = XMLParser.CreateSdmxMlReader(stream, SdmxSchemaEnumType.VersionTwo))
            using (var dataLocation = new SdmxXmlStream(reader, MessageEnumType.Structure, SdmxSchemaEnumType.VersionTwo, RegistryMessageEnumType.Null))
            {
                // 3. Get the IStructureWorkspace
                IStructureWorkspace structureWorkspace = parsingManager.ParseStructures(dataLocation);

                // 4. Get the ISdmxObjects with resolving cross-references.
                ISdmxObjects structureObjects = structureWorkspace.GetStructureObjects(false);

                if (structureObjects == null)
                {
                    throw new InvalidOperationException("Could not load Structure objects");
                }
            }
        }