本文整理汇总了C#中IElement.get方法的典型用法代码示例。如果您正苦于以下问题:C# IElement.get方法的具体用法?C# IElement.get怎么用?C# IElement.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IElement
的用法示例。
在下文中一共展示了IElement.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPropertiesOfClassifier
/// <summary>
/// Returns a list of all properties within the classifier.
/// Also properties from generalized classes need to be returned
/// </summary>
/// <param name="classifier"></param>
/// <param name="legacy">true, if legacy access to the attributes shall be used.
/// This means that the methods are accessed via string definitions and not via the properties</param>
/// <returns></returns>
public IEnumerable<string> GetPropertiesOfClassifier(IElement classifier)
{
if (classifier == null) throw new ArgumentNullException(nameof(classifier));
var metaLayer = Legacy ? null : _dataLayerLogic.GetMetaLayerFor(_dataLayerLogic.GetDataLayerOfObject(classifier));
var uml = Legacy ? null : _dataLayerLogic.Get<_UML>(metaLayer);
var propertyOwnedAttribute = Legacy ? "ownedAttribute" : _UML._StructuredClassifiers._StructuredClassifier.ownedAttribute;
var propertyGeneralization = Legacy ? "generalization" : _UML._Classification._Classifier.generalization;
var propertyGeneral = Legacy ? "general" : _UML._Classification._Generalization.general;
if (classifier.isSet(propertyOwnedAttribute))
{
var result = classifier.get(propertyOwnedAttribute) as IEnumerable;
foreach (var item in result)
{
yield return item.ToString();
}
}
// Check for generalizations
if (classifier.isSet(propertyGeneralization))
{
var generalizations = classifier.get(propertyGeneralization) as IEnumerable;
foreach (var generalization in generalizations.Cast<IElement>())
{
var general = generalization.get(propertyGeneral) as IElement;
// Especially for the MOF extent, the generalizations are references in xml and are
// filled out by the simple loader
if (general != null)
{
foreach (var found in GetPropertiesOfClassifier(general))
{
yield return found;
}
}
}
}
}
示例2: Copy
public IElement Copy(IElement element)
{
var targetElement = _factory.create(element.getMetaClass());
var elementAsExt = element as IObjectAllProperties;
if (elementAsExt == null)
{
throw new ArgumentException("element is not of type IObjectAllProperties");
}
foreach (var property in elementAsExt.getPropertiesBeingSet())
{
var value = element.get(property);
targetElement.set(property, value);
}
return targetElement;
}
示例3: GetValue
public static object GetValue(IElement element, string property, object defaultValue = null)
{
return element.isSet(property) ?
element.get(property) :
defaultValue;
}