private void AddPrefixNS(string prefix) { _prefix = prefix; _kvpDict = PrefixNS(prefix, _kvpDict); if (!_prefix.IsNullOrWhiteSpace()) { DynamicObjectName = "{0}:{1}".FormatString(prefix, DynamicObjectName.IndexOf(":") > 0 ? DynamicObjectName.Substring(DynamicObjectName.IndexOf(":") + 1) : DynamicObjectName); } }
public ChoDynamicObject(Func <IDictionary <string, object> > func, bool watchChange = false) { if (DynamicObjectName.IsNullOrWhiteSpace()) { DynamicObjectName = DefaultName; } ThrowExceptionIfPropNotExists = false; IsFixed = false; IsReadOnly = false; _func = func; _watchChange = watchChange; Task.Run(() => { Initialize(); _afterLoaded.Raise(this, null); if (watchChange) { int pollIntervalInSec = PollIntervalInSec; if (pollIntervalInSec <= 0) { pollIntervalInSec = 5; } System.Threading.Timer timer = null; timer = new System.Threading.Timer((e) => { timer.Change(Timeout.Infinite, Timeout.Infinite); try { Initialize(); } catch { } timer.Change((long)TimeSpan.FromSeconds(pollIntervalInSec).TotalMilliseconds, Timeout.Infinite); }, null, (long)TimeSpan.FromSeconds(pollIntervalInSec).TotalMilliseconds, Timeout.Infinite); } }); }