public XamlTypeResolverProvider(XamlObject containingObject) { if (containingObject == null) throw new ArgumentNullException("containingObject"); this.document = containingObject.OwnerDocument; this.containingObject = containingObject; }
internal XamlTextValue(XamlDocument document, string textValue) { this.document = document; if (textValue.StartsWith("{")) textValue = "{}" + textValue; this.textValue = textValue; }
public XamlTypeResolverProvider(XamlObject containingObject) { if (containingObject == null) { throw new ArgumentNullException("containingObject"); } this.document = containingObject.OwnerDocument; this.containingObject = containingObject; }
internal XamlTextValue(XamlDocument document, string textValue) { this.document = document; if (textValue.StartsWith("{")) { textValue = "{}" + textValue; } this.textValue = textValue; }
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; } }
/// <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(); }
/// <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; } }
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); }
internal XamlTextValue(XamlDocument document, XmlCDataSection cDataSection, XmlSpace xmlSpace) { this.document = document; this.xmlSpace = xmlSpace; this.cDataSection = cDataSection; }
internal XamlTextValue(XamlDocument document, XmlText textNode, XmlSpace xmlSpace) { this.document = document; this.xmlSpace = xmlSpace; this.textNode = textNode; }
internal XamlTextValue(XamlDocument document, string textValue) { this.document = document; this.textValue = textValue; }
/// <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); }
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; }
internal XamlTextValue(XamlDocument document, XmlAttribute attribute) { this.document = document; this.attribute = attribute; }