本文整理汇总了C#中INameScope类的典型用法代码示例。如果您正苦于以下问题:C# INameScope类的具体用法?C# INameScope怎么用?C# INameScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
INameScope类属于命名空间,在下文中一共展示了INameScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddScopeElements
private void AddScopeElements(INameScope scope, ElementAccessor[] elements, ref bool duplicateElements, bool allowDuplicates)
{
for (int i = 0; i < elements.Length; i++)
{
this.AddScopeElement(scope, elements[i], ref duplicateElements, allowDuplicates);
}
}
示例2: Remove
public void Remove(FrameworkElement target, INameScope nameScope, object layerOwner)
{
if (Storyboard != null)
{
Storyboard.Remove(target, nameScope, layerOwner);
}
}
示例3: Timer
public Timer(
NodeGCType gcType,
INodeScope parentNodeScope,
INameScope parentNameScope,
string initialBasicName
)
: base(gcType, parentNodeScope, parentNameScope, initialBasicName)
{
Debug.Assert(gcType == s_gcTypeOfAllInstances);
}
示例4: InitializeContext
public InitializeContext(object target, InitializeContext parentContext, INameScope nameScope, FrameworkElement templatedParent, BaseValueSource valueSource)
{
this.Target = target;
this.ParentContext = parentContext;
this.NameScope = nameScope;
this.TemplatedParent = templatedParent;
this.ValueSource = valueSource;
this.Root = parentContext != null && parentContext.Root != null ? parentContext.Root : Target;
}
示例5: AddUniqueAccessor
private static void AddUniqueAccessor(INameScope scope, Accessor accessor)
{
Accessor accessor2 = (Accessor) scope[accessor.Name, accessor.Namespace];
if (accessor2 != null)
{
if (accessor is ElementAccessor)
{
throw new InvalidOperationException(Res.GetString("XmlDuplicateElementName", new object[] { accessor2.Name, accessor2.Namespace }));
}
throw new InvalidOperationException(Res.GetString("XmlDuplicateAttributeName", new object[] { accessor2.Name, accessor2.Namespace }));
}
scope[accessor.Name, accessor.Namespace] = accessor;
}
示例6: Begin
public void Begin(FrameworkElement containingObject, INameScope nameScope = null, HandoffBehavior handoffBehavior = HandoffBehavior.SnapshotAndReplace, object layerOwner = null)
{
Stop(containingObject);
TimelineClock clock = CreateClock();
clock.Begin(((IAnimatable)containingObject).RootClock);
clocks[containingObject] = clock;
ListDictionary<TargetKey, AnimationTimelineClock> targets = GetAnimationClocksTargets(clock, containingObject, nameScope ?? NameScope.GetContainingNameScope(containingObject));
foreach (TargetKey target in targets.GetKeys())
{
target.Target.ApplyAnimationClocks(target.TargetProperty, targets.GetValues(target), handoffBehavior, layerOwner);
}
}
示例7: AddScopeElement
private void AddScopeElement(INameScope scope, ElementAccessor element, ref bool duplicateElements, bool allowDuplicates)
{
if (scope != null)
{
ElementAccessor accessor = (ElementAccessor) scope[element.Name, element.Namespace];
if (accessor != null)
{
if (!allowDuplicates)
{
throw new InvalidOperationException(Res.GetString("XmlDuplicateElementInScope", new object[] { element.Name, element.Namespace }));
}
if (accessor.Mapping.TypeDesc != element.Mapping.TypeDesc)
{
throw new InvalidOperationException(Res.GetString("XmlDuplicateElementInScope1", new object[] { element.Name, element.Namespace }));
}
duplicateElements = true;
}
else
{
scope[element.Name, element.Namespace] = element;
}
}
}
示例8: WireRootObjectToParent
private static DependencyObject WireRootObjectToParent(object createdObject, DependencyObject rootObject, DependencyObject container, FrameworkElement feContainer, INameScope nameScope)
{
rootObject = createdObject as DependencyObject;
if (rootObject != null)
{
// Add the root to the appropriate tree.
if (feContainer != null)
{
// Put the root object into FE.Templatechild (must be a UIElement).
UIElement rootElement = rootObject as UIElement;
if (rootElement == null)
{
throw new InvalidOperationException(SR.Get(SRID.TemplateMustBeFE, new object[] { rootObject.GetType().FullName }));
}
feContainer.TemplateChild = rootElement;
Debug.Assert(!(rootElement is FrameworkElement) ||
((FrameworkElement)rootElement).TemplateChildIndex != -1);
}
// If we have a container that is not a FE, add to the logical tree of the FEF
else if (container != null)
{
FrameworkElement feResult;
FrameworkContentElement fceResult;
Helper.DowncastToFEorFCE(rootObject, out feResult, out fceResult, true);
FrameworkElementFactory.AddNodeToLogicalTree((FrameworkContentElement)container,
rootObject.GetType(), feResult != null, feResult, fceResult);
}
// Set the TemplateNameScope on the root
if (NameScope.GetNameScope(rootObject) == null)
{
NameScope.SetNameScope(rootObject, nameScope);
}
}
return rootObject;
}
示例9: HandleBeforeProperties
private void HandleBeforeProperties(object createdObject,
ref DependencyObject rootObject,
DependencyObject container,
FrameworkElement feContainer,
INameScope nameScope)
{
if (createdObject is FrameworkElement || createdObject is FrameworkContentElement)
{
// We want to set TemplateChild on the parent if we are dealing with the root
// We MUST wait until the object is wired into the Template vis TemplateNameScope.RegisterName
if (rootObject == null)
{
rootObject = WireRootObjectToParent(createdObject, rootObject, container, feContainer, nameScope);
}
InvalidatePropertiesOnTemplate(container, createdObject);
}
}
示例10: SetNameScope
/// <summary>
/// Sets the value of the attached <see cref="NameScopeProperty"/> on a visual.
/// </summary>
/// <param name="visual">The visual.</param>
/// <param name="value">The value to set.</param>
public static void SetNameScope(Visual visual, INameScope value)
{
visual.SetValue(NameScopeProperty, value);
}
示例11: NameScope
public NameScope (INameScope external)
{
this.external = external;
}
示例12: FindNameScope
/// <summary>
/// Returns the nearest element implementing <see cref="INameScope"/>, stepping up the
/// logical tree from our context object.
/// </summary>
/// <param name="result">Returns the nearest name scope element, if there is one.</param>
/// <returns><c>true</c>, if a name scope could be found, <c>false</c> if it could not
/// be found (yet).</returns>
protected bool FindNameScope(out INameScope result)
{
result = null;
DependencyObject current = _contextObject;
if (current == null)
{
#if DEBUG_BINDINGS
DebugOutput("FindNameScope doesn't have a current context");
#endif
return false;
}
while (current != null)
{
if (current is INameScope)
{
result = current as INameScope;
return true;
}
if (current is UIElement)
{
UIElement uiElement = (UIElement) current;
AbstractProperty templateNameScopeProperty = uiElement.TemplateNameScopeProperty;
AttachToSourcePathProperty(templateNameScopeProperty);
if ((result = ((INameScope) templateNameScopeProperty.GetValue())) != null)
return true;
}
if (!FindParent(current, out current, FindParentMode.HybridPreferLogicalTree))
return false;
}
return false;
}
示例13: ResolveTargetName
/// <summary>
/// Finds the target element of a Storyboard.TargetName property.
/// </summary>
/// <remarks>
/// This is using a different set of FindName rules than that used
/// by ResolveBeginStoryboardName for finding a BeginStoryboard object due
/// to the different FindName behavior in templated objects.
///
/// The templated object name is the name attached to the
/// FrameworkElementFactory that created the object. There are many of them
/// created, one per templated object. So we need to use Template.FindName()
/// to find the templated child using the context of the templated parent.
///
/// Note that this FindName() function on the template class is
/// completely different from the INameScope.FindName() function on the
/// same class
/// </remarks>
internal static DependencyObject ResolveTargetName(
string targetName,
INameScope nameScope,
DependencyObject element )
{
object nameScopeUsed = null;
object namedObject = null;
DependencyObject targetObject = null;
FrameworkElement fe = element as FrameworkElement;
FrameworkContentElement fce = element as FrameworkContentElement;
if( fe != null )
{
if( nameScope != null )
{
namedObject = ((FrameworkTemplate)nameScope).FindName(targetName, fe);
nameScopeUsed = nameScope;
}
else
{
namedObject = fe.FindName(targetName);
nameScopeUsed = fe;
}
}
else if( fce != null )
{
Debug.Assert( nameScope == null );
namedObject = fce.FindName(targetName);
nameScopeUsed = fce;
}
else
{
throw new InvalidOperationException(
SR.Get(SRID.Storyboard_NoNameScope, targetName));
}
if( namedObject == null )
{
throw new InvalidOperationException(
SR.Get(SRID.Storyboard_NameNotFound, targetName, nameScopeUsed.GetType().ToString()));
}
targetObject = namedObject as DependencyObject;
if( targetObject == null )
{
throw new InvalidOperationException(SR.Get(SRID.Storyboard_TargetNameNotDependencyObject, targetName ));
}
return targetObject;
}
示例14: RegisterName
private void RegisterName(ObjectWriterContext ctx, string name, object inst, XamlType xamlType, INameScope nameScope, INameScope parentNameScope, bool isRoot)
{
INameScope objA = nameScope;
NameScopeDictionary dictionary = nameScope as NameScopeDictionary;
if (dictionary != null)
{
objA = dictionary.UnderlyingNameScope;
}
if (object.ReferenceEquals(objA, inst) && !isRoot)
{
nameScope = parentNameScope;
}
if (!(inst is NameFixupToken))
{
try
{
nameScope.RegisterName(name, inst);
}
catch (Exception exception)
{
if (CriticalExceptions.IsCriticalException(exception))
{
throw;
}
throw this.WithLineInfo(new XamlObjectWriterException(System.Xaml.SR.Get("NameScopeException", new object[] { exception.Message }), exception));
}
}
}
示例15: AddUniqueAccessor
static void AddUniqueAccessor(INameScope scope, Accessor accessor) {
Accessor existing = (Accessor)scope[accessor.Name, accessor.Namespace];
if (existing != null) {
if (accessor is ElementAccessor) {
throw new InvalidOperationException(Res.GetString(Res.XmlDuplicateElementName, existing.Name, existing.Namespace));
}
else {
#if DEBUG
if (!(accessor is AttributeAccessor))
throw new InvalidOperationException(Res.GetString(Res.XmlInternalErrorDetails, "Bad accessor type " + accessor.GetType().FullName));
#endif
throw new InvalidOperationException(Res.GetString(Res.XmlDuplicateAttributeName, existing.Name, existing.Namespace));
}
}
else {
scope[accessor.Name, accessor.Namespace] = accessor;
}
}