Exemple #1
0
        public static IObjectDataValue CreateObjectValue(IObjectData objectData, IObjectData value)
        {
            // argument checks
            Debug.Assert(objectData != null);

            return(objectData.CreateValue(value));
        }
Exemple #2
0
        public static IObjectDataValue CreateObjectValue <T>(this IObjectData data, T value, Action <T, IObjectData, bool> saveObject, string name, bool overwrite, bool omitDefault)
        {
            // argument checks
            Debug.Assert(data != null);
            Debug.Assert(saveObject != null);
            Debug.Assert(name != null || overwrite == false);

            IObjectData objectData = null;

            if (value != null)
            {
                // get IObjectData into which the value saves its contents
                if (overwrite)
                {
                    // overwirte mode
                    objectData = data.GetObjectValue(name, defaultValue: null);
                }
                if (objectData == null)
                {
                    // create a empty IObjectData
                    objectData = data.CreateObject();
                }

                // save the value's contents
                saveObject(value, objectData, omitDefault);
            }

            return(data.CreateValue(objectData));
        }
Exemple #3
0
        public static IObjectDataValue CreateArrayValue(IObjectData objectData, IEnumerable <IObjectDataValue> value)
        {
            // argument checks
            Debug.Assert(objectData != null);

            return(objectData.CreateValue(value));
        }
Exemple #4
0
        public static IObjectDataValue CreatePasswordValue(IObjectData data, string value)
        {
            // argument checks
            Debug.Assert(data != null);

            // create password value
            return(data.CreateValue(string.IsNullOrEmpty(value) ? string.Empty : ProtectPassword(value)));
        }
Exemple #5
0
        private static IObjectDataValue CreateCultureInfoValue(IObjectData data, CultureInfo value)
        {
            // argument checks
            Debug.Assert(data != null);

            // create CultureInfo value
            return(data.CreateValue((value == null) ? null : value.Name));
        }
Exemple #6
0
        public static IObjectDataValue CreateEnumValue(this IObjectData data, Enum value)
        {
            // argument checks
            Debug.Assert(data != null);
            Debug.Assert(value != null);

            return(data.CreateValue(value.ToString()));
        }
Exemple #7
0
        public static IObjectDataValue CreateArrayValue <T>(IObjectData data, IEnumerable <T> value, Func <IObjectData, T, IObjectDataValue> createItem)
        {
            // argument checks
            Debug.Assert(data != null);
            Debug.Assert(createItem != null);

            IEnumerable <IObjectDataValue> actualValue = (value == null) ? null : value.Select(t => createItem(data, t));

            return(data.CreateValue(actualValue));
        }
        private static IObjectDataValue CreateIPAddressValue(IObjectData data, IPAddress value)
        {
            // argument checks
            Debug.Assert(data != null);
            Debug.Assert(value != null);

            // set IPAddress value
            string stringValue = value.ToString();

            Debug.Assert(string.IsNullOrEmpty(stringValue) == false);
            return(data.CreateValue(stringValue));
        }