private static PROPERTY_SET_TYPE DSC_ConvertToSettable(PROPERTY_DSC_TYPE propertyD) { PROPERTY_SET_TYPE propertyS = new PROPERTY_SET_TYPE(); propertyS.sysname = propertyD.sysname; propertyS.Value = propertyD.value; return(propertyS); }
private static string[] DSC_EnumerateSettableValues(PROPERTY_DSC_TYPE property) { // four cases; bool, integer, string, or list are examined here. ELEMENT_VALUE_TYPE_TYPE valueType = property.isType; // only list is enumerable if (valueType == ELEMENT_VALUE_TYPE_TYPE.list) { // return property list return(property.allowedValueList); } return(null); }
private static bool DSC_IsAllowableValue(PROPERTY_DSC_TYPE property, string value) { // if check property existence only if (value == null) { return(true); } // four cases; bool, integer, string, or list are examined here. ELEMENT_VALUE_TYPE_TYPE valueType = property.isType; if (valueType == ELEMENT_VALUE_TYPE_TYPE.@bool) { // for bool, allowable value is "true" and "false" return(value == "true" || value == "false"); } else if (valueType == ELEMENT_VALUE_TYPE_TYPE.integer) { // for integer, allowable value is the value within // specified range int intValue = int.Parse(value); ELEMENT_CONSTRAINT_TYPE[] constTypes = property.appInfo; foreach (ELEMENT_CONSTRAINT_TYPE constType in constTypes) { if (constType.name == ELEMENT_CONSTRAINT_ATTR_TYPE.minValue && intValue < int.Parse(constType.Value)) { return(false); } if (constType.name == ELEMENT_CONSTRAINT_ATTR_TYPE.maxValue && intValue > int.Parse(constType.Value)) { return(false); } } return(true); } else if (valueType == ELEMENT_VALUE_TYPE_TYPE.@string) { // for string, allowable value is the one within a range // of specified number of characters int length = value.Length; ELEMENT_CONSTRAINT_TYPE[] constTypes = property.appInfo; foreach (ELEMENT_CONSTRAINT_TYPE constType in constTypes) { if (constType.name == ELEMENT_CONSTRAINT_ATTR_TYPE.minLength && length < int.Parse(constType.Value)) { return(false); } if (constType.name == ELEMENT_CONSTRAINT_ATTR_TYPE.maxLength && length > int.Parse(constType.Value)) { return(false); } } return(true); } else if (valueType == ELEMENT_VALUE_TYPE_TYPE.list) { // for list, allowable value is the one within an allowable value list string[] validValues = property.allowedValueList; foreach (string validValue in validValues) { if (value == validValue) { return(true); } } return(false); } else // NO SUPPORT { return(true); } }