public DynamicModel() { PropertyChanged += DynamicModel_PropertyChanged; foreach (var prop in this.GetType().GetProperties()) { var value = DynamicStorageExtensions.GetDynamicStorageValue(null, prop.Name); if (prop.PropertyType == typeof(Int32)) { prop.SetValue(this, int.Parse(value)); } else if (prop.PropertyType == typeof(long)) { prop.SetValue(this, long.Parse(value)); } else if (prop.PropertyType == typeof(DateTime)) { prop.SetValue(this, DateTime.Parse(value)); } else { prop.SetValue(this, value); } } }
public void UsingLibraryDirectly() { //SiteContext is only used as a shortcut extensions method when using Sitecore.Context.Site. //So you can pass it null //The following key-value pair will get saved to Core DB DynamicStorageExtensions.SetDynamicStorageValue(null, "Name", "TamerMehyar"); //Gets retrieved from CoreDB since cache will still be empty var myName = DynamicStorageExtensions.GetDynamicStorageValue(null, "Name"); //Gets retrieved from Cache var myNameCached = DynamicStorageExtensions.GetDynamicStorageValue(null, "Name"); }