예제 #1
0
파일: Asana.cs 프로젝트: jfjcn/AsanaNet
        /// <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();
        }
예제 #2
0
        public Task DuplicateProjectById(Int64 int64, AsanaDuplicateProjectSettings settings, AsanaResponseEventHandler callback)
        {
            var data    = Parsing.Serialize(settings, true, false);
            var request = GetBaseRequestWithParams(AsanaFunction.GetFunction(Function.DuplicateProject), data, int64);

            return(request.Go((o, h) => PackAndSendResponse <AsanaDuplicateProjectJob>(o, callback), ErrorCallback));
        }
예제 #3
0
파일: Asana.cs 프로젝트: jfjcn/AsanaNet
        /// <summary>
        /// Tells the asana object to save the specified object
        /// </summary>
        /// <param name="obj"></param>
        internal Task Save <T>(T obj, AsanaFunction func, Dictionary <string, object> data = null) where T : AsanaObject
        {
            IAsanaData idata = obj as IAsanaData;

            if (idata == null)
            {
                throw new NullReferenceException("All AsanaObjects must implement IAsanaData in order to Save themselves.");
            }

            if (data == null)
            {
                data = Parsing.Serialize(obj, true, !idata.IsObjectLocal);
            }
            AsanaRequest             request = null;
            AsanaFunctionAssociation afa     = AsanaFunction.GetFunctionAssociation(obj.GetType());

            if (func == null)
            {
                func = idata.IsObjectLocal ? afa.Create : afa.Update;
            }

            request = GetBaseRequestWithParams(func, data, obj);
            return(request.Go((o, h) => RepackAndCallback(o, obj), ErrorCallback));
        }