private FrameworkElement CreateBranchPresentation(XrmUri branchKey)
        {
            XrmUriEditor uiCondition = new XrmUriEditor(nodeSelectionManager.ConfigManager) {
                XrmUri = branchKey,
                Margin = new Thickness(5, 2, 5, 2)
            };
            Grid.SetColumn(uiCondition, 0);

            TargetNodeSelector uiTargetSelector = new TargetNodeSelector {
                Margin = new Thickness(5, 2, 10, 2),
            };
            uiTargetSelector.Initialize(nodeSelectionManager, node, () => node.Branches[branchKey], delegate(NodeConfiguration targetNode) {
                node.Branches[branchKey] = targetNode;
            });
            Grid.SetColumn(uiTargetSelector, 1);

            Grid result = new Grid {
                Tag = branchKey,
                ColumnDefinitions = {
                    new ColumnDefinition { Width=new GridLength(1, GridUnitType.Star) },
                    new ColumnDefinition { Width=new GridLength(1, GridUnitType.Auto) }
                },
                Children = { uiCondition, uiTargetSelector }
            };
            return result;
        }
Esempio n. 2
0
        internal XrmUriEditor(ConfigurationManager configManager)
        {
            InitializeComponent();

            this.configManager = configManager;
            XrmUri = new XrmUri();
        }
        public void WriteDefaultValueToXElement(XElement target, object defaultValue)
        {
            if (defaultValue == null) {
                WriteDefaultValueToXElement(target);
                return;
            }

            if (!(defaultValue is string)) {
                throw new InvalidOperationException("Default value for configuration item of type XrmUri must be string.");
            }
            string xpath = (string)defaultValue;
            XrmUri value = new XrmUri(xpath);
            WriteToXElement(target, value);
        }
        internal CbrNodePropertiesEditor(CbrNodeConfiguration node, NodeSelectionManager nodeSelectionManager)
        {
            InitializeComponent();
            this.node = node;
            this.nodeSelectionManager = nodeSelectionManager;

            uiName.Text = node.Name;

            if (node.TestedSelection == null) {
                node.TestedSelection = new TokenSelection();
            }
            uiTestedMessage.Selection = node.TestedSelection;

            uiDefaultTargetSelector.Initialize(nodeSelectionManager, node, () => node.DefaultTarget, delegate(NodeConfiguration defaultTarget) {
                node.DefaultTarget = defaultTarget;
            });

            #region Prepare branches
            uiBranches.Initialize(delegate {
                XrmUri branchKey = new XrmUri();
                node.Branches.Add(branchKey, null);
                return CreateBranchPresentation(branchKey);
            });
            uiBranches.ItemRemoved += delegate(FrameworkElement uiBranch) {
                XrmUri branchKey = (XrmUri)uiBranch.Tag;
                node.Branches.Remove(branchKey);
                nodeSelectionManager.MessageflowGraphPresenter.RaiseGraphChanged();
            };
            uiBranches.ItemAdded += delegate(FrameworkElement uiBranch) {
                nodeSelectionManager.MessageflowGraphPresenter.RaiseGraphChanged();
            };
            foreach (XrmUri branchKey in node.Branches.Keys) {
                uiBranches.AddItem(CreateBranchPresentation(branchKey));
            }
            #endregion

            #region Prepare uiTestXml
            uiTestXml.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML");
            uiTestXml.Options.ConvertTabsToSpaces = true;
            uiTestXml.Options.IndentationSize = 4;
            uiTestXml.ShowLineNumbers = true;
            #endregion
        }
Esempio n. 5
0
        /// <summary>
        /// Maps a URI to an object containing the actual resource.
        /// </summary>
        /// <remarks>
        /// When the scheme of the URI is xrm:// the resource is loaded from
        /// the XML resource manager, otherwise the default behavior of
        /// XmlUrlResolver is used.
        /// </remarks>
        /// <param name="absoluteUri">absolute URI of the resource</param>
        /// <param name="role">not used</param>
        /// <param name="ofObjectToReturn">type of object to return;
        /// System.IO.Stream or null</param>
        /// <returns>Stream containing the resource</returns>
        public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
        {
            if (absoluteUri == null) {
                throw new ArgumentNullException("absoluteUri");
            }

            if ((absoluteUri.Scheme == "xrm") && ((ofObjectToReturn == null) || (ofObjectToReturn == typeof(Stream)))) {
                XrmUri xrmUri = new XrmUri(absoluteUri);
                XDocument xdocument = XrmResourceProvider(xrmUri);
                if (xdocument == null) {
                    return null;
                }

                MemoryStream memoryStream = new MemoryStream();
                using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream)) {
                    xdocument.WriteTo(xmlWriter);
                }
                memoryStream.Position = 0;
                return memoryStream;
            } else {
                //otherwise use the default behavior of the XmlUrlResolver class (resolve resources from source)
                return base.GetEntity(absoluteUri, role, ofObjectToReturn);
            }
        }
Esempio n. 6
0
 public XDocument Resolve(string href)
 {
     XrmUri xrmUri = new XrmUri(href);
     XDocument result = xrmResourceProvider(xrmUri);
     return result;
 }
Esempio n. 7
0
 /// <summary>
 /// Sets the contents of a XML resource specified by its 
 /// </summary>
 /// <param name="resourceUri">XRM URI of the resource to be stored
 /// </param>
 /// <param name="resourceContent">contents of the XML resource</param>
 public void SetXmlResource(XrmUri resourceUri, XDocument resourceContent)
 {
     throw new NotImplementedException();
 }
Esempio n. 8
0
 /// <summary>
 /// Gets the contents of a XML resource specified by its XRM URI.
 /// </summary>
 /// <param name="resourceUri">XRM URI of the requested resource</param>
 /// <returns>requested XML resource or null the there is no such a
 /// resource corresponding to the provided XRM URI or the resource is
 /// empty</returns>
 public XDocument GetXmlResource(XrmUri resourceUri)
 {
     XDocument content = storage.LoadXml();
     XDocument result = resourceUri.GetResource(content);
     return result;
 }
 public void WriteDefaultValueToXElement(XElement target)
 {
     XrmUri defaultValue = new XrmUri();
     WriteToXElement(target, defaultValue);
 }
 private XDocument GetXrmResource(XrmUri xrmUri)
 {
     XDocument xrmContent = nodeSelectionManager.AppConfig.GetXrmContent();
     XDocument result = xrmUri.GetResource(xrmContent);
     return result;
 }
Esempio n. 11
0
 public SerializableXDocument GetXmlResource(XrmUri target)
 {
     XDocument xmlResource = xmlResourceManager.GetXmlResource(target);
     return new SerializableXDocument(xmlResource);
 }
Esempio n. 12
0
 /// <summary>
 /// Obtains a XML resource identified its XRM URI from a XML resource
 /// storage.
 /// </summary>
 /// <param name="target">XRM URI of the requested resource</param>
 /// <returns>the requested resource XML resource; or null if none was
 /// found</returns>
 /// <seealso cref="XRouter.Common.Xrm.XmlResourceManager"/>
 public XDocument GetXmlResource(XrmUri target)
 {
     var result = BrokerService.GetXmlResource(target);
     return result.XDocument;
 }