コード例 #1
0
        private static async Task <bool> doMembership(Operations operations)
        {
            if (token == null)
            {
                Authorizer authorizer = new Authorizer();

                Console.WriteLine("calling authorize()");

                token = await authorizer.Authorize();

                Console.WriteLine("doMembership(): Token=" + token.ToString());
            }

            MembershipService membershipService = new MembershipService(token);

            if (operations.HasFlag(Operations.C))
            {
                Membership newMembership = MembershipHelper.GenerateObject();
                Membership membership    = await membershipService.CreateObject(newMembership);

                Console.WriteLine("Membership Create: " + membership.ToString());
            }

            if (operations.HasFlag(Operations.R))
            {
                Membership membership = await membershipService.ReadObject();

                Console.WriteLine("Membership Read: " + membership.ToString());
            }

            if (operations.HasFlag(Operations.U))
            {
                Membership newMembership = MembershipHelper.GenerateObject();
                Membership membership    = await membershipService.UpdateObject(newMembership);

                Console.WriteLine("Membership Update: " + membership.ToString());
            }

            if (operations.HasFlag(Operations.D))
            {
                Membership membership = await membershipService.DeleteObject();

                Console.WriteLine("Membership Delete: " + membership.ToString());
            }
            return(true);
        }