本文整理汇总了C#中EntitySet.GetComponentSpecification方法的典型用法代码示例。如果您正苦于以下问题:C# EntitySet.GetComponentSpecification方法的具体用法?C# EntitySet.GetComponentSpecification怎么用?C# EntitySet.GetComponentSpecification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntitySet
的用法示例。
在下文中一共展示了EntitySet.GetComponentSpecification方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeserialiseComponentMapping
public ComponentMapping DeserialiseComponentMapping(XmlNode mappingNode, IDatabase database, EntitySet set)
{
NodeProcessor proc = new NodeProcessor(mappingNode);
ComponentMapping mapping = new ComponentMappingImpl();
mapping.FromTable = database.GetTable(proc.GetString("FromTable"), proc.GetString("FromSchema"));
NodeProcessor specProcessor = new NodeProcessor(mappingNode.SelectSingleNode("ToComponent"));
var specification = set.GetComponentSpecification(specProcessor.Attributes.GetString("specification"));
var parentEntity = set.GetEntity(specProcessor.Attributes.GetString("parent-entity"));
string name = specProcessor.Attributes.GetString("name");
if (parentEntity == null)
throw new DeserialisationException(string.Format("Could not find the Entity named {0}", name));
if (specification == null)
throw new DeserialisationException(string.Format("Could not find the Component Specification named {0}", name));
var component = specification.ImplementedComponents.FirstOrDefault(c => ReferenceEquals(c.ParentEntity, parentEntity) && c.Name == name);
if (component == null)
throw new DeserialisationException(string.Format("Could not find the component named {0}", name));
mapping.ToComponent = component;
var columnNodes = mappingNode.SelectNodes("FromColumns/Column");
var propNodes = mappingNode.SelectNodes("ToProperties/Property");
if (columnNodes == null) throw new DeserialisationException("There were no columns in this Mapping xml");
if (propNodes == null) throw new DeserialisationException("There were no properties in this Mapping xml");
List<IColumn> columns = new List<IColumn>();
foreach (XmlNode columnNode in columnNodes)
{
columns.Add(mapping.FromTable.GetColumn(columnNode.InnerText));
}
List<ComponentPropertyMarker> properties = new List<ComponentPropertyMarker>();
foreach (XmlNode propNode in propNodes)
{
properties.Add(mapping.ToComponent.GetProperty(propNode.InnerText));
}
if (columns.Count != properties.Count) throw new DeserialisationException("Mapping contains different numbers of columns and properties");
for (int i = 0; i < columns.Count; i++)
{
mapping.AddPropertyAndColumn(properties[i], columns[i]);
}
ProcessScriptBase(mapping, mappingNode);
return mapping;
}