本文整理汇总了C#中IObject.get方法的典型用法代码示例。如果您正苦于以下问题:C# IObject.get方法的具体用法?C# IObject.get怎么用?C# IObject.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObject
的用法示例。
在下文中一共展示了IObject.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetName
public string GetName(IObject element)
{
// Returns the name by the uml logic.
var dataLayer = _dataLayerLogic?.GetDataLayerOfObject(element);
var metaLayer = _dataLayerLogic?.GetMetaLayerFor(dataLayer);
var uml = _dataLayerLogic?.Get<_UML>(metaLayer);
if (uml != null && element.isSet(_UML._CommonStructure._NamedElement.name))
{
var result = element.get(_UML._CommonStructure._NamedElement.name);
if (result != null)
{
return result.ToString();
}
}
// If the element is not uml induced or the property is empty, check by
// the default "name" property
if (element.isSet("name"))
{
return element.get("name").ToString();
}
// Ok, finally, we don't know what to do, so request retrieve the name just via ToString
return element.ToString();
}
示例2: IsProperty
public bool IsProperty(IObject element)
{
var attributeXmi = "{" + Namespaces.Xmi + "}type";
return element.isSet(attributeXmi) &&
element.get(attributeXmi).ToString() == "uml:Property";
}
示例3: GetSubProperties
public static IEnumerable<IObject> GetSubProperties(IObject element)
{
var elementAsExt = (IObjectAllProperties)element;
if (elementAsExt == null)
{
throw new ArgumentNullException(nameof(element));
}
foreach (var property in elementAsExt.getPropertiesBeingSet())
{
var propertyValue = element.get(property);
var propertyAsEnumerable = propertyValue as IEnumerable;
if (propertyAsEnumerable != null)
{
foreach (var innerValue in propertyAsEnumerable)
{
var innerValueAsObject = innerValue as IObject;
if (innerValueAsObject != null)
{
yield return innerValueAsObject;
}
}
}
}
}
示例4: getDescendents
/// <summary>
/// Gets all descendents of an object, but does not
/// return this object itself
/// </summary>
/// <param name="element">Element being queried</param>
/// <returns>An enumeration of all object and its descendents</returns>
public static IEnumerable<IObject> getDescendents(IObject element)
{
var elementAsIObjectExt = element as IObjectAllProperties;
if (elementAsIObjectExt == null)
{
throw new InvalidOperationException("element is not of type IObjectExt");
}
foreach (var property in elementAsIObjectExt.getPropertiesBeingSet())
{
var value = element.get(property);
if (value is IObject)
{
// Value is an object... perfect!
yield return value as IObject;
}
if (value is IEnumerable && value.GetType() != typeof (string))
{
// Value is a real enumeration. Unfortunately strings are also
// enumeration, but we would like to skip them. Their content
// would be skipped either.
var valueAsEnumerable = value as IEnumerable;
foreach (var innerValue in getDescendents(valueAsEnumerable))
{
yield return innerValue;
}
}
}
}
示例5: GetName
public static string GetName(IObject value)
{
if (value.isSet("name"))
{
return value.get("name").ToString();
}
return null;
}
示例6: WalkProperty
protected override void WalkProperty(IObject propertyObject, CallStack stack)
{
base.WalkProperty(propertyObject, stack);
var nameAsObject = propertyObject.get("name");
var name = nameAsObject == null ? string.Empty : nameAsObject.ToString();
if (name != null)
{
Result.AppendLine($"{stack.Indentation}public static string @{name} = \"{name}\";");
Result.AppendLine($"{stack.Indentation}public IElement _{name} = null;");
Result.AppendLine();
}
else
{
Debug.WriteLine($"Found unknown property: {propertyObject}");
}
}
示例7: ConvertToJson
/// <summary>
/// Converts a given element to a json string, dependent on the column definition as given by the
/// ColumnCreationResult
/// </summary>
/// <param name="element"></param>
/// <param name="creatorResult"></param>
/// <returns></returns>
private Dictionary<string, object> ConvertToJson(IObject element, ColumnCreationResult creatorResult)
{
var result = new Dictionary<string, object>();
foreach (var property in creatorResult.Properties
.Where(property => element.isSet(property)))
{
var propertyAsString = ColumnCreator.ConvertPropertyToColumnName(property);
var propertyValue = element.get(property);
if (creatorResult.ColumnsOnProperty[property].isEnumeration)
{
if (propertyValue is IEnumerable && !(propertyValue is string))
{
var list = new List<object>();
foreach (var listValue in (propertyValue as IEnumerable))
{
var asElement = listValue as IElement;
string url;
if (asElement != null)
{
url = asElement.GetUri();
}
else
{
url = null;
}
list.Add(new
{
u = url,
v = listValue == null ? "null" : _resolution.GetName(listValue)
});
}
result[propertyAsString] = list;
}
else
{
result[propertyAsString] = propertyValue == null ? "null" : _resolution.GetName(propertyValue);
}
}
else
{
result[propertyAsString] = propertyValue == null ? "null" : _resolution.GetName(propertyValue);
}
}
return result;
}
示例8: GetNameOfElement
protected static string GetNameOfElement(IObject element)
{
var nameAsObject = element.get("name");
var name = nameAsObject == null ? string.Empty : nameAsObject.ToString();
return name;
}
示例9: XmlGetElementsOfTypes
/// <summary>
/// Gets all elements of a specific type in the proeprty
/// </summary>
/// <param name="element">Element, whose property is queried </param>
/// <param name="typeNames">Type names to be queried</param>
/// <returns>Enumeration of all elements</returns>
private static IEnumerable<IObject> XmlGetElementsOfTypes(IObject element, IEnumerable<string> typeNames)
{
var elementAsExt = (IObjectAllProperties) element;
if (elementAsExt == null)
{
throw new ArgumentNullException(nameof(element));
}
var attributeXmi = "{" + Namespaces.Xmi + "}type";
var typeNamesList = typeNames.ToList();
foreach (var property in elementAsExt.getPropertiesBeingSet())
{
var propertyValue = element.get(property);
var propertyAsEnumerable = propertyValue as IEnumerable;
foreach (var innerValue in propertyAsEnumerable)
{
var innerValueAsObject = innerValue as IObject;
if (innerValueAsObject != null && innerValueAsObject.isSet(attributeXmi))
{
var type = innerValueAsObject.get(attributeXmi).ToString();
if (typeNamesList.Count(x => type == x) > 0)
{
yield return innerValueAsObject;
}
}
}
}
}