FlatRedBall.Glue.GuiDisplay.NamedObjectPropertyGridDisplayer.GetIfIsCsv C# (CSharp) Method

GetIfIsCsv() public static method

public static GetIfIsCsv ( NamedObjectSave instance, string memberName ) : bool
instance FlatRedBall.Glue.SaveClasses.NamedObjectSave
memberName string
return bool
        public static bool GetIfIsCsv(NamedObjectSave instance, string memberName)
        {
            bool isCsv = false;
            // Wait!  Is this thing a CSV?  If so, we just want to use the string value and not try to translate:
            if (instance.SourceType == SaveClasses.SourceType.Entity && !string.IsNullOrEmpty(instance.SourceClassType))
            {
                EntitySave entity = ObjectFinder.Self.GetEntitySave(instance.SourceClassType);

                if (entity != null)
                {
                    CustomVariable customVariable = entity.GetCustomVariableRecursively(memberName);

                    // This may not actually be a CustomVariable, but instead could be an Object that is SetByContainer.
                    // Therefore we should tolerate a null:
                    if (customVariable != null)
                    {
                        isCsv = customVariable.GetIsCsv();
                    }
                }
            }
            return isCsv;
        }

Usage Example

示例#1
0
        public static void SetVariableOn(NamedObjectSave nos, string memberName, Type memberType, object value)
        {
            bool shouldConvertValue = false;


            if (memberType != null &&
                value is string &&
                memberType != typeof(Microsoft.Xna.Framework.Color) &&
                !CustomVariableExtensionMethods.GetIsFile(memberType) && // If it's a file, we just want to set the string value and have the underlying system do the loading
                !CustomVariableExtensionMethods.GetIsObjectType(memberType.FullName)
                )
            {
                bool isCsv = NamedObjectPropertyGridDisplayer.GetIfIsCsv(nos, memberName);
                shouldConvertValue = !isCsv &&
                                     memberType != typeof(object) &&
                                     // variable could be an object
                                     memberType != typeof(PositionedObject);
                // If the MemberType is object, then it's something we can't convert to - it's likely a state
            }

            if (shouldConvertValue)
            {
                value = PropertyValuePair.ConvertStringToType((string)value, memberType);
            }
            nos.SetPropertyValue(memberName, value);
        }