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


C# DocProject.GetTemplate方法代码示例

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


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

示例1: ImportMvd

        internal static void ImportMvd(mvdXML mvd, DocProject docProject, string filepath)
        {
            if (mvd.Templates != null)
            {
                Dictionary<EntityRule, DocModelRuleEntity> fixups = new Dictionary<EntityRule, DocModelRuleEntity>();
                foreach (ConceptTemplate mvdTemplate in mvd.Templates)
                {
                    DocTemplateDefinition docDef = docProject.GetTemplate(mvdTemplate.Uuid);
                    if (docDef == null)
                    {
                        docDef = new DocTemplateDefinition();
                        docProject.Templates.Add(docDef);
                    }

                    ImportMvdTemplate(mvdTemplate, docDef, fixups);
                }

                foreach(EntityRule er in fixups.Keys)
                {
                    DocModelRuleEntity docEntityRule = fixups[er];
                    if(er.References != null)
                    {
                        foreach(TemplateRef tr in er.References)
                        {
                            DocTemplateDefinition dtd = docProject.GetTemplate(tr.Ref);
                            if(dtd != null)
                            {
                                docEntityRule.References.Add(dtd);
                            }
                        }
                    }
                }
            }

            if (mvd.Views != null)
            {
                foreach (ModelView mvdView in mvd.Views)
                {
                    DocModelView docView = docProject.GetView(mvdView.Uuid);
                    if (docView == null)
                    {
                        docView = new DocModelView();
                        docProject.ModelViews.Add(docView);
                    }

                    ImportMvdObject(mvdView, docView);

                    docView.BaseView = mvdView.BaseView;
                    docView.Exchanges.Clear();
                    Dictionary<Guid, ExchangeRequirement> mapExchange = new Dictionary<Guid, ExchangeRequirement>();
                    foreach (ExchangeRequirement mvdExchange in mvdView.ExchangeRequirements)
                    {
                        mapExchange.Add(mvdExchange.Uuid, mvdExchange);

                        DocExchangeDefinition docExchange = new DocExchangeDefinition();
                        ImportMvdObject(mvdExchange, docExchange);
                        docView.Exchanges.Add(docExchange);

                        docExchange.Applicability = (DocExchangeApplicabilityEnum)mvdExchange.Applicability;

                        // attempt to find icons if exists -- remove extention
                        try
                        {
                            string iconpath = filepath.Substring(0, filepath.Length - 7) + @"\mvd-" + docExchange.Name.ToLower().Replace(' ', '-') + ".png";
                            if (System.IO.File.Exists(iconpath))
                            {
                                docExchange.Icon = System.IO.File.ReadAllBytes(iconpath);
                            }
                        }
                        catch
                        {

                        }
                    }

                    foreach (ConceptRoot mvdRoot in mvdView.Roots)
                    {
                        // find the entity
                        DocEntity docEntity = LookupEntity(docProject, mvdRoot.ApplicableRootEntity);
                        if (docEntity != null)
                        {
                            DocConceptRoot docConceptRoot = docView.GetConceptRoot(mvdRoot.Uuid);
                            if (docConceptRoot == null)
                            {
                                docConceptRoot = new DocConceptRoot();
                                if (docView.ConceptRoots == null)
                                {
                                    docView.ConceptRoots = new List<DocConceptRoot>();
                                }
                                docView.ConceptRoots.Add(docConceptRoot);
                            }

                            ImportMvdObject(mvdRoot, docConceptRoot);
                            docConceptRoot.ApplicableEntity = docEntity;

                            if (mvdRoot.Applicability != null)
                            {
                                docConceptRoot.ApplicableTemplate = docProject.GetTemplate(mvdRoot.Applicability.Template.Ref);
                                if(mvdRoot.Applicability.TemplateRules != null)
                                {
//.........这里部分代码省略.........
开发者ID:BuildingSMART,项目名称:IfcDoc,代码行数:101,代码来源:Program.cs

示例2: ImportMvdConcept

        private static void ImportMvdConcept(Concept mvdNode, DocTemplateUsage docUse, DocProject docProject, Dictionary<Guid, ExchangeRequirement> mapExchange)
        {
            // special case for attributes
            DocTemplateDefinition docTemplateDef = docProject.GetTemplate(mvdNode.Template.Ref);
            if (docTemplateDef != null)
            {
                ImportMvdObject(mvdNode, docUse);

                docUse.Definition = docTemplateDef;
                docUse.Override = mvdNode.Override;

                // exchange requirements
                foreach (ConceptRequirement mvdReq in mvdNode.Requirements)
                {
                    ExchangeRequirement mvdExchange = null;
                    if (mapExchange.TryGetValue(mvdReq.ExchangeRequirement, out mvdExchange))
                    {
                        DocExchangeItem docReq = new DocExchangeItem();
                        docUse.Exchanges.Add(docReq);

                        foreach (DocModelView docModel in docProject.ModelViews)
                        {
                            foreach (DocExchangeDefinition docAnno in docModel.Exchanges)
                            {
                                if (docAnno.Uuid.Equals(mvdReq.ExchangeRequirement))
                                {
                                    docReq.Exchange = docAnno;
                                    break;
                                }
                            }
                        }

                        docReq.Applicability = (DocExchangeApplicabilityEnum)mvdReq.Applicability;

                        switch(mvdReq.Requirement)
                        {
                            case RequirementEnum.Mandatory:
                                docReq.Requirement = DocExchangeRequirementEnum.Mandatory;
                                break;

                            case RequirementEnum.Recommended:
                                docReq.Requirement = DocExchangeRequirementEnum.Optional;
                                break;

                            case RequirementEnum.NotRelevant:
                                docReq.Requirement = DocExchangeRequirementEnum.NotRelevant;
                                break;

                            case RequirementEnum.NotRecommended:
                                docReq.Requirement = DocExchangeRequirementEnum.NotRecommended;
                                break;

                            case RequirementEnum.Excluded:
                                docReq.Requirement = DocExchangeRequirementEnum.Excluded;
                                break;
                        }
                    }
                }

                // rules as template items
                if (mvdNode.TemplateRules != null)
                {
                    docUse.Operator = (DocTemplateOperator)Enum.Parse(typeof(DocTemplateOperator), mvdNode.TemplateRules.Operator.ToString());
                    foreach (TemplateRule rule in mvdNode.TemplateRules.TemplateRule)
                    {
                        DocTemplateItem docItem = ImportMvdItem(rule, docProject, mapExchange);
                        docUse.Items.Add(docItem);
                    }

                    if (mvdNode.TemplateRules.InnerRules != null)
                    {
                        mvdNode.ToString();
                    }
                }

            }
        }
开发者ID:BuildingSMART,项目名称:IfcDoc,代码行数:77,代码来源:Program.cs

示例3: ImportMvdConcept

        private static void ImportMvdConcept(Concept mvdNode, DocTemplateUsage docUse, DocProject docProject, Dictionary<Guid, ExchangeRequirement> mapExchange)
        {
            // special case for attributes                            
            DocTemplateDefinition docTemplateDef = docProject.GetTemplate(mvdNode.Template.Ref);
            if (docTemplateDef != null)
            {
                // lookup use definition
                docUse.Uuid = mvdNode.Uuid;
                docUse.Name = mvdNode.Name;
                docUse.Definition = docTemplateDef;
                docUse.Override = mvdNode.Override;

                // content
                if (mvdNode.Definitions != null)
                {
                    foreach (Definition mvdDef in mvdNode.Definitions)
                    {
                        if (mvdDef.Body != null)
                        {
                            docUse.Documentation = mvdDef.Body.Content;
                        }
                    }
                }

                // exchange requirements
                foreach (ConceptRequirement mvdReq in mvdNode.Requirements)
                {
                    ExchangeRequirement mvdExchange = null;
                    if (mapExchange.TryGetValue(mvdReq.ExchangeRequirement, out mvdExchange))
                    {
                        DocExchangeItem docReq = new DocExchangeItem();
                        docUse.Exchanges.Add(docReq);

                        foreach (DocModelView docModel in docProject.ModelViews)
                        {
                            foreach (DocExchangeDefinition docAnno in docModel.Exchanges)
                            {
                                if (docAnno.Uuid.Equals(mvdReq.ExchangeRequirement))
                                {
                                    docReq.Exchange = docAnno;
                                    break;
                                }
                            }
                        }

                        docReq.Applicability = (DocExchangeApplicabilityEnum)mvdReq.Applicability;
                        docReq.Requirement = (DocExchangeRequirementEnum)mvdReq.Requirement;
                    }
                }

                // rules as template items
                if (mvdNode.TemplateRules != null)
                {
                    docUse.Operator = (DocTemplateOperator)Enum.Parse(typeof(DocTemplateOperator), mvdNode.TemplateRules.Operator.ToString());
                    foreach (TemplateRule rule in mvdNode.TemplateRules.TemplateRule)
                    {
                        DocTemplateItem docItem = ImportMvdItem(rule, docProject, mapExchange);
                        docUse.Items.Add(docItem);
                    }

                    if (mvdNode.TemplateRules.InnerRules != null)
                    {
                        mvdNode.ToString();
                    }
                }

            }
        }
开发者ID:corneliuspreidel,项目名称:IfcDoc,代码行数:68,代码来源:Program.cs


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