static private CreateVariableNotWritableError ( |
||
variable | ||
Результат |
internal static SessionStateUnauthorizedAccessException CreateVariableNotWritableError(PSVariable variable)
{
string message = String.Format("Cannot overwrite variable {0} because it is read-only or constant.", variable.Name);
return CreateError(variable, message, "VariableNotWritable");
}
private static void CheckVariableCanBeChanged(PSVariable variable, bool force = false) { if ((variable.ItemOptions.HasFlag(ScopedItemOptions.ReadOnly) && !force) || variable.ItemOptions.HasFlag(ScopedItemOptions.Constant)) { var ex = SessionStateUnauthorizedAccessException.CreateVariableNotWritableError(variable); throw ex; } ThrowIfVariableIsPrivate(variable); }