Represents a .xaml document.
		public XamlTypeResolverProvider(XamlObject containingObject)
		{
			if (containingObject == null)
				throw new ArgumentNullException("containingObject");
			this.document = containingObject.OwnerDocument;
			this.containingObject = containingObject;
		}
예제 #2
0
		internal XamlTextValue(XamlDocument document, string textValue)
		{
			this.document = document;
			if (textValue.StartsWith("{"))
				textValue = "{}" + textValue;
			this.textValue = textValue;
		}
예제 #3
0
 public XamlTypeResolverProvider(XamlObject containingObject)
 {
     if (containingObject == null)
     {
         throw new ArgumentNullException("containingObject");
     }
     this.document         = containingObject.OwnerDocument;
     this.containingObject = containingObject;
 }
예제 #4
0
 internal XamlTextValue(XamlDocument document, string textValue)
 {
     this.document = document;
     if (textValue.StartsWith("{"))
     {
         textValue = "{}" + textValue;
     }
     this.textValue = textValue;
 }
예제 #5
0
			public DummyTypeDescriptorContext(XamlDocument document, XamlObject containingObject)
			{
				if (containingObject != null) {
					if (containingObject.OwnerDocument != document)
						throw new ArgumentException("Containing object must belong to the document!");
					baseServiceProvider = containingObject.ServiceProvider;
				} else {
					baseServiceProvider = document.ServiceProvider;
				}
			}
예제 #6
0
		/// <summary>For use by XamlParser only.</summary>
		internal XamlObject(XamlDocument document, XmlElement element, Type elementType, object instance)
		{
			this.document = document;
			this.element = element;
			this.elementType = elementType;
			this.instance = instance;

			var contentAttrs = elementType.GetCustomAttributes(typeof(ContentPropertyAttribute), true) as ContentPropertyAttribute[];
			if (contentAttrs != null && contentAttrs.Length > 0) {
				this.contentPropertyName = contentAttrs[0].Name;
			}

			ServiceProvider = new XamlObjectServiceProvider(this);
			CreateWrapper();
		}
예제 #7
0
        /// <summary>For use by XamlParser only.</summary>
        internal XamlObject(XamlDocument document, XmlElement element, Type elementType, object instance)
        {
            this.document    = document;
            this.element     = element;
            this.elementType = elementType;
            this.instance    = instance;

            var contentAttrs = elementType.GetCustomAttributes(typeof(ContentPropertyAttribute), true) as ContentPropertyAttribute[];

            if (contentAttrs != null && contentAttrs.Length > 0)
            {
                this.contentPropertyName = contentAttrs[0].Name;
            }

            ServiceProvider = new XamlObjectServiceProvider(this);
            CreateWrapper();
        }
예제 #8
0
		/// <summary>For use by XamlParser only.</summary>
		internal XamlObject(XamlDocument document, XmlElement element, Type elementType, object instance)
		{
			this.document = document;
			this.element = element;
			this.elementType = elementType;
			this.instance = instance;

			this.contentPropertyName = GetContentPropertyName(elementType);

			ServiceProvider = new XamlObjectServiceProvider(this);
			CreateWrapper();
			
			var rnpAttrs = elementType.GetCustomAttributes(typeof(RuntimeNamePropertyAttribute), true) as RuntimeNamePropertyAttribute[];
			if (rnpAttrs != null && rnpAttrs.Length > 0 && !String.IsNullOrEmpty(rnpAttrs[0].Name)) {
				runtimeNameProperty = rnpAttrs[0].Name;
			}
		}
예제 #9
0
        /// <summary>For use by XamlParser only.</summary>
        internal XamlObject(XamlDocument document, XmlElement element, Type elementType, object instance)
        {
            this.document    = document;
            this.element     = element;
            this.elementType = elementType;
            this.instance    = instance;

            this.contentPropertyName = GetContentPropertyName(elementType);

            ServiceProvider = new XamlObjectServiceProvider(this);
            CreateWrapper();

            var rnpAttrs = elementType.GetCustomAttributes(typeof(RuntimeNamePropertyAttribute), true) as RuntimeNamePropertyAttribute[];

            if (rnpAttrs != null && rnpAttrs.Length > 0 && !String.IsNullOrEmpty(rnpAttrs[0].Name))
            {
                runtimeNameProperty = rnpAttrs[0].Name;
            }
        }
예제 #10
0
        static XmlNode FindChildNode(XmlNode node, Type elementType, string propertyName, XamlDocument xamlDocument)
        {
            var localName       = elementType.Name + "." + propertyName;
            var namespacesURI   = xamlDocument.GetNamespacesFor(elementType);
            var clrNamespaceURI = xamlDocument.GetNamespaceFor(elementType, true);

            foreach (XmlNode childNode in node.ChildNodes)
            {
                if (childNode.LocalName == localName && (namespacesURI.Contains(childNode.NamespaceURI) || childNode.NamespaceURI == clrNamespaceURI))
                {
                    return(childNode);
                }
            }

            var type = elementType.BaseType;

            namespacesURI = xamlDocument.GetNamespacesFor(type);

            while (type != typeof(object))
            {
                if (type.GetProperty(propertyName) == null)
                {
                    break;
                }

                localName = type.Name + "." + propertyName;

                foreach (XmlNode childNode in node.ChildNodes)
                {
                    if (childNode.LocalName == localName && namespacesURI.Contains(childNode.NamespaceURI))
                    {
                        return(childNode);
                    }
                }

                type = type.BaseType;
            }

            return(null);
        }
