本文整理汇总了C#中IInformationObject.SetValuesToObjects方法的典型用法代码示例。如果您正苦于以下问题:C# IInformationObject.SetValuesToObjects方法的具体用法?C# IInformationObject.SetValuesToObjects怎么用?C# IInformationObject.SetValuesToObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInformationObject
的用法示例。
在下文中一共展示了IInformationObject.SetValuesToObjects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetFieldValues
public static void SetFieldValues(IInformationObject rootObject, NameValueCollection fieldEntries)
{
NameValueCollection internalObjectFixedEntries = new NameValueCollection();
foreach (string key in fieldEntries.AllKeys)
{
string fieldValue = fieldEntries[key];
if (key.Contains("___"))
{
int underscoreIndex = key.IndexOf('_');
string containingObjectID = key.Substring(0, underscoreIndex);
List<IInformationObject> foundObjects= new List<IInformationObject>();
rootObject.FindObjectsFromTree(foundObjects, iObj => iObj.ID == containingObjectID, false);
if(foundObjects.Count == 0)
throw new InvalidDataException("Containing object with ID not found: " + containingObjectID);
var containingRootObject = foundObjects[0];
string chainedPropertyName = key.Substring(underscoreIndex + 1);
object actualContainingObject;
string actualPropertyName;
InitializeChainAndReturnPropertyOwningObject(containingRootObject, chainedPropertyName,
out actualContainingObject, out actualPropertyName);
IInformationObject actualIObj = (IInformationObject) actualContainingObject;
string actualKey = actualIObj.ID + "_" + actualPropertyName;
internalObjectFixedEntries.Add(actualKey, fieldValue);
}
else
{
internalObjectFixedEntries.Add(key, fieldValue);
}
}
rootObject.SetValuesToObjects(internalObjectFixedEntries);
}