Exemple #1
0
        public ValidationResult SetAttribute(string attribute, object value)
        {
            if (attribute == "name")
            {
                if (!(value is string))
                {
                    return(new ValidationResult {
                        Valid = false, Message = ValidationMessage.InvalidAttributeName
                    });
                }

                ValidationResult result;

                result = m_controller.CanRename(m_element, (string)value);
                if (!result.Valid)
                {
                    return(result);
                }

                if (m_element.Fields[FieldDefinitions.Anonymous])
                {
                    m_element.Fields[FieldDefinitions.Anonymous] = false;
                }
            }

            if (!Utility.IsValidAttributeName(attribute))
            {
                return(new ValidationResult {
                    Valid = false, Message = ValidationMessage.InvalidAttributeName
                });
            }

            IDataWrapper wrapper = value as IDataWrapper;

            if (wrapper != null)
            {
                value = wrapper.GetUnderlyingValue();
            }

            string oldName = null;

            if (attribute == "name")
            {
                oldName = m_element.Name;
            }

            m_element.Fields.Set(attribute, value);

            if (attribute == "name")
            {
                m_controller.UpdateDictionariesReferencingRenamedObject(oldName, (string)value);
            }

            return(new ValidationResult {
                Valid = true
            });
        }
Exemple #2
0
        public override void SetParameter(string index, object value)
        {
            object       valueToSet   = value;
            IDataWrapper wrappedValue = value as IDataWrapper;

            if (wrappedValue != null)
            {
                valueToSet = wrappedValue.GetUnderlyingValue();
            }

            if (EditorName.StartsWith("(function)"))
            {
                if (index == "script")
                {
                    throw new NotImplementedException();
                }
                FunctionCallScript.SetFunctionCallParameter(int.Parse(index), valueToSet);
                return;
            }
            Script.SetParameter(int.Parse(index), valueToSet);
        }