예제 #1
0
        /// <summary>
        /// Holds routines that are useful in multiple actions.
        /// </summary>
        public static string Generate()
        {
            SetupXamlInformation compileFeatures = new SetupXamlInformation();

            _EnsureInitialized();

            return(_GenerateTree(_generator, compileFeatures));
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        public static string PostProcess(string xmlContent, SetupXamlInformation ppParams)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(xmlContent);

            CleanupXamlFile(xmlDoc, ppParams);
            ApplyResourceKeysInXaml(xmlDoc);

            return(xmlDoc.OuterXml);
        }
예제 #3
0
        private static void CleaningResources(XmlNode node, SetupXamlInformation ppParams)
        {
            if (WPFXamlGenerator.IsResourceDictionaryNode(node))
            {
                foreach (XmlNode childResourceNode in node.ChildNodes)
                {
                    XmlElement childResource = childResourceNode as XmlElement;

                    if (childResource == null)
                    {
                        continue;
                    }

                    if (!GetXSharedXmlNodeValue(childResource))
                    {
                        // x:Shared is value is already False;

                        continue;
                    }

                    Type resourceType = FindType(childResource);


                    if (typeof(Visual).IsAssignableFrom(resourceType) || typeof(ContentElement).IsAssignableFrom(resourceType))
                    {
                        if (!ppParams.EnableXamlCompilationFeatures)
                        {
                            node.RemoveChild(childResourceNode);
                        }
                        else
                        {
                            WPFXamlGenerator.SetXSharedValue(childResource, "false");
                        }
                    }
                }
            }
            else
            {
                foreach (XmlNode n in node.ChildNodes)
                {
                    CleaningResources(n, ppParams);
                }
            }
        }
예제 #4
0
        private static string _GenerateTree(XamlGenerator generator, SetupXamlInformation setupXamlInfo)
        {
            if (setupXamlInfo == null)
            {
                throw new ArgumentNullException("setupXamlInfo");
            }

            _setupXamlInfo = setupXamlInfo;

            //
            // Generate xaml using XamlGenerator.
            // Note: generator code was referenced from ClientTestLibrary directory.
            //

            int maxTotalElements = _xamlDefinition.MaxTotalElements;
            int maxAttributes    = _xamlDefinition.MaxAttributes;
            int maxChildren      = _xamlDefinition.MaxChildren;
            int maxDepth         = _xamlDefinition.MaxDepth;

            DateTime start  = DateTime.Now;
            Stream   stream = generator.CreateStream(maxDepth, maxAttributes, maxChildren); // maxDepth, maxAttributes, maxChildren

            string xaml = "";

            // Store xaml in string.
            using (StreamReader sr = new StreamReader(stream))
            {
                xaml = sr.ReadToEnd();
            }


            xaml = ModifyXaml.PostProcess(xaml, setupXamlInfo);

            OnXamlGenerated(xaml);

            //
            // Return root of generated tree or the string depending of the parseXaml argument.
            //
            return(xaml);
        }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 private static void CleanupXamlFile(XmlDocument xmlDoc, SetupXamlInformation ppParams)
 {
     CleaningResources(xmlDoc.DocumentElement, ppParams);
 }
예제 #6
0
 /// <summary>
 /// Holds routines that are useful in multiple actions.
 /// </summary>
 public static string GenerateWindow(SetupXamlInformation compileFeatures)
 {
     _EnsureInitialized();
     return(_GenerateTree(_windowGenerator, compileFeatures));
 }
예제 #7
0
 /// <summary>
 /// Holds routines that are useful in multiple actions.
 /// </summary>
 public static string GenerateResourceDictionary(SetupXamlInformation compileFeatures)
 {
     _EnsureInitialized();
     return(_GenerateTree(_resourceGenerator, compileFeatures));
 }
예제 #8
0
 /// <summary>
 /// Holds routines that are useful in multiple actions.
 /// </summary>
 public static string GenerateFreezable(SetupXamlInformation compileFeatures)
 {
     _EnsureInitialized();
     return(_GenerateTree(_freezableGenerator, compileFeatures));
 }