예제 #1
0
        public ModelProperty(
            IStorage storage,
            BotStateSet botStateSet,
            TSet defaultValue,
            string name)
        {
            var state = new NamedState(storage, name);

            accessor = state.CreateProperty <TSet>(name);
            botStateSet.Add(state);

            var current = state.Load().Result;

            if (current == null || !current.ContainsKey(name))
            {
                var get = Convert(defaultValue);
                lock (this)
                {
                    tget = get;
                }
            }
            else
            {
                var get = Convert((TSet)current[name]);
                lock (this)
                {
                    tget = get;
                }
            }
        }