public ExportXmlOptionsControl(CommonConfiguration commonConfig, XmlOptionsControls controls)
        {
            InitializeComponent();

            this._commonConfig = commonConfig;

            LoadFromConfig();

            grBRibbon.Visibility = GetVisibilityForAttribute(controls, XmlOptionsControls.RibbonFilters);

            chBSortRibbonCommandsAndRulesById.Visibility = GetVisibilityForAttribute(controls, XmlOptionsControls.SortRibbonCommandsAndRulesById);
            chBSortFormXmlElements.Visibility            = GetVisibilityForAttribute(controls, XmlOptionsControls.SortFormXmlElements);
            chBSortXmlAttributes.Visibility = GetVisibilityForAttribute(controls, XmlOptionsControls.SortXmlAttributes);

            chBXmlAttributeOnNewLine.Visibility  = GetVisibilityForAttribute(controls, XmlOptionsControls.XmlAttributeOnNewLine);
            chBSetXmlSchemas.Visibility          = GetVisibilityForAttribute(controls, XmlOptionsControls.SetXmlSchemas);
            chBSetIntellisenseContext.Visibility = GetVisibilityForAttribute(controls, XmlOptionsControls.SetIntellisenseContext);

            chBSolutionComponentWithManagedInfo.Visibility  = GetVisibilityForAttribute(controls, XmlOptionsControls.SolutionComponentWithManagedInfo);
            chBSolutionComponentWithSolutionInfo.Visibility = GetVisibilityForAttribute(controls, XmlOptionsControls.SolutionComponentWithSolutionInfo);
            chBSolutionComponentWithUrl.Visibility          = GetVisibilityForAttribute(controls, XmlOptionsControls.SolutionComponentWithUrl);
        }
 private static System.Windows.Visibility GetVisibilityForAttribute(XmlOptionsControls controls, XmlOptionsControls attribute)
 {
     return((controls & attribute) != 0 ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed);
 }
Пример #3
0
        public static string FormatXmlByConfiguration(
            string xml
            , CommonConfiguration commonConfig
            , XmlOptionsControls xmlOptions
            , string schemaName        = null
            , string entityName        = null
            , string siteMapUniqueName = null
            , Guid?formId            = null
            , Guid?savedQueryId      = null
            , Guid?customControlId   = null
            , Guid?workflowId        = null
            , string webResourceName = null
            )
        {
            var result = xml;

            if ((xmlOptions & XmlOptionsControls.SetIntellisenseContext) != 0 &&
                commonConfig.SetIntellisenseContext
                )
            {
                if (entityName != null)
                {
                    result = ReplaceOrInsertAttribute(result, patternIntellisenseContextEntityName, replaceIntellisenseContextEntityNameFormat3, entityName);
                }

                if (siteMapUniqueName != null)
                {
                    result = ReplaceOrInsertAttribute(result, patternIntellisenseContextSiteMapNameUnique, replaceIntellisenseContextSiteMapNameUniqueFormat3, siteMapUniqueName);
                }

                if (savedQueryId.HasValue)
                {
                    result = ReplaceOrInsertAttribute(result, patternIntellisenseContextSavedQueryId, replaceIntellisenseContextSavedQueryIdFormat3, savedQueryId.ToString());
                }

                if (formId.HasValue)
                {
                    result = ReplaceOrInsertAttribute(result, patternIntellisenseContextFormId, replaceIntellisenseContextFormIdFormat3, formId.ToString());
                }

                if (customControlId.HasValue)
                {
                    result = ReplaceOrInsertAttribute(result, patternIntellisenseContextCustomControlId, replaceIntellisenseContextCustomControlIdFormat3, customControlId.ToString());
                }

                if (workflowId.HasValue)
                {
                    result = ReplaceOrInsertAttribute(result, patternIntellisenseContextWorkflowId, replaceIntellisenseContextWorkflowIdFormat3, workflowId.ToString());
                }

                if (!string.IsNullOrEmpty(webResourceName))
                {
                    result = ReplaceOrInsertAttribute(result, patternIntellisenseContextWebResourceName, replaceIntellisenseContextWebResourceNameFormat3, webResourceName);
                }

                if (entityName != null ||
                    siteMapUniqueName != null ||
                    savedQueryId.HasValue ||
                    formId.HasValue ||
                    customControlId.HasValue ||
                    workflowId.HasValue ||
                    !string.IsNullOrEmpty(webResourceName)
                    )
                {
                    result = ReplaceOrInsertAttribute(result, patternIntellisenseContext, replaceIntellisenseContextNamespaceFormat3, Intellisense.Model.IntellisenseContext.IntellisenseContextNamespace.NamespaceName);
                }
            }

            if ((xmlOptions & XmlOptionsControls.SetXmlSchemas) != 0 &&
                commonConfig.SetXmlSchemasDuringExport
                )
            {
                var schemasResources = AbstractDynamicCommandXsdSchemas.GetXsdSchemas(schemaName);

                if (schemasResources != null)
                {
                    result = ContentComparerHelper.SetXsdSchema(result, schemasResources);
                }
            }

            if (TryParseXml(result, out XElement doc))
            {
                var sortRibbonCommandsAndRulesById = (xmlOptions & XmlOptionsControls.SortRibbonCommandsAndRulesById) != 0 && commonConfig.SortRibbonCommandsAndRulesById;
                var sortFormXmlElements            = (xmlOptions & XmlOptionsControls.SortFormXmlElements) != 0 && commonConfig.SortFormXmlElements;
                var sortXmlAttributes = (xmlOptions & XmlOptionsControls.SortXmlAttributes) != 0 && commonConfig.SortXmlAttributes;

                if (sortRibbonCommandsAndRulesById)
                {
                    SortRibbonCommandsAndRulesByIdInternal(doc);
                }

                if (sortFormXmlElements)
                {
                    SortFormXmlElementsInternal(doc);
                }

                if (sortXmlAttributes)
                {
                    SortXmlAttributesInternal(doc);
                }

                if ((xmlOptions & XmlOptionsControls.XmlAttributeOnNewLine) != 0 && commonConfig.ExportXmlAttributeOnNewLine)
                {
                    return(FormatXmlNewLineOnAttributes(doc));
                }
                else
                {
                    return(doc.ToString());
                }
            }
            else
            {
                return(result);
            }
        }