public static String SaveXamlToFile(this String xaml, Guid id, OfficeDevPnP.Core.Framework.Provisioning.Connectors.FileConnectorBase connector)
        {
            using (Stream mem = new MemoryStream())
            {
                using (StreamWriter sw = new StreamWriter(mem, Encoding.Unicode, 2048, true))
                {
                    sw.Write(xaml);
                }
                mem.Position = 0;

                String xamlFileName = String.Format("{0}.xaml", id.ToString());
                connector.SaveFileStream(xamlFileName, mem);
                return (xamlFileName);
            }
        }
        public static String SaveXamlToFile(this String xaml, Guid id, OfficeDevPnP.Core.Framework.Provisioning.Connectors.FileConnectorBase connector, ListCollection lists)
        {
            // Tokenize XAML to replace any ListId attribute with the corresponding token
            XElement xamlDocument = XElement.Parse(xaml);
            var elements = (IEnumerable)xamlDocument.XPathEvaluate("//child::*[@ListId]");

            if (elements != null)
            {
                foreach (var element in elements.Cast<XElement>())
                {
                    var listId = element.Attribute("ListId").Value;
                    element.SetAttributeValue("ListId", TokenizeListIdProperty(listId, lists));
                }

                xaml = xamlDocument.ToString();
            }

            using (Stream mem = new MemoryStream())
            {
                using (StreamWriter sw = new StreamWriter(mem, Encoding.Unicode, 2048, true))
                {
                    sw.Write(xaml);
                }
                mem.Position = 0;

                String xamlFileName = String.Format("{0}.xaml", id.ToString());
                connector.SaveFileStream(xamlFileName, mem);
                return (xamlFileName);
            }
        }