private static object GetDefaultValueFor(NamedObjectSave nos, string property, string overridingType) { if (!string.IsNullOrEmpty(overridingType)) { Type overridingTypeAsType = TypeManager.GetTypeFromString(overridingType); string valueAsString = TypeManager.GetDefaultForType(overridingType); return(PropertyValuePair.ConvertStringToType(valueAsString, overridingTypeAsType)); } switch (nos.SourceType) { case SourceType.File: if (!string.IsNullOrEmpty(nos.SourceFile) && !string.IsNullOrEmpty(nos.SourceNameWithoutParenthesis)) { string absoluteFileName = ProjectManager.MakeAbsolute(nos.SourceFile, true); return(ContentParser.GetValueForProperty(absoluteFileName, nos.SourceNameWithoutParenthesis, property)); } break; case SourceType.Entity: if (!string.IsNullOrEmpty(nos.SourceClassType)) { IElement element = ObjectFinder.Self.GetIElement(nos.SourceClassType); if (element != null) { CustomVariable customVariable = element.GetCustomVariable(property); if (customVariable != null) { return(GetDefaultValueFor(customVariable, element)); } else if (property == "Visible" && element is EntitySave && ((EntitySave)element).ImplementsIVisible) { return(true); } else if (property == "Enabled" && element is EntitySave && ((EntitySave)element).ImplementsIWindow) { return(true); } } } break; case SourceType.FlatRedBallType: if (!string.IsNullOrEmpty(nos.SourceClassType)) { // See if there is a variable set for this already - there may be // now that we allow users to specify values right on FlatRedBall-type // NamedObjectSaves InstructionSave instructionSave = nos.GetCustomVariable(property); if (instructionSave != null && instructionSave.Value != null) { return(instructionSave.Value); } else { object value = GetExceptionForFlatRedBallTypeDefaultValue(nos, property); if (value != null) { return(value); } else { string classType = nos.SourceClassType; value = GetDefaultValueForPropertyInType(property, classType); return(value); } } } break; } return(null); }