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


C# MgaProject.get_ObjectByPath方法代码示例

本文整理汇总了C#中MgaProject.get_ObjectByPath方法的典型用法代码示例。如果您正苦于以下问题:C# MgaProject.get_ObjectByPath方法的具体用法?C# MgaProject.get_ObjectByPath怎么用?C# MgaProject.get_ObjectByPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MgaProject的用法示例。


在下文中一共展示了MgaProject.get_ObjectByPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DesignSpaceWithRefs

        //[Fact]
        public void DesignSpaceWithRefs()
        {
            var fullTestPath = Path.Combine(_exportModelDirectory, "DesignSpaceWithRefs");
            var xmeFilePath = Path.Combine(fullTestPath, "DesignSpaceWithRefs.xme");
            var pathExportedDesign = Path.Combine(fullTestPath, "DesignSpace.adm");

            // delete design file if it already exists
            if (File.Exists(pathExportedDesign))
            {
                File.Delete(pathExportedDesign);
            }

            String connectionString;
            GME.MGA.MgaUtils.ImportXMEForTest(xmeFilePath, out connectionString);

            var proj = new MgaProject();
            bool ro_mode;
            proj.Open(connectionString, out ro_mode);
            proj.EnableAutoAddOns(true);

            try
            {
                var designExporter = new CyPhyDesignExporter.CyPhyDesignExporterInterpreter();
                designExporter.Initialize(proj);

                var mgaGateway = new MgaGateway(proj);
                MgaFCO currentFCO = null;
                mgaGateway.PerformInTransaction(delegate
                {
                    currentFCO = proj.get_ObjectByPath("/@DesignSpaces|kind=DesignSpace|relpos=0/@DesignSpace|kind=DesignContainer|relpos=0") as MgaFCO;
                    Assert.NotNull(currentFCO);
                });

                var parameters = new CyPhyGUIs.InterpreterMainParameters()
                {
                    CurrentFCO = currentFCO,
                    Project = proj,
                    OutputDirectory = fullTestPath
                };

                var result = designExporter.Main(parameters);

                var design = avm.Design.LoadFromFile(pathExportedDesign);

                /// Add assert statements to check structure
                var root = design.RootContainer;
                Assert.NotNull(root);

                Assert.Equal(1, root.Container1.Count(c => c.Name == "AltContainer"));
                var AltContainer = root.Container1.First(c => c.Name == "AltContainer");

                Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_5"));
                Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_6"));
                Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_7"));

                Assert.Equal(1, root.Container1.Count(c => c.Name == "DesignContainer"));
                var DesignContainer = root.Container1.First(c => c.Name == "DesignContainer");

                Assert.Equal(1, DesignContainer.ComponentInstance.Count(ci => ci.Name == "CompA3"));

                Assert.Equal(1, DesignContainer.Container1.Count(c => c.Name == "Assembly1"));
                var Assembly1 = DesignContainer.Container1.First(c => c.Name == "Assembly1");

                Assert.Equal(1, Assembly1.ComponentInstance.Count(ci => ci.Name == "CompA1"));
                Assert.Equal(1, Assembly1.ComponentInstance.Count(ci => ci.Name == "CompA2"));

                Assert.Equal(1, root.Container1.Count(c => c.Name == "ReusableContainer"));
                var ReusableContainer = root.Container1.First(c => c.Name == "ReusableContainer");

                Assert.Equal(1, ReusableContainer.Container1.Count(c => c.Name == "Assembly4"));
                var Assembly4 = ReusableContainer.Container1.First(c => c.Name == "Assembly4");

                Assert.Equal(1, Assembly4.ComponentInstance.Count(ci => ci.Name == "CompA1"));
                Assert.Equal(1, Assembly4.ComponentInstance.Count(ci => ci.Name == "CompA2"));

                Assert.Equal(1, ReusableContainer.ComponentInstance.Count(ci => ci.Name == "CompA4"));

                Assert.Equal(1, root.ComponentInstance.Count(ci => ci.Name == "CompA"));

                Assert.Equal(1, root.ComponentInstance.Count(ci => ci.Name == "CompA"));
            }
            finally
            {
                proj.Close();
            }
        }
开发者ID:metamorph-inc,项目名称:meta-core,代码行数:87,代码来源:Program.cs


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