private string GetUserDefinedNamespaceScript() { // Get namespace. string ns = _settingProvider.GetNamespace(); // Validate namespace. if (String.IsNullOrEmpty(ns)) { // Return empty string. return(String.Empty); } // Get array of objects we need to create on client side. string[] objects = ns.Split('.'); // Check if we ahve any object names. if (objects == null || objects.Length == 0) { // Return empty string. return(String.Empty); } // Initialize result string. string result = String.Empty; for (int i = 0; i < objects.Length; i++) { // Get first required part of namespace. string temp = String.Join(".", objects.Skip(0).Take(i + 1).ToArray()); // Add namespace decleration to result. if (i == objects.Length - 1) { result += String.Format("{0} = window.{0} || ", temp); } else { result += String.Format("{0} = window.{0} || {{}};", temp); } } // Return result. return(result); }