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


C# MgaFCO.GetParent方法代码示例

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


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

示例1: merge

        public void merge(MgaFCO currentObject, string filename) {

            _currentMgaProject = currentObject.Project;

            MgaProject mgaProject = GetProject(filename, currentObject.Project.MetaName);

            if (mgaProject == null)
                return;
            try
            {

                _projectFilename = filename;

                MgaGateway mgaGateway = new MgaGateway(mgaProject);

                mgaGateway.PerformInTransaction(delegate
                {

                    // "DO" LOOP IS ONLY TO ALLOW "break" TO TERMINATE THIS INTERPRETER
                    do
                    {

                        int origPrefs = _currentMgaProject.Preferences;
                        // Magic word allows us to remove ConnPoints
                        _currentMgaProject.Preferences = origPrefs | (int)GME.MGA.preference_flags.MGAPREF_IGNORECONNCHECKS | (int)GME.MGA.preference_flags.MGAPREF_FREEINSTANCEREFS;

                        try
                        {
                            // GET FCO TO BE MERGED FROM OTHER MGA FILE
                            IMgaFCO otherCurrentObject = mgaProject.get_ObjectByPath(currentObject.AbsPath) as IMgaFCO;
                            if (otherCurrentObject == null)
                            {
                                gmeConsole.Error.WriteLine("Could not perform merge:  could not find object of path \"" + currentObject.AbsPath + "\" in file \"" + filename + "\"");
                                _exitStatus |= Errors.PathError;
                                break;
                            }

                            recordConnections(otherCurrentObject);

                            // GET PARENT (IN CURRENT MODEL) OF THE FCO TO BE MERGED INTO THE CURRENT MODEL
                            MgaObject currentParentMGAObject = null;
                            GME.MGA.Meta.objtype_enum currentParentObjTypeEnum;
                            currentObject.GetParent(out currentParentMGAObject, out currentParentObjTypeEnum);


                            // THE ROOT OF THE MERGED FCO
                            IMgaFCO newCurrentObject = null;

                            IMgaFCO otherArchetype = otherCurrentObject.ArcheType;
                            if (otherArchetype != null)
                            {

                                MgaFCO newArchetype = mgaProject.get_ObjectByPath(otherArchetype.AbsPath) as MgaFCO;
                                if (newArchetype == null)
                                {
                                    gmeConsole.Error.WriteLine("Could not find object of path \"" + otherArchetype.AbsPath + "\" (archetype of \"" + otherCurrentObject.AbsPath + "\" in file \"" + filename + "\") in current model.");
                                    _exitStatus |= Errors.PathError;
                                    break;
                                }

                                if (currentParentObjTypeEnum == GME.MGA.Meta.objtype_enum.OBJTYPE_FOLDER)
                                {
                                    newCurrentObject = (currentParentMGAObject as MgaFolder).DeriveRootObject(newArchetype, otherCurrentObject.IsInstance);
                                }
                                else if (currentParentObjTypeEnum == GME.MGA.Meta.objtype_enum.OBJTYPE_MODEL)
                                {
                                    newCurrentObject = (currentParentMGAObject as MgaModel).DeriveChildObject(newArchetype, otherCurrentObject.MetaRole, otherCurrentObject.IsInstance);
                                }
                                else
                                {
                                    gmeConsole.Error.WriteLine("Unable to merge \"" + otherCurrentObject.AbsPath + "\" of file \"" + filename + "\":  prospective parent neither a folder nor a model.");
                                    _exitStatus |= Errors.GMEError;
                                    break;
                                }

                                attributesAndRegistryCopy(newCurrentObject, otherCurrentObject);
                                connectionCopy();

                            }
                            else
                            {

                                if (currentParentObjTypeEnum == GME.MGA.Meta.objtype_enum.OBJTYPE_FOLDER)
                                {
                                    newCurrentObject = (currentParentMGAObject as MgaFolder).CreateRootObject(currentObject.Meta);
                                }
                                else if (currentParentObjTypeEnum == GME.MGA.Meta.objtype_enum.OBJTYPE_MODEL)
                                {
                                    newCurrentObject = (currentParentMGAObject as MgaModel).CreateChildObject(currentObject.MetaRole);
                                }
                                else
                                {
                                    gmeConsole.Error.WriteLine("Unable to merge \"" + otherCurrentObject.AbsPath + "\" of file \"" + filename + "\":  prospective parent neither a folder nor a model.");
                                    _exitStatus |= Errors.GMEError;
                                    break;
                                }

                                subTreeCopy(newCurrentObject, otherCurrentObject);
                                instanceCopy();
                                attributesAndRegistryCopy(newCurrentObject, otherCurrentObject);
//.........这里部分代码省略.........
开发者ID:metamorph-inc,项目名称:meta-core,代码行数:101,代码来源:SubTreeMerge.cs


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