本文整理汇总了C#中System.Windows.Freezable.GetValueEntry方法的典型用法代码示例。如果您正苦于以下问题:C# Freezable.GetValueEntry方法的具体用法?C# Freezable.GetValueEntry怎么用?C# Freezable.GetValueEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Freezable
的用法示例。
在下文中一共展示了Freezable.GetValueEntry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CloneCoreCommon
// Makes a deep clone of a Freezable. Helper method for
// CloneCore(), CloneCurrentValueCore() and GetAsFrozenCore()
//
// If useCurrentValue is true it calls GetValue on each of the sourceFreezable's DPs; if false
// it uses ReadLocalValue.
private void CloneCoreCommon(Freezable sourceFreezable, bool useCurrentValue, bool cloneFrozenValues)
{
EffectiveValueEntry[] srcEffectiveValues = sourceFreezable.EffectiveValues;
uint srcEffectiveValueCount = sourceFreezable.EffectiveValuesCount;
// Iterate through the effective values array. Note that default values aren't
// stored here so the only defaults we'll come across are modified defaults,
// which useCurrentValue = true uses and useCurrentValue = false ignores.
for (uint i = 0; i < srcEffectiveValueCount; i++)
{
EffectiveValueEntry srcEntry = srcEffectiveValues[i];
DependencyProperty dp = DependencyProperty.RegisteredPropertyList.List[srcEntry.PropertyIndex];
// We need to skip ReadOnly properties otherwise SetValue will fail
if ((dp != null) && !dp.ReadOnly)
{
object sourceValue;
EntryIndex entryIndex = new EntryIndex(i);
if (useCurrentValue)
{
// Default values aren't in the EffectiveValues array
// so we won't see them as we iterate. We do copy modified defaults.
Debug.Assert(srcEntry.BaseValueSourceInternal != BaseValueSourceInternal.Default || srcEntry.HasModifiers);
sourceValue = sourceFreezable.GetValueEntry(
entryIndex,
dp,
null,
RequestFlags.FullyResolved).Value;
// GetValue should not have returned UnsetValue
Debug.Assert(sourceValue != DependencyProperty.UnsetValue);
}
else // use base values
{
// If the local value has modifiers, ReadLocalValue will return the base
// value, which is what we want. A modified default will return UnsetValue,
// which will be ignored at the call to SetValue
sourceValue = sourceFreezable.ReadLocalValueEntry(entryIndex, dp, true /* allowDeferredReferences */);
// For the useCurrentValue = false case we ignore any UnsetValues.
if (sourceValue == DependencyProperty.UnsetValue)
{
continue;
}
// If the DP is an expression ReadLocalValue will return the actual expression.
// In this case we need to copy it.
if (srcEntry.IsExpression)
{
sourceValue = ((Expression)sourceValue).Copy(this, dp);
}
}
//
// If the value of the current DP is a Freezable
// we need to recurse and call the appropriate Clone method in
// order to do a deep copy.
//
Debug.Assert(!(sourceValue is Expression && sourceValue is Freezable),
"This logic assumes Expressions and Freezables don't co-derive");
Freezable valueAsFreezable = sourceValue as Freezable;
if (valueAsFreezable != null)
{
Freezable valueAsFreezableClone;
//
// Choose between the four possible ways of
// cloning a Freezable
//
if (cloneFrozenValues) //CloneCore and CloneCurrentValueCore
{
valueAsFreezableClone = valueAsFreezable.CreateInstanceCore();
if (useCurrentValue)
{
// CloneCurrentValueCore implementation. We clone even if the
// Freezable is frozen by recursing into CloneCurrentValueCore.
valueAsFreezableClone.CloneCurrentValueCore(valueAsFreezable);
}
else
{
// CloneCore implementation. We clone even if the Freezable is
// frozen by recursing into CloneCore.
valueAsFreezableClone.CloneCore(valueAsFreezable);
}
sourceValue = valueAsFreezableClone;
Debug_VerifyCloneCommon(valueAsFreezable, valueAsFreezableClone, /*isDeepClone=*/ true);
//.........这里部分代码省略.........