Code Monkey home page Code Monkey logo

agfx's People

Contributors

jeffwilcox avatar kinnara avatar shawnburke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

agfx's Issues

Using AgFx with SharpGIS.WebRequestCreator throws OverflowException

Register SharpGIS.WebRequestCreator (can be found in NuGet as SharpGIS.GZipWebClient) in app.xaml.cs to enable GZip support like this:
WebRequest.RegisterPrefix("http://", SharpGIS.WebRequestCreator.GZip);
WebRequest.RegisterPrefix("https://", SharpGIS.WebRequestCreator.GZip);

And then watch AgFx crash and burn due to an OverflowException being thrown :(

Windows RT support?

Hi

I LOVE Agfx, it's so awesome! Actually it's so awesome that I would like it to work on my upcoming Windows RT apps.

Is this something you are looking into supporting?

Sorry if I'm "posting" the wrong place but didn't knew where else to do with this :)

Service is called only once, CachePolicy is ignored

Hi,

Sorry for the cross post but I don't know which one is monitored better, this place or codeplex.

I've been working with AgFx trying to figure out if it's suitable for a project of mine. After reading the tutorial, I have implemented something basic but it seems that either I don't get how it works or I have made some enormous mistake.

There is this simple service on an MVC 3 project, with just this method:

    [OperationContract]
    [WebGet(UriTemplate = "/Version/{param}",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
    public string GetVersion(string param)
    {
         return param + ": " + DateTime.Now.ToLongTimeString();
    }

I have a LoadContext:

public class StructureVersionLoadContext : LoadContext
{
    public string Param
    {
        get
        {
            return (string)Identity;
        }
    }

    public StructureVersionLoadContext(string param)
        : base(param)
    {
    }
}

and a VM:

[CachePolicy(CachePolicy.CacheThenRefresh, 10)]
public class StructureVersionModel : ModelItemBase<StructureVersionLoadContext>
{
    public StructureVersionModel()
    {
    }

    public StructureVersionModel(string param) :
        base(new StructureVersionLoadContext(param))
    {
    }

    private string _description;
    public string Description
    {
        get { return _description; }
        set
        {
            _description = value;
            RaisePropertyChanged("Description");
        }
    }

    public class StructureVersionModelDataLoader : IDataLoader<StructureVersionLoadContext>
    {
        public LoadRequest GetLoadRequest(StructureVersionLoadContext context, Type objectType)
        {
            var url = string.Format(@"http://localhost:2641/Service/Version/{0}", context.Param);
            return new WebLoadRequest(context, new Uri(url));
        }

        public object Deserialize(StructureVersionLoadContext context, Type objectType, Stream data)
        {
            var model = new StructureVersionModel(context.Param);
            model.LoadContext = context;

            using (var sr = new StreamReader(data))
            {
                var sv = JsonConvert.DeserializeObject<string>(sr.ReadToEnd());

                model.Description = sv;
            };

            return model;
        }
    }
}

Now, on the WP side, I have a button that runs this code:

this.DataContext = DataManager.Current.Load(new StructureVersionLoadContext(theTextBox.Text));

I have set the CachePolicy of the VM to CacheThenRefresh. By reading the documentation, I understand that when I press the button for the first time, AgFx should fetch a value from the service. If I press it again within 10 seconds, AgFx should just give me the cached value (assuming that the parameter is the same). And when I press it after 10 seconds have passed (keeping always the same parameter), AgFx should hit the service again and give me a fresh value. Correct? Well, the problem is that this last part is not happening. The service is hit once and never again. Not event if I do DataManager.Current.Refresh().

I have uploaded a project to demo the described behavior here: https://skydrive.live.com/redir.aspx?cid=ccdfc90fac9f29ce&resid=CCDFC90FAC9F29CE!549&parid=CCDFC90FAC9F29CE!547

Thanx
Manos

Use DataManager.Current.Save to save local data?

Hi Shawn,

In my windows phone app I have a scenario that I need to store a model (of type ModelItemBase) object locally. This model object is created on the phone the first time users open the app. And then after that each time when it's needed, it will be loaded from the cache.

I know I can use the phone's isolated storage to achieve what I want, but can I also use the DataManager.Current.Save method instead? Would it be an overkill in this case?

What I have done so far is, I have my model's data loader implement IDataOptimizer, like this,

        public object DeserializeOptimizedData(LoadContext context, Type objectType, System.IO.Stream stream)
        {
            var serializer = new DataContractSerializer(typeof(MyModel));
            return (AlarmCollectionModel)serializer.ReadObject(stream);
        }

        public bool SerializeOptimizedData(object value, System.IO.Stream outputStream)
        {
            var vm = (AlarmCollectionModel)value;
            var serializer = new DataContractSerializer(typeof(MyModel)));
            serializer.WriteObject(outputStream, vm);

            return true;
        }

But do I still need to implement the GetLoadRequest and Deserialize? I simply make both of them return 'null'. Is this correct?

Thanks,
Xin

AgFx in combination with JSON.Net

Hi All,

Using AgFx looks great, all is working smoothly using the samples.

However, I'm interested in using AgFx in my application, but it does not work with JSON.Net

I'm using a web-service that supports JSON, currently I'm using Restsharp requests (tried base requests as well) However, I'm not using ViewModels like shown in the examples, but using ViewModels for MVVM. The ViewModels in AgFx terms are Models in my application.

When I now try to load my data Models, they are not getting deserialized... When I try the same without the ModelItemBase, the deserialization works.

What should I do to make this work?

Hope anyone can help.

Pieter

Unhandled exception from AgFx.ErrorLog.WriteError

I got this little watson report from my app using the latest AgFx source. Looking at the code for ErrorLog.WriteError, it looks like it should be protected from this (I think it would be an ObjectDisposedException). Has anyone else seen this or have any ideas?

Application_UnhandledException
Cannot access a closed file.
at System.IO.__Error.FileNotOpen()
at System.IO.FileStream.Write(Byte[] array, Int32 offset, Int32 count)
at System.IO.IsolatedStorage.IsolatedStorageFileStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Flush()
at AgFx.ErrorLog.WriteError(String description, Exception ex)
at AgFx.DataManager.OnUnhandledError(Exception ex)
at AgFx.DataManager.b__7f[T](Exception ex)
at AgFx.CacheEntry.NotifyCompletion(ValueLoader loader, Exception ex)
at AgFx.CacheEntry.LiveValueLoader_Failed(Object s, ExceptionEventArgs e)
at AgFx.CacheEntry.ValueLoader.OnLoadFailed(Exception ex)
at AgFx.CacheEntry.ValueLoader.ProcessData()
at AgFx.CacheEntry.LiveValueLoader.OnLoadSuccess(Stream result)
at AgFx.DataManager.<>c__DisplayClass81`1.<>c__DisplayClass83.b__7c(LoadRequestResult result)
at AgFx.WebLoadRequest.<>c__DisplayClass3.<>c__DisplayClass6.b__1(IAsyncResult async)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.b__8(Object state2)
at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()

AgFx.DataManager.OnUnhandledError when WebLoadRequest trying to access invalid page

Hi,

I get the following exception when WebLoadRequest tries to access a page that is temporarily unavailable (HTTP code 503):

An error occurred loading an object of type RssFeedModel, see InnerException for details.
at AgFx.DataManager.OnUnhandledError(Exception ex)
at AgFx.UpdateCompletionHandler.ProcessResults()
at AgFx.UpdateCompletionHandler.UnregisterLoader(LoaderType loader)
at AgFx.UpdateCompletionHandler.OnError(LoaderType loader, Exception ex)
at AgFx.CacheEntry.NotifyCompletion(ValueLoader loader, Exception ex)
at AgFx.CacheEntry.LiveValueLoader_Failed(Object s, ExceptionEventArgs e)
at AgFx.CacheEntry.ValueLoader.OnLoadFailed(Exception ex)
at AgFx.CacheEntry.LiveValueLoader.OnLoadFail(LoadRequestFailedException exception)
at AgFx.DataManager.<>c__DisplayClass67`1.<>c__DisplayClass69.b__63(LoadRequestResult result)
at USElections.Utils.MyWebLoadRequest.<>c__DisplayClass3.<>c__DisplayClass6.b__1(IAsyncResult asyncObject)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.b__8(Object state2)
at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadPool.WorkItem.doWork(Object o)
at System.Threading.Timer.ring()

I made a copy of WebLoadRequest and called it MyWebLoadRequest. Somehow reflector prevented me from stepping to your code.

The problem is in this line of code:

                try
                {
                    response = (HttpWebResponse)request.EndGetResponse(asyncObject);
                }
                catch (WebException exception)
                {
                    result(new LoadRequestResult(exception));
                    return;
                }

The callback to result() fails.

I'm running against the (latest) Nuget release 1.1.0.1101.

Next step will be downloading the original source code and test it against that. I will try that later, but perhaps you already have an idea of what is going wrong.

Thanks again for this great library. Really love it!

Plans for Windows Phone 8?

I absolutely love AgFx for Windows Phone 7. Are there any plans to port it over to Windows Phone 8 and take advantage of the newer APIs?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.