本文整理汇总了C#中DocProject.GetDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# DocProject.GetDefinition方法的具体用法?C# DocProject.GetDefinition怎么用?C# DocProject.GetDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocProject
的用法示例。
在下文中一共展示了DocProject.GetDefinition方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadEntity
private void LoadEntity(DocEntity entity, DocProject project, string selection)
{
if (entity == null)
return;
// recurse to base
if (entity.BaseDefinition != null)
{
DocEntity docBase = project.GetDefinition(entity.BaseDefinition) as DocEntity;
LoadEntity(docBase, project, selection);
}
// load attributes
foreach (DocAttribute docAttr in entity.Attributes)
{
// if attribute is derived, dont add, but remove existing
if (!String.IsNullOrEmpty(docAttr.Derived))
{
foreach (ListViewItem lvi in this.listView.Items)
{
if (lvi.Text.Equals(docAttr.Name))
{
lvi.Remove();
break;
}
}
}
else
{
ListViewItem lvi = new ListViewItem();
lvi.Tag = docAttr;
lvi.Text = docAttr.Name;
lvi.SubItems.Add(docAttr.DefinedType); // INVERSE / SET / LIST / OPTIONAL...
this.listView.Items.Add(lvi);
if(selection != null && lvi.Text.Equals(selection))
{
lvi.Selected = true;
}
}
}
}
示例2: DrawEntity
/// <summary>
/// Draws entity and recurses.
/// </summary>
/// <param name="g">Graphics device.</param>
/// <param name="lane">Horizontal lane for which to draw the entity.</param>
/// <param name="lanes">List of lanes left-to-right.</param>
/// <param name="docEntity">The entity to draw.</param>
/// <param name="docView">The model view for which to draw the entity.</param>
/// <param name="docTemplate">The template to draw.</param>
/// <param name="docRule">Optional rule for recursing.</param>
/// <param name="map">Map of definitions.</param>
/// <param name="layout">Optional layout to receive rectangles for building image map</param>
/// <param name="docProject">Required project.</param>
/// <param name="instance">Optional instance where included or missing attributes are highlighted.</param>
private static void DrawEntity(
Graphics g,
int lane,
List<int> lanes,
DocEntity docEntity,
DocModelView docView,
DocTemplateDefinition docTemplate,
DocModelRuleEntity docRule,
Dictionary<string, DocObject> map,
Dictionary<Rectangle, DocModelRule> layout,
DocProject docProject,
DocSchema docSchema,
object instance)
{
List<DocAttribute> listAttr = new List<DocAttribute>();
BuildAttributeList(docEntity, listAttr, map);
while(lanes.Count < lane + 1)
{
int miny = 0;
if (lanes.Count > lane)
{
miny = lanes[lane];
}
lanes.Add(miny);
}
int x = lane * CX + FormatPNG.Border;
int y = lanes[lane] + FormatPNG.Border;
if (g != null)
{
Brush brush = Brushes.Black;
if (instance != null)
{
brush = Brushes.Red;
if (instance is System.Collections.IList)
{
string typename = instance.GetType().Name;
// keep going until matching instance
System.Collections.IList list = (System.Collections.IList)instance;
foreach (object member in list)
{
string membertypename = member.GetType().Name;
DocEntity docType = docProject.GetDefinition(membertypename) as DocEntity;
while (docType != null)
{
if (docType == docEntity)
{
brush = Brushes.Lime;
instance = member;
break;
}
docType = docProject.GetDefinition(docType.BaseDefinition) as DocEntity;
}
if (brush != Brushes.Red)
break;
}
}
else
{
string typename = instance.GetType().Name;
DocEntity docType = docProject.GetDefinition(typename) as DocEntity;
while (docType != null)
{
if (docType == docEntity)
{
brush = Brushes.Lime;
break;
}
docType = docProject.GetDefinition(docType.BaseDefinition) as DocEntity;
}
}
}
else if (docEntity.IsAbstract())
{
brush = Brushes.Gray;
}
else
//.........这里部分代码省略.........
示例3: CreateInheritanceDiagramForEntity
/// <summary>
/// Create an inheritance diagram for a particular entity, its entire hierarchy of supertypes, and one level of subtypes, within scope.
/// </summary>
/// <param name="docEntity"></param>
/// <param name="font"></param>
/// <param name="map"></param>
/// <returns></returns>
public static Image CreateInheritanceDiagramForEntity(DocProject docProject, Dictionary<DocObject, bool> included, DocEntity docEntity, Font font, Dictionary<Rectangle, DocEntity> map)
{
// determine items within scope
Dictionary<DocObject, bool> hierarchy = new Dictionary<DocObject,bool>();
DocEntity docBase = docEntity;
DocEntity docRoot = docBase;
while (docBase != null)
{
docRoot = docBase;
if (included == null || included.ContainsKey(docBase))
{
hierarchy.Add(docBase, true);
}
docBase = docProject.GetDefinition(docBase.BaseDefinition) as DocEntity;
}
foreach (DocSection docSection in docProject.Sections)
{
foreach (DocSchema docSchema in docSection.Schemas)
{
foreach (DocEntity docEnt in docSchema.Entities)
{
if (docEnt.BaseDefinition == docEntity.Name)
{
if (included == null || included.ContainsKey(docEnt))
{
hierarchy.Add(docEnt, true);
}
}
}
}
}
return CreateInheritanceDiagram(docProject, hierarchy, docRoot, docEntity, font, map);
}
示例4: FindTemplateItems
/// <summary>
/// Builds list of items in order, using inherited concepts.
/// </summary>
/// <param name="entity"></param>
/// <param name="template"></param>
/// <param name="view"></param>
private static DocTemplateItem[] FindTemplateItems(DocProject docProject, DocEntity entity, DocTemplateDefinition template, DocModelView view)
{
// inherited concepts first
List<DocTemplateItem> listItems = new List<DocTemplateItem>();
DocEntity basetype = entity;
bool inherit = true;
while (basetype != null)
{
// find templates for base
foreach (DocModelView docView in docProject.ModelViews)
{
if (view == docView || view.BaseView == docView.Name)
{
foreach (DocConceptRoot docRoot in docView.ConceptRoots)
{
if (docRoot.ApplicableEntity == basetype)
{
foreach (DocTemplateUsage eachusage in docRoot.Concepts)
{
if (eachusage.Definition == template)
{
// found it
string[] parameters = template.GetParameterNames();
foreach (DocTemplateItem eachitem in eachusage.Items)
{
string[] values = new string[parameters.Length];
for (int iparam = 0; iparam < parameters.Length; iparam++)
{
values[iparam] = eachitem.GetParameterValue(parameters[iparam]);
}
// new (IfcDoc 4.9d): only add if we don't override by parameters matching exactly
bool include = true;
foreach (DocTemplateItem existitem in listItems)
{
bool samevalues = true;
for (int iparam = 0; iparam < parameters.Length; iparam++)
{
string value = values[iparam];
string match = existitem.GetParameterValue(parameters[iparam]);
if (match != value || (match != null && !match.Equals(value, StringComparison.Ordinal)))
{
samevalues = false;
break;
}
}
if (samevalues)
{
include = false;
break;
}
}
if (include)
{
listItems.Add(eachitem);
}
}
inherit = !eachusage.Override;
}
}
}
}
}
}
// inherit concepts from supertypes unless overriding
if (basetype.BaseDefinition != null && inherit)
{
basetype = docProject.GetDefinition(basetype.BaseDefinition) as DocEntity;
}
else
{
basetype = null;
}
}
return listItems.ToArray();
}
示例5: GenerateDocumentation
public static void GenerateDocumentation(
DocProject docProject,
string path,
Dictionary<long, SEntity> instances,
Dictionary<string, DocObject> mapEntity,
Dictionary<string, string> mapSchema,
DocModelView[] views,
string[] locales,
BackgroundWorker worker,
FormProgress formProgress)
{
// copy over static content * if it doesn't already exist *
string pathContent = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
if (pathContent.EndsWith(@"bin\x86\Debug")) // debugging
{
pathContent = System.IO.Path.GetDirectoryName(pathContent);
pathContent = System.IO.Path.GetDirectoryName(pathContent);
pathContent = System.IO.Path.GetDirectoryName(pathContent);
}
pathContent = System.IO.Path.Combine(pathContent, "content");
if(!System.IO.Directory.Exists(path))
{
System.IO.Directory.CreateDirectory(path);
}
CopyFiles(pathContent, path);
System.IO.Directory.CreateDirectory(Properties.Settings.Default.OutputPath + "\\diagrams");
Dictionary<string, DocPropertyEnumeration> mapPropEnum = new Dictionary<string, DocPropertyEnumeration>();
foreach (DocSection docSection in docProject.Sections)
{
foreach (DocSchema docSchema in docSection.Schemas)
{
foreach (DocPropertyEnumeration docEnum in docSchema.PropertyEnums)
{
mapPropEnum.Add(docEnum.Name, docEnum);
}
}
}
Dictionary<DocObject, string> mapNumber = new Dictionary<DocObject, string>(); // map items to section (e.g. "1.1.1.1")
string pathSchema = path + @"\schema";
// count progress
int progressTotal = docProject.Sections.Count + docProject.Annexes.Count + 2;
formProgress.SetProgressTotal(progressTotal);
int progressCurrent = 0;
// build list of locales in use
SortedList<string, string> listLocale = new SortedList<string, string>();
foreach (DocObject eachobj in mapEntity.Values)
{
if (eachobj.Localization != null)
{
foreach (DocLocalization doclocal in eachobj.Localization)
{
// only deal with languages, not regions
if (doclocal.Locale != null && doclocal.Locale.Length >= 2)
{
string language = doclocal.Locale.Substring(0, 2);
if (!listLocale.ContainsKey(language))
{
listLocale.Add(language, doclocal.Locale);
}
}
}
}
}
// build filter
Dictionary<DocObject, bool> included = null;
if (views != null)
{
included = new Dictionary<DocObject, bool>();
foreach (DocModelView docEachView in views)
{
docProject.RegisterObjectsInScope(docEachView, included);
}
}
Dictionary<DocObject, bool>[] dictionaryViews = new Dictionary<DocObject, bool>[docProject.ModelViews.Count];
for (int i = 0; i < docProject.ModelViews.Count; i++)
{
DocModelView docView = docProject.ModelViews[i];
if (included != null && included.ContainsKey(docView))
{
dictionaryViews[i] = new Dictionary<DocObject, bool>();
docProject.RegisterObjectsInScope(docProject.ModelViews[i], dictionaryViews[i]);
}
}
DocEntity docEntityRoot = docProject.GetDefinition("IfcRoot") as DocEntity;
//.........这里部分代码省略.........
示例6: FormatField
private static string FormatField(DocProject docProject, string content, string fieldname, string fieldtype, string fieldvalue)
{
DocDefinition docDef = docProject.GetDefinition(fieldtype);
// hyperlink to enumerators
if (docDef is DocEnumeration)
{
// hyperlink to enumeration definition
// replace it with hyperlink
DocSchema docSchema = docProject.GetSchemaOfDefinition(docDef);
string relative = @"../../";
string hyperlink = relative + docSchema.Name.ToLower() + @"/lexical/" + docDef.Name.ToLower() + ".htm";
string format = "<a href=\"" + hyperlink + "\">" + fieldvalue + "</a>";
return content.Replace(fieldname, format);
}
else if (docDef is DocEntity)//fieldvalue != null && fieldvalue.StartsWith("Ifc") && docProject.GetDefinition(fieldvalue) != null)
{
// replace it with hyperlink
DocSchema docSchema = docProject.GetSchemaOfDefinition(docDef);
string relative = @"../../";
string hyperlink = relative + docSchema.Name.ToLower() + @"/lexical/" + docDef.Name.ToLower() + ".htm";
string format = "<a href=\"" + hyperlink + "\">" + fieldvalue + "</a>";
return content.Replace(fieldname, format);
}
else //if (docDef == null)
{
// hyperlink to property set definition
DocSchema docSchema = null;
DocObject docObj = docProject.FindPropertySet(fieldvalue, out docSchema);
if (docObj is DocPropertySet)
{
string relative = @"../../";
string hyperlink = relative + docSchema.Name.ToLowerInvariant() + @"/pset/" + docObj.Name.ToLower() + ".htm"; // case-sensitive on linux -- need to make schema all lowercase
string format = "<a href=\"" + hyperlink + "\">" + fieldvalue + "</a>";
return content.Replace(fieldname, format);
}
else if (docObj is DocQuantitySet)
{
string relative = @"../../";
string hyperlink = relative + docSchema.Name.ToLowerInvariant() + @"/qset/" + docObj.Name.ToLower() + ".htm"; // case-sentive on linux -- need to make schema all lowercase
string format = "<a href=\"" + hyperlink + "\">" + fieldvalue + "</a>";
return content.Replace(fieldname, format);
}
if (docObj == null)
{
// simple replace -- hyperlink may markup value later
return content.Replace(fieldname, fieldvalue);
}
}
/*
else
{
// simple replace -- hyperlink may markup value later
return content.Replace(fieldname, fieldvalue);
}*/
return content;
}
示例7: FormatEntityConcepts
//.........这里部分代码省略.........
sbSuper.Append("<tr><td> </td><td>");
mapSuper.Add(docSuperUsage.Definition, docSuperUsage);
string templateid = MakeLinkName(docSuperUsage.Definition);
sbSuper.Append("<a href=\"../../");
sbSuper.Append(schema);
sbSuper.Append("/lexical/" + MakeLinkName(docSuper) + ".htm#" + templateid + "\">");
if (suppress)
{
sbSuper.Append("<del>");
}
sbSuper.Append(docSuperUsage.Definition.Name);
if (suppress)
{
sbSuper.Append("</del>");
}
sbSuper.Append("</a>");
sbSuper.Append("</td><td>");
sbSuper.Append(docViewBase.Name);
sbSuper.Append("</td></tr>");
}
}
listLines.Add(sbSuper.ToString());
}
}
}
// go to base type
docSuper = docProject.GetDefinition(docSuper.BaseDefinition) as DocEntity;
}
if (hasConceptsAtEntity || listLines.Count > 0)
{
sb.AppendLine("<section>");
sb.AppendLine("<h5 class=\"num\">Definitions applying to " + docView.Name + "</h5>");
// link to instance diagram
if (hasConceptsAtEntity)
{
string linkdiagram = MakeLinkName(docView) + "/" + MakeLinkName(entity) + ".htm";
sb.Append("<p><a href=\"../../../annex/annex-d/" + linkdiagram + "\"><img style=\"border: 0px\" src=\"../../../img/diagram.png\" /> Instance diagram</a></p>");
}
sb.AppendLine("<hr />");
foreach (DocConceptRoot docRoot in docView.ConceptRoots)
{
if (docRoot.ApplicableEntity == entity)
{
sb.Append(docRoot.Documentation);
if (docRoot.Concepts.Count > 0)
{
sb.AppendLine("<details>");
sb.AppendLine("<summary>Concept usage</summary>");
foreach (DocTemplateUsage eachusage in docRoot.Concepts)
{
FormatEntityUsage(docProject, entity, docRoot, eachusage, mapEntity, mapSchema, listFigures, listTables, included, sb);
}
sb.AppendLine("</details>");
示例8: FormatConceptTable
//.........这里部分代码省略.........
}
}
}
}
if (docTemplateInner == null && value != null && mapSchema.TryGetValue(value, out schema))
{
if(value.StartsWith("Pset_"))
{
value.ToString();
}
sb.Append("<a href=\"../../");
sb.Append(schema.ToLower());
sb.Append("/lexical/");
sb.Append(value.ToLower());
sb.Append(".htm\">");
sb.Append(value);
sb.Append("</a>");
}
else if(docDef.Name.Equals("IfcReference"))
{
// ...hyperlinks
if(value != null)
{
string[] parts = value.Split('\\');
foreach(string part in parts)
{
string[] tokens = part.Split('.');
if (tokens.Length > 0)
{
sb.Append("\\");
DocDefinition docToken = docProject.GetDefinition(tokens[0]);
if (docToken != null)
{
DocSchema docSchema = docProject.GetSchemaOfDefinition(docToken);
string relative = @"../../";
string hyperlink = relative + docSchema.Name.ToLower() + @"/lexical/" + docToken.Name.ToLower() + ".htm";
string format = "<a href=\"" + hyperlink + "\">" + tokens[0] + "</a>";
sb.Append(format);
}
if (tokens.Length > 1)
{
sb.Append(".");
sb.Append(tokens[1]);
}
sb.Append("<br>");
}
}
}
//sb.Append(value);
}
else if(value != null)
{
sb.Append(value);
}
}
else if (docDef != null && value != null)
{
value = FormatField(docProject, value, value, docDef.Name, value);
sb.Append(value);
}
else if (value != null)
示例9: FormatData
public string FormatData(DocProject docProject, DocPublication docPublication, DocExchangeDefinition docExchange, Dictionary<string, DocObject> map, Dictionary<long, SEntity> instances, SEntity root, bool markup)
{
// load properties
this.m_fullpropertynames.Clear();
foreach(DocSection docSection in docProject.Sections)
{
foreach(DocSchema docSchema in docSection.Schemas)
{
foreach(DocEntity docEntity in docSchema.Entities)
{
if(!docEntity.IsAbstract())
{
DocEntity docClass = docEntity;
while(docClass != null)
{
foreach(DocAttribute docAttr in docClass.Attributes)
{
if (String.IsNullOrEmpty(docAttr.Derived) &&
String.IsNullOrEmpty(docAttr.Inverse))
{
string row0 = docEntity.Name;
string row1 = docAttr.Name;
string row2 = docAttr.Name + "_" + docClass.Name;
string row3 = "ENTITY";
DocAggregationEnum docAggr = docAttr.GetAggregation();
if(docAggr == DocAggregationEnum.SET)
{
row3 = "SET";
}
else if(docAggr == DocAggregationEnum.LIST)
{
row3 = "LIST";
}
this.m_fullpropertynames.Add(row1 + "_" + row0, new ObjectProperty(row0, row1, row2, row3));
}
}
docClass = docProject.GetDefinition(docClass.BaseDefinition) as DocEntity;
}
}
}
}
}
this.m_stream = new System.IO.MemoryStream();
this.Instances = instances;
this.Markup = markup;
this.Save();
this.m_stream.Position = 0;
StreamReader reader = new StreamReader(this.m_stream);
string content = reader.ReadToEnd();
return content;
}
示例10: ExportCnf
//.........这里部分代码省略.........
cnf.schema.Add(sch);
IfcDoc.Schema.CNF.uosElement uos = new Schema.CNF.uosElement();
uos.name = "ifcXML";
cnf.uosElement.Add(uos);
IfcDoc.Schema.CNF.type typeNumber = new Schema.CNF.type();
typeNumber.select = "NUMBER";
typeNumber.map = "xs:double";
cnf.type.Add(typeNumber);
IfcDoc.Schema.CNF.type typeBinary = new Schema.CNF.type();
typeBinary.select = "BINARY";
typeBinary.map = "xs:hexBinary";
cnf.type.Add(typeBinary);
IfcDoc.Schema.CNF.type typeStripped = new Schema.CNF.type();
typeStripped.select = "IfcStrippedOptional";
typeStripped.keep = false;
cnf.type.Add(typeStripped);
SortedDictionary<string, IfcDoc.Schema.CNF.entity> mapEntity = new SortedDictionary<string, Schema.CNF.entity>();
// export default configuration -- also export for Common Use Definitions (base view defined as itself to include everything)
//if (docViews == null || docViews.Length == 0 || (docViews.Length == 1 && docViews[0].BaseView == docViews[0].Uuid.ToString()))
{
foreach (DocSection docSection in docProject.Sections)
{
foreach (DocSchema docSchema in docSection.Schemas)
{
foreach(DocEntity docEntity in docSchema.Entities)
{
bool include = true; //... check if included in graph?
if (included != null && !included.ContainsKey(docEntity))
{
include = false;
}
if (include)
{
foreach (DocAttribute docAttr in docEntity.Attributes)
{
if (docAttr.XsdFormat != DocXsdFormatEnum.Default || docAttr.XsdTagless == true)
{
IfcDoc.Schema.CNF.entity ent = null;
if (!mapEntity.TryGetValue(docEntity.Name, out ent))
{
ent = new Schema.CNF.entity();
ent.select = docEntity.Name;
mapEntity.Add(docEntity.Name, ent);
}
ExportCnfAttribute(ent, docAttr, docAttr.XsdFormat, docAttr.XsdTagless);
}
}
}
}
}
}
}
// export view-specific configuration
foreach (DocModelView docView in docViews)
{
foreach (DocXsdFormat format in docView.XsdFormats)
{
DocEntity docEntity = docProject.GetDefinition(format.Entity) as DocEntity;
if (docEntity != null)
{
DocAttribute docAttr = null;
foreach (DocAttribute docEachAttr in docEntity.Attributes)
{
if (docEachAttr.Name != null && docEachAttr.Name.Equals(format.Attribute))
{
docAttr = docEachAttr;
break;
}
}
if (docAttr != null)
{
IfcDoc.Schema.CNF.entity ent = null;
if (!mapEntity.TryGetValue(docEntity.Name, out ent))
{
ent = new Schema.CNF.entity();
mapEntity.Add(docEntity.Name, ent);
}
ExportCnfAttribute(ent, docAttr, format.XsdFormat, format.XsdTagless);
}
}
}
}
// add at end, such that sorted
foreach(IfcDoc.Schema.CNF.entity ent in mapEntity.Values)
{
cnf.entity.Add(ent);
}
}
示例11: FormatReference
private static string FormatReference(DocProject docProject, string value)
{
if (value == null)
return null;
StringBuilder sb = new StringBuilder();
string[] parts = value.Split('\\');
foreach (string part in parts)
{
string[] tokens = part.Split('.');
if (tokens.Length > 0)
{
sb.Append("\\");
DocDefinition docToken = docProject.GetDefinition(tokens[0]);
if (docToken != null)
{
DocSchema docSchema = docProject.GetSchemaOfDefinition(docToken);
string relative = @"../../";
string hyperlink = relative + docSchema.Name.ToLower() + @"/lexical/" + docToken.Name.ToLower() + ".htm";
string format = "<a href=\"" + hyperlink + "\">" + tokens[0] + "</a>";
sb.Append(format);
}
if (tokens.Length > 1)
{
sb.Append(".");
sb.Append(tokens[1]);
}
sb.Append("<br>");
}
}
return sb.ToString();
}
示例12: FormatEntityConcepts
//.........这里部分代码省略.........
if (suppress || overiden)
{
sbSuper.Append("</del>");
}
sbSuper.Append("</a>");
if(overiden)
{
sbSuper.Append(" (overridden)");
}
else if(suppress)
{
sbSuper.Append(" (suppressed)");
}
sbSuper.Append("</td><td>");
sbSuper.Append("<a href=\"../../templates/" + MakeLinkName(docSuperUsage.Definition) + ".htm\">" + docSuperUsage.Definition + "</a>");
sbSuper.Append("</td><td>");
sbSuper.Append(docViewBase.Name);
sbSuper.Append("</td></tr>");
sbSuper.AppendLine();
}
}
}
}
}
if (sbSuper.Length > 0)
{
listLines.Add(sbSuper.ToString());
}
// go to base type
docSuper = docProject.GetDefinition(docSuper.BaseDefinition) as DocEntity;
}
if (hasConceptsAtEntity || listLines.Count > 0)
{
sb.AppendLine("<section>");
sb.AppendLine("<h5 class=\"num\">Definitions applying to " + docView.Name + "</h5>");
// link to instance diagram
if (hasConceptsAtEntity)
{
string linkdiagram = MakeLinkName(docView) + "/" + MakeLinkName(entity) + ".htm";
sb.Append("<p><a href=\"../../../annex/annex-d/" + linkdiagram + "\"><img style=\"border: 0px\" src=\"../../../img/diagram.png\" /> Instance diagram</a></p>");
}
sb.AppendLine("<hr />");
foreach (DocConceptRoot docRoot in docView.ConceptRoots)
{
if (docRoot.ApplicableEntity == entity)
{
sb.Append("<h5>" + docRoot.Name + "</h5>");
if (docRoot.ApplicableTemplate != null)
{
string applicabletemplatetable = FormatConceptTable(docProject, docView, entity, docRoot, null, mapEntity, mapSchema);
sb.Append(applicabletemplatetable);
}
sb.Append(docRoot.Documentation);
if (docRoot.Concepts.Count > 0)
{