Ejemplo n.º 1
0
 private static void AddNewPosition(SortedDictionary<int, Dictionary<MergedCompiledCommandParameter, PositionalCommandParameter>> result, int positionInParameterSet, MergedCompiledCommandParameter parameter, ParameterSetSpecificMetadata parameterSetData)
 {
     if (result.ContainsKey(positionInParameterSet))
     {
         Dictionary<MergedCompiledCommandParameter, PositionalCommandParameter> positionalCommandParameters = result[positionInParameterSet];
         if (ContainsPositionalParameterInSet(positionalCommandParameters, parameter, parameterSetData.ParameterSetFlag))
         {
             throw PSTraceSource.NewInvalidOperationException();
         }
         if (positionalCommandParameters.ContainsKey(parameter))
         {
             positionalCommandParameters[parameter].ParameterSetData.Add(parameterSetData);
         }
         else
         {
             PositionalCommandParameter parameter2 = new PositionalCommandParameter(parameter);
             parameter2.ParameterSetData.Add(parameterSetData);
             positionalCommandParameters.Add(parameter, parameter2);
         }
     }
     else
     {
         Dictionary<MergedCompiledCommandParameter, PositionalCommandParameter> dictionary2 = new Dictionary<MergedCompiledCommandParameter, PositionalCommandParameter>();
         PositionalCommandParameter parameter3 = new PositionalCommandParameter(parameter) {
             ParameterSetData = { parameterSetData }
         };
         dictionary2.Add(parameter, parameter3);
         result.Add(positionInParameterSet, dictionary2);
     }
 }
Ejemplo n.º 2
0
 private static void AddNewPosition(SortedDictionary <int, Dictionary <MergedCompiledCommandParameter, PositionalCommandParameter> > result, int positionInParameterSet, MergedCompiledCommandParameter parameter, ParameterSetSpecificMetadata parameterSetData)
 {
     if (result.ContainsKey(positionInParameterSet))
     {
         Dictionary <MergedCompiledCommandParameter, PositionalCommandParameter> positionalCommandParameters = result[positionInParameterSet];
         if (ContainsPositionalParameterInSet(positionalCommandParameters, parameter, parameterSetData.ParameterSetFlag))
         {
             throw PSTraceSource.NewInvalidOperationException();
         }
         if (positionalCommandParameters.ContainsKey(parameter))
         {
             positionalCommandParameters[parameter].ParameterSetData.Add(parameterSetData);
         }
         else
         {
             PositionalCommandParameter parameter2 = new PositionalCommandParameter(parameter);
             parameter2.ParameterSetData.Add(parameterSetData);
             positionalCommandParameters.Add(parameter, parameter2);
         }
     }
     else
     {
         Dictionary <MergedCompiledCommandParameter, PositionalCommandParameter> dictionary2 = new Dictionary <MergedCompiledCommandParameter, PositionalCommandParameter>();
         PositionalCommandParameter parameter3 = new PositionalCommandParameter(parameter)
         {
             ParameterSetData = { parameterSetData }
         };
         dictionary2.Add(parameter, parameter3);
         result.Add(positionInParameterSet, dictionary2);
     }
 }
Ejemplo n.º 3
0
        } // EvaluateUnboundPositionalParameters

        private static void AddNewPosition(
            SortedDictionary<int, Dictionary<MergedCompiledCommandParameter, PositionalCommandParameter>> result,
            int positionInParameterSet,
            MergedCompiledCommandParameter parameter,
            ParameterSetSpecificMetadata parameterSetData)
        {
            Dictionary<MergedCompiledCommandParameter, PositionalCommandParameter> positionalCommandParameters;
            if (result.TryGetValue(positionInParameterSet, out positionalCommandParameters))
            {
                // Check to see if any of the other parameters in this position are in the same parameter set.
                if (ContainsPositionalParameterInSet(positionalCommandParameters, parameter, parameterSetData.ParameterSetFlag))
                {
                    // Multiple parameters were found with the same
                    // position. This means the parameter set is ambiguous.

                    // positional parameter could not be resolved

                    // We throw InvalidOperationException, which the
                    // caller will catch and throw a more
                    // appropriate exception.
                    throw PSTraceSource.NewInvalidOperationException();
                }

                PositionalCommandParameter positionalCommandParameter;
                if (!positionalCommandParameters.TryGetValue(parameter, out positionalCommandParameter))
                {
                    positionalCommandParameter = new PositionalCommandParameter(parameter);
                    positionalCommandParameters.Add(parameter, positionalCommandParameter);
                }
                positionalCommandParameter.ParameterSetData.Add(parameterSetData);
            }
            else
            {
                Dictionary<MergedCompiledCommandParameter, PositionalCommandParameter> newPositionDictionary =
                    new Dictionary<MergedCompiledCommandParameter, PositionalCommandParameter>();

                PositionalCommandParameter newPositionalParameter = new PositionalCommandParameter(parameter);
                newPositionalParameter.ParameterSetData.Add(parameterSetData);
                newPositionDictionary.Add(parameter, newPositionalParameter);

                result.Add(positionInParameterSet, newPositionDictionary);
            }
        }