/// <summary> /// Clones the specified scriptblock maintaining its language mode. /// </summary> /// <param name="ScriptBlock">The Scriptblock to clone</param> /// <returns>A clone of the scriptblock with the languagemode intact</returns> public static ScriptBlock Clone(this ScriptBlock ScriptBlock) { ScriptBlock newBlock = (ScriptBlock)UtilityHost.InvokePrivateMethod("Clone", ScriptBlock, null); UtilityHost.SetPrivateProperty("LanguageMode", newBlock, UtilityHost.GetPrivateProperty("LanguageMode", ScriptBlock)); return(newBlock); }