예제 #11
0
 internal XamlTextValue(XamlDocument document, XmlCDataSection cDataSection, XmlSpace xmlSpace)
 {
     this.document     = document;
     this.xmlSpace     = xmlSpace;
     this.cDataSection = cDataSection;
 }
예제 #12
0
 internal XamlTextValue(XamlDocument document, XmlText textNode, XmlSpace xmlSpace)
 {
     this.document = document;
     this.xmlSpace = xmlSpace;
     this.textNode = textNode;
 }
예제 #13
0
		internal XamlTextValue(XamlDocument document, string textValue)
		{
			this.document = document;
			this.textValue = textValue;
		}
예제 #14
0
 internal XamlTextValue(XamlDocument document, string textValue)
 {
     this.document  = document;
     this.textValue = textValue;
 }
예제 #15
0
		/// <summary>
		/// Creates a new XamlDesignContext instance.
		/// </summary>
		public XamlDesignContext(XmlReader xamlReader, XamlLoadSettings loadSettings)
		{
			if (xamlReader == null)
				throw new ArgumentNullException("xamlReader");
			if (loadSettings == null)
				throw new ArgumentNullException("loadSettings");
			
			this.Services.AddService(typeof(ISelectionService), new DefaultSelectionService());
			this.Services.AddService(typeof(IToolService), new DefaultToolService(this));
			this.Services.AddService(typeof(UndoService), new UndoService());
			this.Services.AddService(typeof(IErrorService), new DefaultErrorService(this));
			this.Services.AddService(typeof(ViewService), new DefaultViewService(this));
			this.Services.AddService(typeof(OptionService), new OptionService());

			var xamlErrorService = new XamlErrorService();
			this.Services.AddService(typeof(XamlErrorService), xamlErrorService);
			this.Services.AddService(typeof(IXamlErrorSink), xamlErrorService);
			
			_componentService = new XamlComponentService(this);
			this.Services.AddService(typeof(IComponentService), _componentService);
			
			foreach (Action<XamlDesignContext> action in loadSettings.CustomServiceRegisterFunctions) {
				action(this);
			}
			
			// register default versions of overridable services:
			if (this.Services.GetService(typeof(ITopLevelWindowService)) == null) {
				this.Services.AddService(typeof(ITopLevelWindowService), new WpfTopLevelWindowService());
			}
			
			// register extensions from the designer assemblies:
			foreach (Assembly designerAssembly in loadSettings.DesignerAssemblies) {
				this.Services.ExtensionManager.RegisterAssembly(designerAssembly);
				EditorManager.RegisterAssembly(designerAssembly);
			}
			
			_parserSettings = new XamlParserSettings();
			_parserSettings.TypeFinder = loadSettings.TypeFinder;
			_parserSettings.CreateInstanceCallback = this.Services.ExtensionManager.CreateInstanceWithCustomInstanceFactory;
			_parserSettings.ServiceProvider = this.Services;
			_doc = XamlParser.Parse(xamlReader, _parserSettings);
			
			loadSettings.ReportErrors(xamlErrorService);
			
			if (_doc == null) {
				string message;
				if (xamlErrorService != null && xamlErrorService.Errors.Count > 0)
					message = xamlErrorService.Errors[0].Message;
				else
					message = "Could not load document.";
				throw new XamlLoadException(message);
			}
			
			_rootItem = _componentService.RegisterXamlComponentRecursive(_doc.RootElement);
			
			if(_rootItem!=null){
				var rootBehavior=new RootItemBehavior();
				rootBehavior.Intialize(this);
			}
				
			
			_xamlEditOperations=new XamlEditOperations(this,_parserSettings);
		}
예제 #16
0
		internal XamlTextValue(XamlDocument document, XmlCDataSection cDataSection, XmlSpace xmlSpace)
		{
			this.document = document;
			this.xmlSpace = xmlSpace;
			this.cDataSection = cDataSection;
		}
예제 #17
0
		internal XamlTextValue(XamlDocument document, XmlText textNode, XmlSpace xmlSpace)
		{
			this.document = document;
			this.xmlSpace = xmlSpace;
			this.textNode = textNode;
		}
예제 #18
0
		static XmlNode FindChildNode(XmlNode node, Type elementType, string propertyName, XamlDocument xamlDocument)
		{
			var localName = elementType.Name + "." + propertyName;
			var namespacesURI = xamlDocument.GetNamespacesFor(elementType);
			var clrNamespaceURI = xamlDocument.GetNamespaceFor(elementType, true);

			foreach (XmlNode childNode in node.ChildNodes)
			{
				if (childNode.LocalName == localName && (namespacesURI.Contains(childNode.NamespaceURI) || childNode.NamespaceURI == clrNamespaceURI))
				{
					return childNode;
				}
			}

			var type = elementType.BaseType;
			namespacesURI = xamlDocument.GetNamespacesFor(type);

			while (type != typeof(object))
			{
				if (type.GetProperty(propertyName) == null)
					break;

				localName = type.Name + "." + propertyName;

				foreach (XmlNode childNode in node.ChildNodes)
				{
					if (childNode.LocalName == localName && namespacesURI.Contains(childNode.NamespaceURI))
					{
						return childNode;
					}
				}

				type = type.BaseType;
			}
			
			return null;
		}
예제 #19
0
 internal XamlTextValue(XamlDocument document, XmlAttribute attribute)
 {
     this.document  = document;
     this.attribute = attribute;
 }
예제 #20
0
		internal XamlTextValue(XamlDocument document, XmlAttribute attribute)
		{
			this.document = document;
			this.attribute = attribute;
		}