本文整理汇总了C#中IDataObject.GetPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C# IDataObject.GetPropertyValue方法的具体用法?C# IDataObject.GetPropertyValue怎么用?C# IDataObject.GetPropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataObject
的用法示例。
在下文中一共展示了IDataObject.GetPropertyValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
public string Format(IDataObject obj)
{
if (obj == null) return string.Empty;
var cls = _resolver.GetObjectClass(obj.Context.GetInterfaceType(obj));
var allProps = cls.GetAllProperties();
var result = new StringBuilder();
foreach (var prop in allProps.OfType<StringProperty>().OrderBy(p => p.Name))
{
var txtVal = obj.GetPropertyValue<string>(prop.Name);
if (!string.IsNullOrWhiteSpace(txtVal))
{
result.AppendLine(txtVal);
}
}
foreach (var prop in allProps.OfType<EnumerationProperty>().OrderBy(p => p.Name))
{
var enumVal = obj.GetPropertyValue<int>(prop.Name);
var txtVal = prop.Enumeration.GetLabelByValue(enumVal);
if (!string.IsNullOrWhiteSpace(txtVal))
{
result.AppendLine(txtVal);
}
}
return result.ToString();
}
示例2: DebugDataObject
static void DebugDataObject(IDataObject dataObject, string objectTypeName)
{
DataObject objDef = ((SampleSQLDataLayer)sampleDL).GetObjectDefinition(objectTypeName);
foreach (DataProperty prop in objDef.dataProperties)
{
string propName = prop.propertyName;
Console.WriteLine(propName + ": " + Convert.ToString(dataObject.GetPropertyValue(propName)));
}
}
示例3: GetTemplateName
protected string GetTemplateName(org.iringtools.adapter.datalayer.eb.Template template, DataObject objectDefinition, IDataObject dataObject)
{
if ((template.Placeholders == null) || (template.Placeholders.Count() == 0))
{
return template.Name;
}
template.Placeholders.ToList<Placeholder>().Sort(new PlaceHolderComparer());
string[] parameters = new string[template.Placeholders.Length];
int i = 0;
foreach (Placeholder placeholder in template.Placeholders)
{
string propertyName = Utilities.ToPropertyName(placeholder.Value);
string propertyValue = Convert.ToString(dataObject.GetPropertyValue(propertyName));
if (string.IsNullOrEmpty(propertyValue))
{
_logger.Warn(string.Format("Template holder [{0}] is empty.", placeholder.Value));
}
if (!string.IsNullOrEmpty(placeholder.Format))
{
if (propertyValue.Length < placeholder.Format.Length)
{
propertyValue = placeholder.Format.Substring(0, placeholder.Format.Length - propertyValue.Length) + propertyValue;
}
propertyValue = int.Parse(propertyValue).ToString(placeholder.Format);
}
parameters[i++] = propertyValue;
}
return string.Format(template.Name, parameters);
}
示例4: GetDocumentId
protected int GetDocumentId(IDataObject dataObject)
{
return Convert.ToInt32(dataObject.GetPropertyValue("Id"));
}
示例5: FormWidget
private Widget FormWidget(IDataObject dataObject)
{
Widget widget = new Widget();
try
{
if (dataObject.GetPropertyValue("Id") != null)
{
string identifier = dataObject.GetPropertyValue("Id").ToString();
int id = 0;
Int32.TryParse(identifier, out id);
widget.Id = id;
}
if (dataObject.GetPropertyValue("Name") != null)
{
widget.Name = dataObject.GetPropertyValue("Name").ToString();
}
if (dataObject.GetPropertyValue("Description") != null)
{
widget.Description = dataObject.GetPropertyValue("Description").ToString();
}
if (dataObject.GetPropertyValue("Material") != null)
{
widget.Material = dataObject.GetPropertyValue("Material").ToString();
}
if (dataObject.GetPropertyValue("Length") != null)
{
string lengthValue = dataObject.GetPropertyValue("Length").ToString();
double length = 0;
Double.TryParse(lengthValue, out length);
widget.Length = length;
}
if (dataObject.GetPropertyValue("Width") != null)
{
string widthValue = dataObject.GetPropertyValue("Width").ToString();
double width = 0;
Double.TryParse(widthValue, out width);
widget.Width = width;
}
if (dataObject.GetPropertyValue("Height") != null)
{
string heightValue = dataObject.GetPropertyValue("Height").ToString();
double height = 0;
Double.TryParse(heightValue, out height);
widget.Height = height;
}
if (dataObject.GetPropertyValue("Weight") != null)
{
string weightValue = dataObject.GetPropertyValue("Weight").ToString();
double weight = 0;
Double.TryParse(weightValue, out weight);
widget.Weight = weight;
}
if (dataObject.GetPropertyValue("LengthUOM") != null)
{
string lengthUOMValue = dataObject.GetPropertyValue("LengthUOM").ToString();
LengthUOM lengthUOM = LengthUOM.feet;
Enum.TryParse<LengthUOM>(lengthUOMValue, out lengthUOM);
widget.LengthUOM = lengthUOM;
}
if (dataObject.GetPropertyValue("WeightUOM") != null)
{
string weightUOMValue = dataObject.GetPropertyValue("WeightUOM").ToString();
WeightUOM weightUOM = WeightUOM.grams;
Enum.TryParse<WeightUOM>(weightUOMValue, out weightUOM);
widget.WeightUOM = weightUOM;
}
if (dataObject.GetPropertyValue("Color") != null)
{
string colorValue = dataObject.GetPropertyValue("Color").ToString();
Color color = Color.Black;
Enum.TryParse<Color>(colorValue, out color);
widget.Color = color;
}
}
catch (Exception ex)
{
_logger.ErrorFormat("Error while marshalling a data object into a widget: {1}", ex);
throw new Exception("Error while marshalling a data object into a widget.", ex);
}
return widget;
}
示例6: GetRelatedObjects
public override IList<IDataObject> GetRelatedObjects(IDataObject dataObject, string relatedObjectType, int pageSize, int startIndex)
{
string objectType = dataObject.GetType().Name;
IList<IDataObject> dataObjects = null;
if (objectType == typeof(GenericDataObject).Name)
{
objectType = ((GenericDataObject)dataObject).ObjectType;
}
try
{
DataObject parentDataObject = _dataDictionary.dataObjects.Find(x => x.objectName.ToUpper() == objectType.ToUpper());
if (parentDataObject == null)
throw new Exception("Parent data object [" + objectType + "] not found.");
DataObject relatedObjectDefinition = _dataDictionary.dataObjects.Find(x => x.objectName.ToUpper() == relatedObjectType.ToUpper());
if (relatedObjectDefinition == null)
throw new Exception("Related data object [" + relatedObjectType + "] not found.");
DataRelationship dataRelationship = parentDataObject.dataRelationships.Find(c => c.relatedObjectName.ToLower() == relatedObjectDefinition.objectName.ToLower());
if (dataRelationship == null)
throw new Exception("Relationship between data object [" + objectType + "] and related data object [" + relatedObjectType + "] not found.");
DataFilter filter = null;
foreach (PropertyMap propertyMap in dataRelationship.propertyMaps)
{
filter = new DataFilter();
string keyFieldValue = Convert.ToString(dataObject.GetPropertyValue(propertyMap.dataPropertyName));
Expression expression = new Expression();
expression.LogicalOperator = LogicalOperator.And;
expression.RelationalOperator = RelationalOperator.EqualTo;
expression.PropertyName = propertyMap.relatedPropertyName;
expression.Values = new Values() { keyFieldValue };
filter.Expressions.Add(expression);
}
dataObjects = Get(relatedObjectType, filter, 0, 0);
}
catch (Exception ex)
{
_logger.ErrorFormat("Error while geting related data objects", ex);
throw new Exception("Error while geting related data objects", ex);
}
return dataObjects;
}
示例7: GetRelatedObjects
public override IList<IDataObject> GetRelatedObjects(IDataObject dataObject, string relatedObjectType, int pageSize, int startIndex)
{
string objectType = dataObject.GetType().Name;
IList<IDataObject> dataObjects = null;
if (objectType == typeof(GenericDataObject).Name)
{
objectType = ((GenericDataObject)dataObject).ObjectType;
}
try
{
DataObject parentDataObject = _dataDictionary.dataObjects.Find(x => x.objectName.ToUpper() == objectType.ToUpper());
if (parentDataObject == null)
throw new Exception("Parent data object [" + objectType + "] not found.");
DataObject relatedObjectDefinition = _dataDictionary.dataObjects.Find(x => x.objectName.ToUpper() == relatedObjectType.ToUpper());
if (relatedObjectDefinition == null)
throw new Exception("Related data object [" + relatedObjectType + "] not found.");
DataRelationship dataRelationship = parentDataObject.dataRelationships.Find(c => c.relatedObjectName.ToLower() == relatedObjectDefinition.objectName.ToLower());
if (dataRelationship == null)
throw new Exception("Relationship between data object [" + objectType + "] and related data object [" + relatedObjectType + "] not found.");
string pID = Convert.ToString(dataObject.GetPropertyValue(parentDataObject.keyProperties[0].ToString()));
string url = GenerateReletedUrl(objectType, pID, relatedObjectType, pageSize, startIndex);
string jsonString = GetJsonResponseFrom(url);
DataTable dataTable = GetDataTableFrom(jsonString, objectType);
dataObjects = ToDataObjects(dataTable, objectType);
}
catch (Exception ex)
{
_logger.ErrorFormat("Error while geting related data objects", ex);
throw new Exception("Error while geting related data objects", ex);
}
return dataObjects;
}
示例8: GetIdentifier
private string GetIdentifier(IDataObject dataObject)
{
string[] identifierParts = new string[_objectDefinition.keyProperties.Count];
int i = 0;
foreach (KeyProperty keyProperty in _objectDefinition.keyProperties)
{
identifierParts[i] = dataObject.GetPropertyValue(keyProperty.keyPropertyName).ToString();
i++;
}
return String.Join(_objectDefinition.keyDelimeter, identifierParts);
}