Пример #1
0
        /// <summary>
        /// Given a string specifying a type, this method returns the type.
        /// </summary>
        /// <param name="context">The current document context.</param>
        /// <param name="typeName">Type string in the form <c>sys:Int32</c>, where the prefix
        /// is a prefix currently registered in the <paramref name="context"/>, and the suffix
        /// is a type known by the namespace handler specified by the prefix.</param>
        /// <returns>Type object for the specified type string.</returns>
        public static Type ParseType(IParserContext context, string typeName)
        {
            string localName;
            string namespaceURI;

            context.LookupNamespace(typeName, out localName, out namespaceURI);
            return(context.GetNamespaceHandler(namespaceURI).GetElementType(localName));
        }
Пример #2
0
 public AttachedPropertyPathSegment(IParserContext context, string propertyProvider, string propertyName,
                                    string namespaceURI)
 {
     if (string.IsNullOrEmpty(propertyProvider))
     {
         throw new XamlParserException("Property provider name must not be empty");
     }
     if (string.IsNullOrEmpty(propertyName))
     {
         throw new XamlParserException("Property name must not be empty");
     }
     _propertyProvider = propertyProvider;
     _propertyName     = propertyName;
     _namespaceURI     = namespaceURI;
     _namespaceHandler = context.GetNamespaceHandler(namespaceURI);
 }
        void IEvaluableMarkupExtension.Initialize(IParserContext context)
        {
            string localName;
            string namespaceURI;

            context.LookupNamespace(_typeName, out localName, out namespaceURI);
            Type            type = context.GetNamespaceHandler(namespaceURI).GetElementType(localName);
            IDataDescriptor result;

            try
            {
                if (PathExpression.Compile(context, _staticMemberName).Evaluate(
                        new ValueDataDescriptor(type), out result))
                {
                    _value = result.Value;
                }
            }
            catch (XamlBindingException e)
            {
                ServiceRegistration.Get <ILogger>().Warn("Error evaluating Static markup", e);
            }
        }
Пример #4
0
        public override void FinishInitialization(IParserContext context)
        {
            // if we have a type specified in the event name, we get the RoutedEvent here
            string localName;
            string namespaceUri;

            context.LookupNamespace(Event, out localName, out namespaceUri);
            var namespaceHandler = context.GetNamespaceHandler(namespaceUri);

            if (namespaceHandler != null)
            {
                int n = localName.IndexOf('.');
                if (n >= 0)
                {
                    var sourceType = namespaceHandler.GetElementType(localName.Substring(0, n), true);
                    var eventName  = localName.Substring(n + 1);

                    _routedEvent = EventManager.GetRoutedEventForOwner(sourceType, eventName, true);
                }
                // for events without explicit set type, the type and RoutedEvent is looked up in Set/Reset on the target object type.
            }
            base.FinishInitialization(context);
        }
Пример #5
0
        public override void FinishInitialization(IParserContext context)
        {
            base.FinishInitialization(context);

            // check if RoutedEvent is from EventManager
            string localName;
            string namespaceUri;

            context.LookupNamespace(RoutedEvent, out localName, out namespaceUri);
            var namespaceHandler = context.GetNamespaceHandler(namespaceUri);

            if (namespaceHandler != null)
            {
                int n = localName.IndexOf('.');
                if (n >= 0)
                {
                    var sourceType = namespaceHandler.GetElementType(localName.Substring(0, n), true);
                    var eventName  = localName.Substring(n + 1);

                    _eventManagerEvent = EventManager.GetRoutedEventForOwner(sourceType, eventName, true);
                }
            }
        }
Пример #6
0
 /// <summary>
 /// Given a string specifying a type, this method returns the type.
 /// </summary>
 /// <param name="context">The current document context.</param>
 /// <param name="typeName">Type string in the form <c>sys:Int32</c>, where the prefix
 /// is a prefix currently registered in the <paramref name="context"/>, and the suffix
 /// is a type known by the namespace handler specified by the prefix.</param>
 /// <returns>Type object for the specified type string.</returns>
 public static Type ParseType(IParserContext context, string typeName)
 {
   string localName;
   string namespaceURI;
   context.LookupNamespace(typeName, out localName, out namespaceURI);
   return context.GetNamespaceHandler(namespaceURI).GetElementType(localName);
 }
Пример #7
0
    public override void FinishInitialization(IParserContext context)
    {
      // if we have a type specified in the event name, we get the RoutedEvent here
      string localName;
      string namespaceUri;
      context.LookupNamespace(Event, out localName, out namespaceUri);
      var namespaceHandler = context.GetNamespaceHandler(namespaceUri);
      if (namespaceHandler != null)
      {
        int n = localName.IndexOf('.');
        if (n >= 0)
        {
          var sourceType = namespaceHandler.GetElementType(localName.Substring(0, n), true);
          var eventName = localName.Substring(n + 1);

          _routedEvent = EventManager.GetRoutedEventForOwner(sourceType, eventName, true);
        }
        // for events without explicit set type, the type and RoutedEvent is looked up in Set/Reset on the target object type.
      }
      base.FinishInitialization(context);
    }
Пример #8
0
 void IEvaluableMarkupExtension.Initialize(IParserContext context)
 {
   string localName;
   string namespaceURI;
   context.LookupNamespace(_typeName, out localName, out namespaceURI);
   Type type = context.GetNamespaceHandler(namespaceURI).GetElementType(localName);
   IDataDescriptor result;
   try
   {
     if (PathExpression.Compile(context, _staticMemberName).Evaluate(
         new ValueDataDescriptor(type), out result))
       _value = result.Value;
   }
   catch (XamlBindingException e)
   {
     ServiceRegistration.Get<ILogger>().Warn("Error evaluating Static markup", e);
   }
 }