Admin.AjaxHelper.UpdateExtensionSourceCode C# (CSharp) Метод

UpdateExtensionSourceCode() приватный Метод

private UpdateExtensionSourceCode ( string sourceCode, string extensionName ) : bool
sourceCode string
extensionName string
Результат bool
        public static bool UpdateExtensionSourceCode(string sourceCode, string extensionName)
        {
            if (!WebUtils.CheckRightsForAdminSettingsPage(false)) { return false; }
            if (!WebUtils.CheckIfPrimaryBlog(false)) { return false; }

            if (string.IsNullOrWhiteSpace(extensionName))
                return false;

            var ext = ExtensionManager.GetExtension(extensionName);
            if (ext == null)
                return false;

            string extensionFilename = ext.GetPathAndFilename(true);
            if (string.IsNullOrWhiteSpace(extensionFilename))
                return false;

            try
            {
                using (var f = File.CreateText(extensionFilename))
                {
                    f.Write(sourceCode);
                    f.Close();
                    return true;
                }
            }
            catch (Exception ex)
            {
                Utils.Log("Error saving source code: " + ex.Message);
                return false;
            }
        }