本文整理汇总了C#中IDataObject.GetProxyState方法的典型用法代码示例。如果您正苦于以下问题:C# IDataObject.GetProxyState方法的具体用法?C# IDataObject.GetProxyState怎么用?C# IDataObject.GetProxyState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataObject
的用法示例。
在下文中一共展示了IDataObject.GetProxyState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MergeProperties
/// <summary>
/// Merges static properties of DataObject.
/// </summary>
/// <param name="baseObject">Base DataObject to be merged.</param>
/// <param name="mergingObject">Merging DataObject to be merged into base DataObject.</param>
/// <param name="checkPaths">Consider paths in the merging.</param>
private void MergeProperties(IDataObject baseObject, IDataObject mergingObject, Boolean checkPaths)
{
foreach (PropertyInfo propertyInfo in mergingObject.GetType().GetRuntimeProperties())
{
Boolean includePath = true;
if (this.Paths != null)
{
includePath = !checkPaths;
foreach (String path in this.Paths)
{
if (propertyInfo.Name == path)
{
includePath = true;
}
}
}
if ((propertyInfo.CanWrite) && (!mergingObject.GetProxyState(propertyInfo.Name)) && (includePath))
{
if (IsDataList(propertyInfo.PropertyType))
{
IDataList propertyValue = (IDataList)propertyInfo.GetValue(mergingObject, new Object[] { });
if (propertyValue != null)
{
IDataList dataList = (IDataList)LightHouse.Elite.Core.Builder.Get(propertyValue.GetType());
for (int i = 0; i < propertyValue.Count; i++)
{
if (IsReferenceObject((IDataObject)propertyValue[i]))
{
dataList.Add(GetReferencedObject((IDataObject)propertyValue[i]));
}
else
{
IDataObject referencedObject = GetProxyObject((IDataObject)propertyValue[i]);
dataList.Add(referencedObject);
}
}
propertyInfo.SetValue(baseObject, dataList, new Object[] { });
}
}
else if (IsDataObject(propertyInfo.PropertyType))
{
DataObject propertyValue = (DataObject)propertyInfo.GetValue(mergingObject, new Object[] { });
if (propertyValue != null)
{
if (IsReferenceObject(propertyValue))
{
// If the Object hasn't been saved, it is persisted as such to the database
if (String.IsNullOrEmpty(propertyValue.ID))
{
IDataObject referencedObject = GetProxyObject(propertyValue);
propertyInfo.SetValue(baseObject, referencedObject, new Object[] { });
}
else
{
propertyInfo.SetValue(baseObject, GetReferencedObject(propertyValue), new Object[] { });
}
}
else
{
IDataObject referencedObject = GetProxyObject(propertyValue);
propertyInfo.SetValue(baseObject, referencedObject, new Object[] { });
}
}
else
{
propertyInfo.SetValue(baseObject, null, new Object[] { });
}
}
else
{
propertyInfo.SetValue(baseObject, propertyInfo.GetValue(mergingObject, new Object[] { }), new Object[] { });
}
}
}
}
示例2: MergeDynamicProperties
/// <summary>
/// Merges dynamic properties of DataObject.
/// </summary>
/// <param name="baseObject">Base DataObject to be merged.</param>
/// <param name="mergingObject">Merging DataObject to be merged into base DataObject.</param>
/// <param name="checkPaths">Consider paths in the merging.</param>
private void MergeDynamicProperties(IDataObject baseObject, IDataObject mergingObject, Boolean checkPaths)
{
baseObject.DynamicType = mergingObject.DynamicType;
DataCache dynamicCache = (DataCache)typeof(DataObject).GetTypeInfo().GetDeclaredField("dynamicCache").GetValue(mergingObject);
foreach (KeyValuePair<String, Object> propertyValue in dynamicCache.GetObjectsInRegion("Properties"))
{
Boolean includePath = true;
if (this.Paths != null)
{
includePath = !checkPaths;
foreach (String path in this.Paths)
{
if (propertyValue.Key == path)
{
includePath = true;
}
}
}
if ((!mergingObject.GetProxyState(propertyValue.Key)) && (includePath))
{
if (propertyValue.Value != null)
{
Type propertyType = propertyValue.Value.GetType();
if (IsDataList(propertyType))
{
IDataList mergingList = ((IDataList)propertyValue.Value);
IDataList dataList = (IDataList)LightHouse.Elite.Core.Builder.Get(propertyValue.Value.GetType());
for (int i = 0; i < mergingList.Count; i++)
{
IDataObject cloningObject = (IDataObject)mergingList[i];
if (IsReferenceObject(cloningObject))
{
//Proxy on new generated object should be set to false, otherwise will bet unproxied on storing
if (String.IsNullOrEmpty(cloningObject.ID))
{
IDataObject referencedObject = GetProxyObject(cloningObject);
dataList.Add(referencedObject);
}
else
{
dataList.Add(GetReferencedObject(cloningObject));
}
}
else
{
IDataObject referencedObject = GetProxyObject(cloningObject);
dataList.Add(referencedObject);
}
}
baseObject.SetProperty(propertyValue.Key, dataList);
}
else if (IsDataObject(propertyType))
{
DataObject cloningObject = ((DataObject)propertyValue.Value);
if (IsReferenceObject(cloningObject))
{
// If the Object hasn't been saved, it is persisted as such to the database
if (String.IsNullOrEmpty(cloningObject.ID))
{
IDataObject referencedObject = GetProxyObject(cloningObject);
baseObject.SetProperty(propertyValue.Key, referencedObject);
}
else
{
baseObject.SetProperty(propertyValue.Key, GetReferencedObject(cloningObject));
}
}
else
{
IDataObject referencedObject = GetProxyObject(cloningObject);
baseObject.SetProperty(propertyValue.Key, referencedObject);
}
}
else
{
baseObject.SetProperty(propertyValue.Key, propertyValue.Value);
}
}
else
{
baseObject.SetProperty(propertyValue.Key, propertyValue.Value);
}
//.........这里部分代码省略.........