当前位置: 首页>>代码示例>>C#>>正文


C# Io.FileReadableDataLocation类代码示例

本文整理汇总了C#中Org.Sdmxsource.Util.Io.FileReadableDataLocation的典型用法代码示例。如果您正苦于以下问题:C# FileReadableDataLocation类的具体用法?C# FileReadableDataLocation怎么用?C# FileReadableDataLocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileReadableDataLocation类属于Org.Sdmxsource.Util.Io命名空间,在下文中一共展示了FileReadableDataLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestWriteStructures

        public void TestWriteStructures(string file)
        {
            var structureReader = new StructureParsingManager();
            var fileInfo = new FileInfo(file);
            IStructureWorkspace structureWorkspace;
            using (var readable = new FileReadableDataLocation(fileInfo))
            {
                structureWorkspace = structureReader.ParseStructures(readable);
            }

            ISdmxObjects structureBeans = structureWorkspace.GetStructureObjects(false);

            string output = string.Format(CultureInfo.InvariantCulture, "test-sdmxv2.1-{0}", fileInfo.Name);
            var writtingManager = new StructureWriterManager();
            using (var outputStream = new FileStream(output, FileMode.Create))
            {
                writtingManager.WriteStructures(structureBeans, new SdmxStructureFormat(StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV21StructureDocument)), outputStream);
            }

            using (var readable = new FileReadableDataLocation(output))
            {
                XMLParser.ValidateXml(readable, SdmxSchemaEnumType.VersionTwoPointOne);
                var structures = structureReader.ParseStructures(readable);
                Assert.NotNull(structures);
            }
        }
开发者ID:SDMXISTATFRAMEWORK,项目名称:ISTAT_ENHANCED_SDMXRI_WS,代码行数:26,代码来源:TestSdmxV20ToV21.cs

示例2: Main

        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        public static void Main(string[] args)
        {
            IQueryParsingManager manager = new QueryParsingManager(SdmxSchemaEnumType.VersionTwo);
            IQueryWorkspace workspace;
            using (IReadableDataLocation location = new FileReadableDataLocation("QueryStructureRequest.xml"))
            {
                workspace = manager.ParseQueries(location);
            }

            if (workspace != null)
            {
                Console.WriteLine("Is Resolve references : {0}", workspace.ResolveReferences);
                Console.WriteLine("Has Structure Queries : {0}", workspace.HasStructureQueries());
                if (workspace.HasStructureQueries())
                {
                    foreach (IStructureReference simpleStructureQuery in workspace.SimpleStructureQueries)
                    {
                        IMaintainableRefObject reference = simpleStructureQuery.MaintainableReference;
                        Console.WriteLine(
                            "Requested a {0}\n\tAgency ID: {1}\n\tId: {2}\n\tVersion: {3}", 
                            simpleStructureQuery.MaintainableStructureEnumType, 
                            reference.HasAgencyId() ? reference.AgencyId : "(none)", 
                            reference.HasMaintainableId() ? reference.MaintainableId : "(none)", 
                            reference.HasVersion() ? reference.Version : "(none)");
                    }
                }
            }
        }
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:34,代码来源:ReUsingQueryParsingManager.cs

示例3: Test

 public void Test(string file, bool expectedResult)
 {
     using (var reader = new FileReadableDataLocation(file))
     {
         Assert.AreEqual(expectedResult, XmlUtil.IsXML(reader));
     }
 }
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:7,代码来源:TestXmlUtil.cs

示例4: Test

 public void Test(string file)
 {
     using (var readable = new FileReadableDataLocation(file))
     {
         Assert.IsTrue(readable.InputStream.ReadByte() > 0);
         Assert.AreNotSame(readable.InputStream, readable.InputStream);
     }
 }
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:8,代码来源:TestFileReadableDataLocation.cs

