/////////////////////////////////////////////////////////////////////////////////////////////// #region IEnumerable Members public IEnumerator GetEnumerator() { // // NOTE: Make sure that the variable they supplied is valid before we try to // use it as the basis of our enumerator. // if (interpreter != null) { // // HACK: Handle the global "env" array specially. We must do this because // our global "env" array has no backing storage (unlike Tcl's) and // we do not have a trace operation for "get names" or "get names // and values". // if (interpreter.IsEnvironmentVariable(variable)) { IDictionary environment = Environment.GetEnvironmentVariables(); if (environment != null) { return(environment.Keys.GetEnumerator()); } else { DebugOps.Complain(interpreter, ReturnCode.Error, "environment variables unavailable"); } } else if (interpreter.IsTestsVariable(variable)) { Result error = null; StringDictionary tests = interpreter.GetAllTestInformation( false, ref error); if (tests != null) { return((IEnumerator)tests.Keys.GetEnumerator()); } else { DebugOps.Complain(interpreter, ReturnCode.Error, error); } } else if (interpreter.IsSystemArrayVariable(variable)) { ReturnCode code; StringList keys = null; Result error = null; code = MarshalOps.GetArrayElementKeys( interpreter, EntityOps.GetSystemArray(variable), StringOps.DefaultMatchMode, null, false, ref keys, ref error); if (code == ReturnCode.Ok) { return(keys.GetEnumerator()); } else { DebugOps.Complain(interpreter, code, error); } } else { #if DATA DatabaseVariable databaseVariable = null; if (interpreter.IsDatabaseVariable(variable, ref databaseVariable)) { Result error = null; ObjectDictionary database = databaseVariable.GetList( interpreter, true, false, ref error); if (database != null) { return((IEnumerator)database.Keys.GetEnumerator()); } else { DebugOps.Complain(interpreter, ReturnCode.Error, error); } } else #endif { if (variable != null) { ElementDictionary arrayValue = variable.ArrayValue; if ((arrayValue != null) && (arrayValue.Keys != null)) { return(arrayValue.Keys.GetEnumerator()); } } } } } // // NOTE: While the MSDN documentation does not seem to prohibit returning // null here, there may be components and/or applications that would // consider it "bad form"; therefore, we simply return an enumerator // that does nothing. // return(new NullEnumerator <object>()); }