private static void PopulateParameterSets(ResourceType resourceType, PSCmdletInfo cmdletInfo, XElement parameterSetsNodeRoot) { XNamespace xNamespace = "http://schemas.microsoft.com/powershell-web-services/2010/09"; XElement firstNode = (XElement)parameterSetsNodeRoot.FirstNode; while (firstNode != null) { PSParameterSet pSParameterSet = new PSParameterSet(firstNode.GetUniqueElement("http://schemas.microsoft.com/powershell-web-services/2010/09", "Name").Value); foreach (XElement xElement in firstNode.Elements(xNamespace + "Parameter")) { string value = xElement.GetUniqueElement("http://schemas.microsoft.com/powershell-web-services/2010/09", "Name").Value; XElement xElement1 = xElement.TryGetUniqueElement("http://schemas.microsoft.com/powershell-web-services/2010/09", "IsSwitch"); bool flag = false; if (xElement1 != null) { try { flag = (bool)TypeConverter.ConvertTo(xElement1.Value, typeof(bool)); } catch (InvalidCastException invalidCastException1) { InvalidCastException invalidCastException = invalidCastException1; object[] objArray = new object[1]; objArray[0] = xElement1.Value; throw new MetadataException(ExceptionHelpers.GetExceptionMessage(invalidCastException, Resources.InvalidSwitchParameterValue, objArray), invalidCastException); } } XElement xElement2 = xElement.TryGetUniqueElement("http://schemas.microsoft.com/powershell-web-services/2010/09", "IsMandatory"); bool flag1 = false; if (xElement2 != null) { try { flag1 = (bool)TypeConverter.ConvertTo(xElement2.Value, typeof(bool)); } catch (InvalidCastException invalidCastException3) { InvalidCastException invalidCastException2 = invalidCastException3; object[] value1 = new object[1]; value1[0] = xElement2.Value; throw new MetadataException(ExceptionHelpers.GetExceptionMessage(invalidCastException2, Resources.InvalidSwitchParameterValue, value1), invalidCastException2); } } string str = null; XElement xElement3 = xElement.TryGetUniqueElement("http://schemas.microsoft.com/powershell-web-services/2010/09", "Type"); if (xElement3 != null) { str = xElement3.Value; } pSParameterSet.Parameters.Add(value, new PSParameterInfo(flag, flag1, str)); } firstNode = (XElement)firstNode.NextNode; cmdletInfo.ParameterSets.Add(pSParameterSet); } try { cmdletInfo.ThrowIfInvalidState(resourceType); } catch (InvalidOperationException invalidOperationException1) { InvalidOperationException invalidOperationException = invalidOperationException1; object[] cmdletName = new object[2]; cmdletName[0] = cmdletInfo.CmdletName; cmdletName[1] = invalidOperationException.Message; throw new MetadataException(ExceptionHelpers.GetExceptionMessage(invalidOperationException, Resources.FieldOptionOrMandatoryParameterNotInParamset, cmdletName), invalidOperationException); } }