Microsoft.Silverlight.Toolkit.Build.Tasks.DefaultStyle.GenerateXaml C# (CSharp) Method

GenerateXaml() public method

Generate the XAML markup for the default style.
public GenerateXaml ( ) : string
return string
        public string GenerateXaml()
        {
            // Create the ResourceDictionary
            string defaultNamespace = XNamespace.Xml.NamespaceName;
            Namespaces.TryGetValue("", out defaultNamespace);
            XElement resources = new XElement(XName.Get(RootElement, defaultNamespace));

            // Add the shared namespaces
            foreach (KeyValuePair<string, string> @namespace in Namespaces)
            {
                // The default namespace will be added automatically
                if (string.IsNullOrEmpty(@namespace.Key))
                {
                    continue;
                }
                resources.Add(new XAttribute(
                    XName.Get(@namespace.Key, XNamespace.Xmlns.NamespaceName),
                    @namespace.Value));
            }

            // Add the resources
            foreach (KeyValuePair<string, XElement> element in Resources)
            {
                resources.Add(
                    new XText(Environment.NewLine + Environment.NewLine + "    "),
                    new XComment("  " + element.Key + "  "),
                    new XText(Environment.NewLine + "    "),
                    element.Value);
            }

            resources.Add(new XText(Environment.NewLine + Environment.NewLine));

            // Create the document
            XDocument document = new XDocument(
                // TODO: Pull this copyright header from some shared location
                new XComment(Environment.NewLine +
                    "// (c) Copyright Microsoft Corporation." + Environment.NewLine +
                    "// This source is subject to the Microsoft Public License (Ms-PL)." + Environment.NewLine +
                    "// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details." + Environment.NewLine +
                    "// All other rights reserved." + Environment.NewLine),
                new XText(Environment.NewLine + Environment.NewLine),
                new XComment(Environment.NewLine +
                    "// WARNING:" + Environment.NewLine +
                    "// " + Environment.NewLine +
                    "// This XAML was automatically generated by merging the individual default" + Environment.NewLine +
                    "// styles.  Changes to this file may cause incorrect behavior and will be lost" + Environment.NewLine +
                    "// if the XAML is regenerated." + Environment.NewLine),
                new XText(Environment.NewLine + Environment.NewLine),
                resources);

            return document.ToString();
        }