Esempio n. 1
0
        public static void SetValue(this List <PropertySave> propertySaveList, string nameToSearchFor, object value)
        {
            bool isDefault = IsValueDefault(value);

            if (isDefault)
            {
                propertySaveList.Remove(nameToSearchFor);
            }
            else
            {
                var existingProperty = propertySaveList.FirstOrDefault(item => item.Name == nameToSearchFor);
                if (existingProperty != null)
                {
                    existingProperty.Value = value;
                }
                else
                {
                    // If we got here then that means there isn't already something in place for this
                    PropertySave newPropertySave = new PropertySave();
                    newPropertySave.Name  = nameToSearchFor;
                    newPropertySave.Value = value;
                    propertySaveList.Add(newPropertySave);
                }
            }
        }
Esempio n. 2
0
        public static void SetProperty(this ReferencedFileSave referencedFileSave, string propertyName, object value)
        {
            var propertySave = referencedFileSave.Properties.FirstOrDefault(
                item => item.Name == propertyName);

            if (propertySave != null)
            {
                propertySave.Value = value;
            }
            else
            {
                propertySave       = new PropertySave();
                propertySave.Value = value;
                propertySave.Name  = propertyName;

                referencedFileSave.Properties.Add(propertySave);
            }
        }