Пример #1
0
        public static Datasource GenerateObject()
        {
            Datasource datasource = new Datasource
            {
                externalId  = Constants.DATASOURCE_ID,
                description = Constants.DATASOURCE_DESCRIPTION
            };

            return(datasource);
        }
Пример #2
0
        private static async Task <bool> DoDatasource(Operations operations)
        {
            if (token.access_token == null)
            {
                Authorizer authorizer = new Authorizer();

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

                token = await authorizer.Authorize();

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

            DatasourceService datasourceService = new DatasourceService(token);

            if (operations.HasFlag(Operations.C))
            {
                Datasource newDatasource = DatasourceHelper.GenerateObject();
                Datasource datasource    = await datasourceService.CreateObject(newDatasource);

                Console.WriteLine("Datasource Create: " + datasource.ToString());
            }

            if (operations.HasFlag(Operations.R))
            {
                Datasource datasource = await datasourceService.ReadObject();

                Console.WriteLine("Datasource Read: " + datasource.ToString());
            }

            if (operations.HasFlag(Operations.U))
            {
                Datasource newDatasource = DatasourceHelper.GenerateObject();
                Datasource datasource    = await datasourceService.UpdateObject(newDatasource);

                Console.WriteLine("Datasource Update: " + datasource.ToString());
            }

            if (operations.HasFlag(Operations.D))
            {
                Datasource datasource = await datasourceService.DeleteObject();

                Console.WriteLine("Datasource Deleted.");
            }
            return(true);
        }