Пример #1
0
        /// <summary>
        /// Packs the data and into a response object and sends it to the callback
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="callback"></param>
        internal void PackAndSendResponse <T>(string rawData, AsanaResponseEventHandler callback) where T : AsanaObject
        {
            var u = AsanaObject.Create(typeof(T));

            Parsing.Deserialize(GetDataAsDict(rawData), u, this);
            callback(u);
        }
Пример #2
0
        /// <summary>
        /// Repacks data into an existing object
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="rawData"></param>
        /// <param name="?"></param>
        internal void RepackAndCallback <T>(string rawData, T obj) where T : AsanaObject
        {
            Parsing.Deserialize(GetDataAsDict(rawData), obj, this);

            obj.SavingCallback(Parsing.Serialize(obj, false, false));
            obj.SavedCallback();
        }
Пример #3
0
        /// <summary>
        /// Packs the data and into a response object and sends it to the callback
        /// </summary>
        /// <typeparam name="T"></typeparam>
        private T PackAndSendResponse <T>(string rawData) where T : AsanaObject
        {
            var u = AsanaObject.Create(typeof(T));

            Parsing.Deserialize(GetDataAsDict(rawData), u, _host);
            return((T)u);
        }
Пример #4
0
        private T PackOriginalContent <T>(string rawData) where T : AsanaObject
        {
            var data = Json.Deserialize(rawData) as Dictionary <string, object>;
            var u    = AsanaObject.Create(typeof(T));

            Parsing.Deserialize(data, u, _host);
            return((T)u);
        }
Пример #5
0
        /// <summary>
        /// Packs the data and into a collection object and sends it to the callback
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="callback"></param>
        internal void PackAndSendResponseCollection <T>(string rawData, AsanaCollectionResponseEventHandler callback) where T : AsanaObject
        {
            var k = GetDataAsDictArray(rawData);
            AsanaObjectCollection collection = new AsanaObjectCollection();

            foreach (var j in k)
            {
                var t = AsanaObject.Create(typeof(T));
                Parsing.Deserialize(j, t, this);
                collection.Add(t);
            }
            callback(collection);
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        static private AsanaObject SafeAssignAsanaObject <T>(Dictionary <string, object> source, string name, Asana host) where T : AsanaObject
        {
            T value = null;

            if (source.ContainsKey(name) && source[name] != null)
            {
                var obj = source[name] as Dictionary <string, object>;
                value = (T)AsanaObject.Create(typeof(T));
                Parsing.Deserialize(obj, (value as AsanaObject), host);
            }

            return(value);
        }
Пример #7
0
        /// <summary>
        /// Packs the data and into a collection object and sends it to the callback
        /// </summary>
        /// <typeparam name="T"></typeparam>
        private IAsanaObjectCollection <T> PackAndSendResponseCollection <T>(string rawData) where T : AsanaObject
        {
            var k = GetDataAsDictArray(rawData);
            AsanaObjectCollection <T> collection = new AsanaObjectCollection <T>();

            foreach (var j in k)
            {
                var t = (T)AsanaObject.Create(typeof(T));
                Parsing.Deserialize(j, t, _host);
                collection.Add(t);
            }

            return(collection);
        }
Пример #8
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        static private T[] SafeAssignAsanaObjectArray <T>(Dictionary <string, object> source, string name, Asana host) where T : AsanaObject
        {
            T[] value = null;

            if (source.ContainsKey(name) && source[name] != null)
            {
                var list = source[name] as List <object>;

                value = new T[list.Count];
                for (int i = 0; i < list.Count; ++i)
                {
                    T newObj = (T)AsanaObject.Create(typeof(T));
                    Parsing.Deserialize(list[i] as Dictionary <string, object>, (newObj as AsanaObject), host);
                    value[i] = newObj;
                }
            }

            return(value);
        }