예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.myButton);

            button.Click += delegate
            {
                button.Text = string.Format("{0} clicks!", count++);

                var cachedFolderPathString = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
                var cacheProxy             = new CMPCacheProxy(cachedFolderPathString, 5000);
                cacheProxy.ExpiryDays(1);

                string cacheString    = "Test String";
                byte[] retrievedBytes = cacheProxy.RetieveItem("testfile");
                if (retrievedBytes != null)
                {
                    cacheString = System.Text.Encoding.UTF8.GetString(retrievedBytes);
                    Console.WriteLine("cacheString:" + cacheString);
                }
                else
                {
                    byte[] cacheBytes = System.Text.Encoding.UTF8.GetBytes(cacheString);
                    cacheProxy.CacheItem(cacheBytes, "testfile");
                }
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Code to start the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
#endif


            var baseFolderPathString = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            _cacheProxy = new CMPCacheProxy(baseFolderPathString, 5 * 1024);
            _cacheProxy.ExpiryDays(1);

            _imageLoaderProxy = new CMPImageLoaderProxy("<Image_URL>", _cacheProxy);

            // Perform any additional setup after loading the view, typically from a nib.
            Button.AccessibilityIdentifier = "myButton";
            Button.TouchUpInside          += async delegate
            {
                var title = string.Format("{0} clicks!", count++);
                Button.SetTitle(title, UIControlState.Normal);
                await _imageLoaderProxy.LoadImageAsync();
            };
        }
        public CMPImageLoaderProxy(string imageURLString, long cacheSize = 5 * 1024)
        {
            var baseFolderPathString = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var cacheProxy           = new CMPCacheProxy(baseFolderPathString, cacheSize);

            cacheProxy.ExpiryDays(7);

            _imageLoader = new CMPImageLoader(imageURLString, cacheProxy);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Code to start the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
#endif

            // Perform any additional setup after loading the view, typically from a nib.
            Button.AccessibilityIdentifier = "myButton";
            Button.TouchUpInside          += delegate
            {
                var title = string.Format("{0} clicks!", count++);
                Button.SetTitle(title, UIControlState.Normal);

                var cachedFolderPathString = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                var cacheProxy             = new CMPCacheProxy(cachedFolderPathString, 1024);
                cacheProxy.ExpirySeconds(60);

                //var str = new byte[1];

                //str[2] = (byte)'c';

                string cacheString    = null;
                byte[] retrievedBytes = cacheProxy.RetieveItem("testfile81");
                if (retrievedBytes != null)
                {
                    cacheString = System.Text.Encoding.UTF8.GetString(retrievedBytes);
                    Console.WriteLine("cacheString:" + cacheString);
                }
                else
                {
                    cacheString = "Test String38";
                    byte[] cacheBytes = System.Text.Encoding.UTF8.GetBytes(cacheString);
                    cacheProxy.CacheItem(cacheBytes, "testfile81");
                }
            };
        }
 public CMPImageLoaderProxy(string imageURLString, CMPCacheProxy cacheProxy)
 {
     _imageLoader = new CMPImageLoader(imageURLString, cacheProxy);
 }