示例5: TestXSOutput

        public void TestXSOutput(string filePath)
        {
            IList<IDataQuery> dataQueries;
            using (IReadableDataLocation dataLocation = new FileReadableDataLocation(filePath))
            {
                dataQueries = this._dataQueryParseManager.BuildDataQuery(dataLocation, this._retrievalManager);
            }

            Assert.IsNotEmpty(dataQueries);
            var dataQuery = dataQueries.First();

            var outputFileName = string.Format("{0}-out.xml", filePath);
            using (XmlWriter writer = XmlWriter.Create(outputFileName))
            {
                var dataWriter = new CrossSectionalWriterEngine(writer, SdmxSchema.GetFromEnum(SdmxSchemaEnumType.VersionTwo));

                this._dataRetrieval.GetData(dataQuery, dataWriter);
                writer.Flush();
            }

            var fileInfo = new FileInfo(outputFileName);
            Assert.IsTrue(fileInfo.Exists);
            var dsd = dataQuery.DataStructure as ICrossSectionalDataStructureObject;
            Assert.NotNull(dsd);
            using (var fileStream = fileInfo.OpenRead())
            using (var reader = XmlReader.Create(fileStream))
            {
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            {
                                var localName = reader.LocalName;
                                switch (localName)
                                {
                                    case "DataSet":
                                        AssertDimensionsAreMapped(dsd.GetCrossSectionalAttachDataSet(true, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dimension)), reader);
                                        break;
                                    case "Section":
                                        AssertDimensionsAreMapped(dsd.GetCrossSectionalAttachSection(true, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dimension)), reader);

                                        break;
                                    case "Group":
                                        AssertDimensionsAreMapped(dsd.GetCrossSectionalAttachGroup(true, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dimension)), reader);

                                        break;
                                    case "OBS_VALUE":
                                        AssertDimensionsAreMapped(dsd.GetCrossSectionalAttachObservation(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dimension)), reader);
                                        break;
                                }
                            }

                            break;
                    }
                }
            }
        }
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:58,代码来源:TestXS.cs

示例6: TestParseQueries

 public void TestParseQueries(string testFile)
 {
     var manager = new CustomQueryParseManager(SdmxSchemaEnumType.VersionTwo);
     using (var readable = new FileReadableDataLocation(testFile))
     {
         var result = manager.ParseQueries(readable);
         Assert.IsNotEmpty(result.SimpleStructureQueries);
     }
 }
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:9,代码来源:TestCustomQueryParseManager.cs

示例7: TestQueryParserManagerV20

 public void TestQueryParserManagerV20(string file)
 {
     using (var fileReadableDataLocation = new FileReadableDataLocation(file))
     {
         IQueryParsingManager queryParsingManager = new QueryParsingManager(SdmxSchemaEnumType.VersionTwo);
         IQueryWorkspace queryWorkspace = queryParsingManager.ParseQueries(fileReadableDataLocation);
         Assert.IsNotNull(queryWorkspace);
         Assert.IsNotEmpty(queryWorkspace.SimpleStructureQueries);
     }
 }
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:10,代码来源:TestsQueryParsingManager.cs

示例8: TestBuild

        public void TestBuild()
        {
            IStructureParsingManager manager = new StructureParsingManager();
            IDataQueryParseManager queryParseManager = new DataQueryParseManager(SdmxSchemaEnumType.VersionTwoPointOne);
            IComplexDataQueryBuilderManager dataQueryBuilderManager = new ComplexDataQueryBuilderManager(new ComplexDataQueryFactoryV21());
            
            IDataflowObject dataFlow;
            IDataStructureObject dsd;
            using (var readable = new FileReadableDataLocation("tests/V21/Structure/test-sdmxv2.1-ESTAT+SSTSCONS_PROD_M+2.0.xml"))
            {
                var structureWorkspace = manager.ParseStructures(readable);
                dataFlow = structureWorkspace.GetStructureObjects(false).Dataflows.First();
            }

            using (var readable = new FileReadableDataLocation("tests/V21/Structure/test-sdmxv2.1-ESTAT+STS+2.0.xml"))
            {
                var structureWorkspace = manager.ParseStructures(readable);
                dsd = structureWorkspace.GetStructureObjects(false).DataStructures.First();
            }

            ISet<IComplexDataQuerySelection> sections = new HashSet<IComplexDataQuerySelection>();
            var freqCriteria = new ComplexDataQuerySelectionImpl("FREQ", new IComplexComponentValue[] { new ComplexComponentValueImpl("M", OrderedOperator.GetFromEnum(OrderedOperatorEnumType.Equal), SdmxStructureEnumType.Dimension), new ComplexComponentValueImpl("A", OrderedOperator.GetFromEnum(OrderedOperatorEnumType.NotEqual), SdmxStructureEnumType.Dimension), new ComplexComponentValueImpl("B", OrderedOperator.GetFromEnum(OrderedOperatorEnumType.Equal), SdmxStructureEnumType.Dimension) });
            sections.Add(freqCriteria);
            var adjustmentCriteria = new ComplexDataQuerySelectionImpl("ADJUSTMENT", new IComplexComponentValue[] { new ComplexComponentValueImpl("01", OrderedOperator.GetFromEnum(OrderedOperatorEnumType.NotEqual), SdmxStructureEnumType.Dimension) });
            sections.Add(adjustmentCriteria);
            var titleCriteria = new ComplexDataQuerySelectionImpl(
                "TITLE", 
                new IComplexComponentValue[] { new ComplexComponentValueImpl("PAOKARA", TextSearch.GetFromEnum(TextSearchEnumType.Contains), SdmxStructureEnumType.DataAttribute),  new ComplexComponentValueImpl("ARIS", TextSearch.GetFromEnum(TextSearchEnumType.DoesNotContain), SdmxStructureEnumType.DataAttribute), });
            sections.Add(titleCriteria);
            OrderedOperator equalOperator = OrderedOperator.GetFromEnum(OrderedOperatorEnumType.Equal);
            var dateFrom = new SdmxDateCore("2000-01");
            var dateFromOperator = OrderedOperator.GetFromEnum(OrderedOperatorEnumType.GreaterThanOrEqual);
            var primaryMeasureValue = new ComplexComponentValueImpl("200.20", OrderedOperator.GetFromEnum(OrderedOperatorEnumType.GreaterThan), SdmxStructureEnumType.PrimaryMeasure);
            ICollection<IComplexDataQuerySelectionGroup> collection = new[] { new ComplexDataQuerySelectionGroupImpl(sections, dateFrom, dateFromOperator, null, equalOperator, new HashSet<IComplexComponentValue> { primaryMeasureValue }) };

            var complexDataQueryImpl = new ComplexDataQueryImpl(
                null, 
                null, 
                null, 
                dsd, 
                dataFlow, 
                null, 
                null, 
                0, 
                null, 
                false, 
                null, 
                DimensionAtObservation.GetFromEnum(DimensionAtObservationEnumType.Time).Value, 
                false, 
                DataQueryDetail.GetFromEnum(DataQueryDetailEnumType.Full), 
                collection);

            var dataQuery = this._builder.Build(complexDataQueryImpl);
            Assert.NotNull(dataQuery);
        }
