コード例 #1
0
        private static void PrintImageDetails(RackSpaceCloudServerImage image)
        {
            Console.WriteLine("Image ID:" + image.id);
            Console.WriteLine("Image name:" + image.name);
            Console.WriteLine("Image updated:" + image.updated);
            Console.WriteLine("Image status:" + image.status);
            Console.WriteLine("Image created:" + image.created);
            Console.WriteLine("Image serverId:" + image.serverId);
            Console.WriteLine("Image progress:" + image.progress);

            Console.WriteLine("********************************");
            Console.WriteLine();
        }
コード例 #2
0
        private RackSpaceCloudServerImage ExpandoToRackSpaceCloudImageObject(dynamic image)
        {
            var p = image as IDictionary<String, object>;

            object id;
            object name;
            object status;
            object updated;
            object created;
            object serverId;
            object progress;

            if (!p.TryGetValue("id", out id))
            {
                id = "0";
            }

            if (!p.TryGetValue("name", out name))
            {
                name = "Empty value";
            }

            if (!p.TryGetValue("status", out status))
            {
                status = "Empty value";
            }

            if (!p.TryGetValue("updated", out updated))
            {
                updated = "Empty value";
            }

            if (!p.TryGetValue("created", out created))
            {
                created = "Empty value";
            }

            if (!p.TryGetValue("serverId", out serverId))
            {
                serverId = "0";
            }

            if (!p.TryGetValue("progress", out progress))
            {
                progress = "0";
            }

            RackSpaceCloudServerImage imagesDetails = new RackSpaceCloudServerImage
            {
                id = Convert.ToInt32(id.ToString()),
                name = name.ToString(),
                status = status.ToString(),
                updated = updated.ToString(),
                created = created.ToString(),
                serverId = Convert.ToInt32(serverId.ToString()),
                progress = Convert.ToInt32(progress.ToString())
            };
            return imagesDetails;
        }