/// <summary> /// Sets the value for this poperty /// </summary> /// <param name="prps">Repository</param> /// <param name="prpName">Name of the property</param> /// <param name="prpVal">Proeprty value</param> /// <remarks>This method will change the value of existing property or create new one if not exist</remarks> public static void Set(this IXPropertyRepository prps, string prpName, object prpVal) { var prp = prps.GetOrPreCreate(prpName); prp.Value = prpVal; if (!prp.Exists()) { prps.Add(prp); } }
/// <summary> /// Gets or pre creates property /// </summary> /// <param name="prps">Repository</param> /// <param name="name">Name of the property</param> /// <returns>Existing proeprty or non-commited property</returns> public static IXProperty GetOrPreCreate(this IXPropertyRepository prps, string name) { IXProperty prp; if (!prps.TryGet(name, out prp)) { prp = prps.PreCreate(); prp.Name = name; } return(prp); }