开发者ID:SDMXISTATFRAMEWORK,项目名称:ISTAT_ENHANCED_SDMXRI_WS,代码行数:55,代码来源:TestComplexDataQuery2DataQueryBuilder.cs

示例9: TestSDMXv20

        public void TestSDMXv20(string queryFile)
        {
            IDataQuery query;
            using (IReadableDataLocation dataLocation = new FileReadableDataLocation(queryFile))
            {
                query = this._dataQueryParseManager.BuildDataQuery(dataLocation, this._retrievalManager).First();
            }
            
            var outputFileName = string.Format("{0}-out.xml", queryFile);

            using (XmlWriter writer = XmlWriter.Create(outputFileName, new XmlWriterSettings() {Indent = true}))
            {
                var compactWriter = new CompactDataWriterEngine(writer, SdmxSchema.GetFromEnum(SdmxSchemaEnumType.VersionTwo));
                this._dataRetrievalRest.GetData(query, compactWriter);
            }
            
            var selectionGroup = query.SelectionGroups.First();

            var fileInfo = new FileInfo(outputFileName);
            Assert.IsTrue(fileInfo.Exists);
            using (var fileStream = fileInfo.OpenRead())
            using (var reader = XmlReader.Create(fileStream))
            {
                TimeFormat freqValue = TimeFormat.GetFromEnum(TimeFormatEnumType.Null);
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            {
                                var localName = reader.LocalName;
                                if (localName.Equals("Series"))
                                {
                                    Assert.IsTrue(reader.HasAttributes);
                                    freqValue = TimeFormat.GetTimeFormatFromCodeId(reader.GetAttribute("FREQ"));
                                }
                                else if (localName.Equals("Obs"))
                                {
                                    Assert.NotNull(freqValue);
                                    Assert.IsTrue(reader.HasAttributes);
                                    var dateStr = reader.GetAttribute(DimensionObject.TimeDimensionFixedId);
                                    ISdmxDate date = new SdmxDateCore(dateStr);
                                    var dateFrom = new SdmxDateCore(new SdmxDateCore(selectionGroup.DateFrom.Date, freqValue).DateInSdmxFormat);
                                    var dateTo = new SdmxDateCore(new SdmxDateCore(selectionGroup.DateTo.Date, freqValue).DateInSdmxFormat);
                                    Assert.GreaterOrEqual(date.Date, dateFrom.Date);
                                    Assert.LessOrEqual(date.Date, dateTo.Date);
                                }
                            }

                            break;
                    }
                }
            }
        }
开发者ID:SDMXISTATFRAMEWORK,项目名称:ISTAT_ENHANCED_SDMXRI_WS,代码行数:54,代码来源:TestTimeRange.cs

示例10: TestParseSdmxFooterMessage

 public void TestParseSdmxFooterMessage(string fileName, string code, Severity severity, string firstText)
 {
     using (IReadableDataLocation dataLocation = new FileReadableDataLocation(fileName))
     {
         var sdmxFooterMessage = SdmxMessageUtilExt.ParseSdmxFooterMessage(dataLocation);
         Assert.IsNotNull(sdmxFooterMessage);
         Assert.AreEqual(sdmxFooterMessage.Code, code);
         Assert.AreEqual(sdmxFooterMessage.Severity, severity); 
         Assert.IsNotEmpty(sdmxFooterMessage.FooterText);
         Assert.AreEqual(firstText, sdmxFooterMessage.FooterText.First().Value);
     }
 }
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:12,代码来源:TestSdmxMessageUtilExt.cs

