internal virtual string GetPropertyString(CommonCmdletBase cmdlet, PropertyInfo propertyInfo) { string result = string.Empty; if (null == propertyInfo) { return(result); } object tempResult = string.Empty; try { tempResult = propertyInfo.GetValue(cmdlet, null) ?? string.Empty; } catch (Exception) { return(string.Empty); } if (string.IsNullOrEmpty(tempResult.ToString())) { return(result); } result += " -"; result += propertyInfo.Name; result += " "; string tempString = string.Empty; switch (tempResult.GetType().Name) { case "String": result += "\""; result += tempResult; result += "\""; return(result); case "String[]": tempString = string.Empty; foreach (string singleElement in tempResult as IEnumerable) { tempString += ","; tempString += singleElement; } if (0 < tempString.Length) { tempString = tempString.Substring(1); } result += tempString; return(result); case "IUiElement": var convertCmdlet = new ConvertToUiaSearchCriteriaCommand { Full = true }; // result += "\r\n\t"; result += convertCmdlet.ConvertElementToSearchCriteria((IUiElement)tempResult); // result += "\r\n\t"; return(result); case "IUiElement[]": var convertCmdlet2 = new ConvertToUiaSearchCriteriaCommand { Full = true }; foreach (IUiElement element in tempResult as IUiElement[]) { // result += "\r\n\t"; result += convertCmdlet2.ConvertElementToSearchCriteria(element); // result += "\r\n\t"; } return(result); case "Int32": result += tempResult.ToString(); return(result); case "SwitchParameter": bool tempBool = (SwitchParameter)tempResult; result += tempBool ? "$true" : "$false"; return(result); case "Hashtable": result += ConvertHashtableToString((Hashtable)tempResult); return(result); case "Hashtable[]": tempString = string.Empty; foreach (Hashtable hashtable in (tempResult as Hashtable[])) { tempString += ","; tempString += ConvertHashtableToString(hashtable); } if (0 < tempString.Length) { tempString = tempString.Substring(1); } result += tempString; return(result); default: result += tempResult.ToString(); return(result); } }
internal virtual string GetPropertyString(CommonCmdletBase cmdlet, PropertyInfo propertyInfo) { string result = string.Empty; if (null == propertyInfo) return result; object tempResult = string.Empty; try { tempResult = propertyInfo.GetValue(cmdlet, null) ?? string.Empty; } catch (Exception) { return string.Empty; } if (string.IsNullOrEmpty(tempResult.ToString())) return result; result += " -"; result += propertyInfo.Name; result += " "; string tempString = string.Empty; switch (tempResult.GetType().Name) { case "String": result += "\""; result += tempResult; result += "\""; return result; case "String[]": tempString = string.Empty; foreach (string singleElement in tempResult as IEnumerable) { tempString += ","; tempString += singleElement; } if (0 < tempString.Length) tempString = tempString.Substring(1); result += tempString; return result; case "IUiElement": var convertCmdlet = new ConvertToUiaSearchCriteriaCommand { Full = true }; // result += "\r\n\t"; result += convertCmdlet.ConvertElementToSearchCriteria((IUiElement)tempResult); // result += "\r\n\t"; return result; case "IUiElement[]": var convertCmdlet2 = new ConvertToUiaSearchCriteriaCommand { Full = true }; foreach (IUiElement element in tempResult as IUiElement[]) { // result += "\r\n\t"; result += convertCmdlet2.ConvertElementToSearchCriteria(element); // result += "\r\n\t"; } return result; case "Int32": result += tempResult.ToString(); return result; case "SwitchParameter": bool tempBool = (SwitchParameter)tempResult; result += tempBool ? "$true" : "$false"; return result; case "Hashtable": result += ConvertHashtableToString((Hashtable)tempResult); return result; case "Hashtable[]": tempString = string.Empty; foreach (Hashtable hashtable in (tempResult as Hashtable[])) { tempString += ","; tempString += ConvertHashtableToString(hashtable); } if (0 < tempString.Length) tempString = tempString.Substring(1); result += tempString; return result; default: result += tempResult.ToString(); return result; } }