示例#1
0
        /// <inheritdoc/>
        protected internal override void CloneElement(int index)
        {
            int size = array.GetLength(0) + 1;

            ElementType[] newArray = new ElementType[size];

            object clonedEntry = null;

            for (int i = 0; i < array.GetLength(0); i++)
            {
                object value = array.GetValue(i);
                newArray.SetValue(value, i);

                if (i == index)
                {
                    if (value == null)
                    {
                        clonedEntry = null;
                    }
                    else
                    {
                        clonedEntry = SerializableUtility.Clone(value);
                    }
                }
            }

            newArray.SetValue(clonedEntry, size - 1);

            array = newArray;

            if (OnChanged != null)
            {
                OnChanged(array);
            }
        }
            /// <inheritdoc/>
            protected internal override void CloneElement(int index)
            {
                SerializableArray array = property.GetArray();

                int   size     = array.GetLength() + 1;
                Array newArray = property.CreateArrayInstance(new int[] { size });

                object clonedEntry = null;

                for (int i = 0; i < array.GetLength(); i++)
                {
                    object value = array.GetProperty(i).GetValue <object>();

                    newArray.SetValue(value, i);

                    if (i == index)
                    {
                        clonedEntry = SerializableUtility.Clone(array.GetProperty(i).GetValue <object>());
                    }
                }

                newArray.SetValue(clonedEntry, size - 1);

                property.SetValue(newArray);
                this.array  = newArray;
                numElements = newArray.Length;
            }
            /// <inheritdoc/>
            protected internal override KeyValuePair <object, object> CloneElement(int index)
            {
                RecordStateForUndo();

                SerializableProperty keyProperty   = (SerializableProperty)GetKey(index);
                SerializableProperty valueProperty = (SerializableProperty)GetValue(keyProperty);

                SerializableDictionary dictionary = property.GetDictionary();

                DictionaryDataWrapper keyData = new DictionaryDataWrapper();

                keyData.value = SerializableUtility.Clone(keyProperty.GetValue <object>());

                SerializableProperty clonedKeyProperty = new SerializableProperty(dictionary.KeyPropertyType,
                                                                                  dictionary.KeyType,
                                                                                  () => keyData.value, (x) => keyData.value = x);

                DictionaryDataWrapper valueData = new DictionaryDataWrapper();

                valueData.value = SerializableUtility.Clone(valueProperty.GetValue <object>());

                SerializableProperty clonedValueProperty = new SerializableProperty(dictionary.ValuePropertyType,
                                                                                    dictionary.ValueType,
                                                                                    () => valueData.value, (x) => valueData.value = x);

                return(new KeyValuePair <object, object>(clonedKeyProperty, clonedValueProperty));
            }
        /// <inheritdoc/>
        protected internal override KeyValuePair <object, object> CloneElement(int index)
        {
            object key   = GetKey(index);
            object value = GetValue(key);

            KeyValuePair <object, object> clone = new KeyValuePair <object, object>(
                SerializableUtility.Clone(key), SerializableUtility.Clone(value));

            return(clone);
        }
示例#5
0
            /// <inheritdoc/>
            protected internal override void CloneElement(int index)
            {
                SerializableList serializableList = property.GetList();

                if (index >= 0 && index < list.Count)
                {
                    list.Add(SerializableUtility.Clone(serializableList.GetProperty(index).GetValue <object>()));
                }

                numElements = list.Count;
            }
            /// <inheritdoc/>
            protected internal override object CreateValue()
            {
                SerializableDictionary dictionary = property.GetDictionary();

                DictionaryDataWrapper data = new DictionaryDataWrapper();

                data.value = SerializableUtility.Create(dictionary.ValueType);

                SerializableProperty valueProperty = new SerializableProperty(dictionary.ValuePropertyType,
                                                                              dictionary.ValueType,
                                                                              () => data.value, (x) => data.value = x);

                return(valueProperty);
            }
示例#7
0
        /// <inheritdoc/>
        protected internal override void CloneElement(int index)
        {
            object clonedEntry = null;

            if (list[index] != null)
            {
                clonedEntry = SerializableUtility.Clone(list[index]);
            }

            list.Add((ElementType)clonedEntry);

            if (OnValueChanged != null)
            {
                OnValueChanged();
            }
        }
 /// <inheritdoc/>
 protected internal override object CreateValue()
 {
     return(SerializableUtility.Create <Value>());
 }
 /// <inheritdoc/>
 protected internal override object CreateKey()
 {
     return(SerializableUtility.Create <Key>());
 }