示例11: TestReadableDataLocationCtor

 public void TestReadableDataLocationCtor(string file)
 {
     using (var readable = new FileReadableDataLocation(file))
     {
         using (var sdmxXmlStream = new SdmxXmlStream(readable))
         {
             Assert.IsTrue(sdmxXmlStream.HasReader);
             Assert.IsNotNull(sdmxXmlStream.Reader);
             Assert.AreEqual(MessageEnumType.Structure, sdmxXmlStream.MessageType);
             Assert.AreEqual(SdmxSchemaEnumType.VersionTwo, sdmxXmlStream.SdmxVersion);
             Assert.AreEqual(RegistryMessageEnumType.Null, sdmxXmlStream.RegistryType);
         }
     }
 }
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:14,代码来源:TestSdmxXmlStream.cs

示例12: TestComposites

 public void TestComposites(string file)
 {
     var structureParsing = new StructureParsingManager(SdmxSchemaEnumType.VersionTwo);
     using (var readable = new FileReadableDataLocation(file))
     {
         IStructureWorkspace structureWorkspace = structureParsing.ParseStructures(readable);
         ISdmxObjects objects = structureWorkspace.GetStructureObjects(false);
         foreach (IMaintainableObject maintainableObject in objects.GetAllMaintainables())
         {
             ISet<ISdmxObject> sdmxObjects = maintainableObject.Composites;
             Assert.IsNotEmpty(sdmxObjects);
         }
     }
 }
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:14,代码来源:TestSdmxObjectCore.cs

示例13: TestBuildStructureQuery

        public void TestBuildStructureQuery(string testFile)
        {
            var manager = new CustomQueryParseManager(SdmxSchemaEnumType.VersionTwo);

            IQueryWorkspace result;
            using (var readable = new FileReadableDataLocation(testFile))
            {
                result = manager.ParseQueries(readable);
            }

            var builderManager = new QueryStructureRequestBuilderManager(new HeaderImpl("TEST", "TEST"));
            var document = builderManager.BuildStructureQuery(result.SimpleStructureQueries, new QueryStructureRequestFormat(), result.ResolveReferences); 
            Assert.NotNull(document);
        }
开发者ID:SDMXISTATFRAMEWORK,项目名称:ISTAT_ENHANCED_SDMXRI_WS,代码行数:14,代码来源:TestQueryStructureRequestBuilderManager.cs

示例14: readStructures

		public void readStructures(String structureFile, SdmxSchemaEnumType schema) {
			IReadableDataLocation rdl = new FileReadableDataLocation(structureFile);
			spm = new StructureParsingManager(SdmxSchemaEnumType.VersionTwoPointOne);
			
			IStructureWorkspace workspace = spm.ParseStructures(rdl);
			
			ISdmxObjects sdmxObjects = workspace.GetStructureObjects(false);
			
			ISet<IMaintainableObject> maintainables =  sdmxObjects.GetAllMaintainables();
			foreach (IMaintainableObject m in maintainables) {
				Console.WriteLine(m.Urn);
				Console.WriteLine(m.StructureType.StructureType + " - " + m.Name);
				Console.WriteLine(" --- ");
			}
		}
开发者ID:alcardac,项目名称:SDMXRI_WS_OF,代码行数:15,代码来源:ReadingStructures.cs

示例15: TestComplexDataQueryToXDoc

        /// <summary>
        /// Initializes a new instance of the <see cref="TestComplexDataQueryToXDoc"/> class.
        /// </summary>
        public TestComplexDataQueryToXDoc()
        {
            IStructureParsingManager manager = new StructureParsingManager();
            this._dataQueryBuilderManager = new ComplexDataQueryBuilderManager(new ComplexDataQueryFactoryV21());
            using (var readable = new FileReadableDataLocation("tests/V21/Structure/test-sdmxv2.1-ESTAT+SSTSCONS_PROD_M+2.0.xml"))
            {
                var structureWorkspace = manager.ParseStructures(readable);
                this._dataflowObject = structureWorkspace.GetStructureObjects(false).Dataflows.First();
            }

            using (var readable = new FileReadableDataLocation("tests/V21/Structure/test-sdmxv2.1-ESTAT+STS+2.0.xml"))
            {
                var structureWorkspace = manager.ParseStructures(readable);
                this._dataStructureObject = structureWorkspace.GetStructureObjects(false).DataStructures.First();
            }
        }
开发者ID:SDMXISTATFRAMEWORK,项目名称:ISTAT_ENHANCED_SDMXRI_WS,代码行数:19,代码来源:TestComplexDataQueryToXDoc.cs


注:本文中的Org.Sdmxsource.Util.Io.FileReadableDataLocation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。