/// <summary> /// Read all the actions that are children of the actions node /// passed in and return a populated IResourceActions collection /// </summary> /// <param name="actionsNode">The actions node to be read</param> /// <returns>Populated IResourceActions collection</returns> private IResourceActions ReadActions(XPathNavigator actionsNode) { IResourceActions resourceActions = new ResourceActions(); XPathNodeIterator actionNodes = actionsNode.SelectChildren(@"Action", RESOURCE_NAMESPACE_URI); if (actionNodes != null && actionNodes.Count > 0) { while (actionNodes.MoveNext()) { XPathNavigator actionNode = actionNodes.Current; // If the action is already in the resource actions, then // overwrite it i.e. remove it first then add it in again // OK so do it better and more efficiently later IResourceAction resourceAction = ReadAction(actionNode); if (resourceActions.Contains(resourceAction)) { resourceActions.Remove(resourceAction); } resourceActions.Add(resourceAction); // determine the custom data ui handler, probably should be done elsewhere // merged with action loading actually string customUItypeName = (resourceAction as ResourceAction).CustomDataTypeUITypeName; if (customUItypeName != null) { string path = AssemblyLocation.GetPathForActionAssembly(resourceAction.Assembly); try { Assembly assembly = AssemblyLocation.LoadAssemblyFromName(path); resourceAction.CustomDataTypeUI = assembly.CreateInstance(customUItypeName) as ICustomDataType; } catch (Exception e) { StringBuilder sb = new StringBuilder(); sb.Append("XmlResourceReader.ReadAction, trying to load ICustomDataType. "); sb.Append("Ignore exception - custom UI may fail to load because the designer is being used "); sb.Append("from a workstation that doesnt have the action installed. This will be reflected in the designer UI to its user."); Logger.LogDebug(sb.ToString()); Logger.LogDebug(e); } } } } return resourceActions; }
private void Initialize(string resourceXml) { m_xmlDoc = new XmlDocument(); m_resourceActions = new ResourceActions(); m_resourceWriter = new XmlResourceWriter(m_xmlDoc); m_resourceReader = new XmlResourceReader(); m_systemProperties = new SystemProperties(); if (string.IsNullOrEmpty(resourceXml)) { resourceXml = Properties.Resources.XML_RESOURCES_DEFAULT; } if (string.IsNullOrEmpty(m_propertyText)) { m_propertyText = Properties.Resources.XML_PROPERTIES_DEFAULT; } m_xmlDoc.LoadXml(resourceXml); m_resourceActions = m_resourceReader.ReadXml(m_xmlDoc); }