private static string GetPropertyValue(int cliloc, string argument, UltimaItemPropertySetter setter)
        {
            string propertyDescription = GetPropertyDescription(cliloc);
            string value = null;

            if (!String.IsNullOrEmpty(argument))
            {
                if (setter.Switch != null)
                {
                    int integer = 0;

                    if (Int32.TryParse(argument, out integer))
                    {
                        if (!setter.Switch.TryGetValue(integer, out value))
                        {
                            string format       = "Cannot find parameter '{0}' in switch setter at index '{1}' in property '{2}'. Using parameter for value.";
                            string notification = String.Format(format, argument, setter.Index, propertyDescription);
                            App.Window.ShowNotification(NotificationType.Warning, notification);
                            value = argument;
                        }
                    }
                    else
                    {
                        string format       = "Switch setter with argument '{0}' at index '{1}' in property '{2}' is not integer. Using parameter for value.";
                        string notification = String.Format(format, argument, setter.Index, propertyDescription);
                        App.Window.ShowNotification(NotificationType.Warning, notification);
                        value = argument;
                    }
                }
                else
                {
                    try
                    {
                        value = String.Format(setter.Format, argument);
                    }
                    catch
                    {
                        string format       = "Error building setter value  at index '{0}' property '{1}' is not integer. Using format for value.";
                        string notification = String.Format(format, setter.Index, propertyDescription);
                        App.Window.ShowNotification(NotificationType.Warning, notification);
                        value = setter.Format;
                    }
                }
            }
            else
            {
                value = "true";                 // Assume boolean for properties without arguments.
            }
            return(value);
        }
Exemple #2
0
        private static string GetPropertyValue( int cliloc, string argument, UltimaItemPropertySetter setter )
        {
            string propertyDescription = GetPropertyDescription( cliloc );
            string value = null;

            if ( !String.IsNullOrEmpty( argument ) )
            {
                if ( setter.Switch != null )
                {
                    int integer = 0;

                    if ( Int32.TryParse( argument, out integer ) )
                    {
                        if ( !setter.Switch.TryGetValue( integer, out value ) )
                        {
                            string format = "Cannot find parameter '{0}' in switch setter at index '{1}' in property '{2}'. Using parameter for value.";
                            string notification = String.Format( format, argument, setter.Index, propertyDescription );
                            App.Window.ShowNotification( NotificationType.Warning, notification );
                            value = argument;
                        }
                    }
                    else
                    {
                        string format = "Switch setter with argument '{0}' at index '{1}' in property '{2}' is not integer. Using parameter for value.";
                        string notification = String.Format( format, argument, setter.Index, propertyDescription );
                        App.Window.ShowNotification( NotificationType.Warning, notification );
                        value = argument;
                    }
                }
                else
                {
                    try
                    {
                        value = String.Format( setter.Format, argument );
                    }
                    catch
                    {
                        string format = "Error building setter value  at index '{0}' property '{1}' is not integer. Using format for value.";
                        string notification = String.Format( format, setter.Index, propertyDescription );
                        App.Window.ShowNotification( NotificationType.Warning, notification );
                        value = setter.Format;
                    }
                }
            }
            else
                value = "true"; // Assume boolean for properties without arguments.

            return value;
        }