예제 #1
0
 protected DefaultMessageBundleFactory()
 {
     this.fetcher = BasicHttpFetcher.Instance;
     //Cache<Uri, MessageBundle> baseCache = cacheProvider.createCache(CACHE_NAME);
     //this.cache = new SoftExpiringCache<Uri, MessageBundle>(baseCache);
     this.refresh = long.Parse(PestaSettings.GadgetCacheXmlRefreshInterval);
 }
예제 #2
0
        public static UpnpDeviceInfo FromXmlString(string aXml, Uri aDocUri, IHttpFetcher aFetcher)
        {
            var doc        = XDocument.Parse(aXml);
            var deviceInfo = FromXmlDeviceNode(doc.Root.Element(UpnpDeviceXml.DeviceElement), aDocUri, aFetcher);

            deviceInfo.DeviceXml = aXml;
            return(deviceInfo);
        }
예제 #3
0
        public static async Task <T> FetchAndDeserializeAsync <T>(string link, IHttpFetcher fetcher)
        {
            var jsonStream = await fetcher.GetHttpStreamAsync(link);

            var deserialized = JsonConvert.DeserializeObject <T>(jsonStream);

            return(deserialized);
        }
예제 #4
0
 protected ProxyHandler()
 {
     //
     // TODO: Add constructor logic here
     //
     fetcher = BasicHttpFetcher.Instance;
     lockedDomainService = HashLockedDomainService.Instance;
     contentRewriterRegistry = DefaultContentRewriterRegistry.Instance;
 }
예제 #5
0
 protected ProxyHandler()
 {
     //
     // TODO: Add constructor logic here
     //
     fetcher                 = BasicHttpFetcher.Instance;
     lockedDomainService     = HashLockedDomainService.Instance;
     contentRewriterRegistry = DefaultContentRewriterRegistry.Instance;
 }
예제 #6
0
        /**
         * Retrieves js content from the given url.
         *
         * @param url
         * @param fetcher
         * @return The contents of the JS file, or null if it can't be fetched.
         * @throws GadgetException
         */
        private static String LoadDataFromUrl(String url, IHttpFetcher fetcher)
        {
            // set up the request and response objects
            Uri       uri      = Uri.parse(url);
            sRequest  request  = new sRequest(uri);
            sResponse response = fetcher.fetch(request);

            if (response.getHttpStatusCode() == (int)HttpStatusCode.OK)
            {
                return(response.responseString);
            }
            return(null);
        }
예제 #7
0
        /**
         * Creates a new js library.
         *
         * @param type If FILE or RESOURCE, the content will be loaded from disk.
         *     if URL or INLINE, the content will be handled the same as html <script>
         * @param content If FILE or RESOURCE, we will also look for a file
         *     named file.opt.ext for every file.ext, and if present we will
         *     use that as the standard content and file.ext as the debug content.
         * @param feature The name of the feature that this library was created for
         *     may be null.
         * @param fetcher Used to retrieve Type.URL; if null, Type.URL will not be
         *     kept as a url reference, otherwise the file will be fetched and treated
         *     as a FILE type.
         * @return The newly created library.
         * @throws GadgetException
         */
        public static JsLibrary Create(Type type, String content, String feature, IHttpFetcher fetcher)
        {
            String optimizedContent = null;
            String debugContent;

            switch (type)
            {
            case Type.FILE:
            case Type.RESOURCE:
                if (content.EndsWith(".js"))
                {
                    optimizedContent = LoadData(content.Substring(0, content.Length - 3) + ".opt.js", type);
                }
                debugContent = LoadData(content, type);
                if (String.IsNullOrEmpty(optimizedContent))
                {
                    optimizedContent = debugContent;
                }
                break;

            case Type.URL:
                if (fetcher == null)
                {
                    debugContent = optimizedContent = content;
                }
                else
                {
                    type         = Type.FILE;
                    debugContent = optimizedContent = LoadDataFromUrl(content, fetcher);
                }
                break;

            default:
                debugContent     = content;
                optimizedContent = content;
                break;
            }
            return(new JsLibrary(feature, type, optimizedContent, debugContent));
        }
예제 #8
0
 public static UpnpServiceInfo FromXmlServiceNode(XElement aServiceNode, Uri aDocUri, IHttpFetcher aFetcher)
 {
     var instance = new UpnpServiceInfo();
     foreach (var item in aServiceNode.Elements())
     {
         if (item.Name == UpnpDeviceXml.ServiceTypeElement) { instance.ServiceType = item.Value; }
         if (item.Name == UpnpDeviceXml.ServiceIdElement) { instance.ServiceId = item.Value; }
         if (item.Name == UpnpDeviceXml.SCPDURLElement)
         {
             instance.SCPDURL = item.Value;
             Uri absoluteUri;
             if (Uri.TryCreate(aDocUri, instance.SCPDURL, out absoluteUri))
             {
                 instance.DescriptionXml = aFetcher.SynchronousGetRequest(absoluteUri);
                 var descriptionDoc = XDocument.Parse(instance.DescriptionXml);
                 instance.Description = UpnpServiceDescriptionInfo.FromXmlScpdNode(descriptionDoc.Root);
             }
         }
         if (item.Name == UpnpDeviceXml.ControlURLElement) { instance.ControlURL = item.Value; }
         if (item.Name == UpnpDeviceXml.EventSubURLElement) { instance.EventSubURL = item.Value; }
     }
     return instance;
 }
예제 #9
0
 protected DefaultRequestPipeline()
 {
     httpFetcher          = BasicHttpFetcher.Instance;
     oauthRequestProvider = new Provider <OAuthRequest>();
 }
예제 #10
0
 public JsFeatureLoader()
 {
     fetcher = BasicHttpFetcher.Instance;
 }
예제 #11
0
        public static UpnpServiceInfo FromXmlServiceNode(XElement aServiceNode, Uri aDocUri, IHttpFetcher aFetcher)
        {
            var instance = new UpnpServiceInfo();

            foreach (var item in aServiceNode.Elements())
            {
                if (item.Name == UpnpDeviceXml.ServiceTypeElement)
                {
                    instance.ServiceType = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ServiceIdElement)
                {
                    instance.ServiceId = item.Value;
                }
                if (item.Name == UpnpDeviceXml.SCPDURLElement)
                {
                    instance.SCPDURL = item.Value;
                    Uri absoluteUri;
                    if (Uri.TryCreate(aDocUri, instance.SCPDURL, out absoluteUri))
                    {
                        instance.DescriptionXml = aFetcher.SynchronousGetRequest(absoluteUri);
                        var descriptionDoc = XDocument.Parse(instance.DescriptionXml);
                        instance.Description = UpnpServiceDescriptionInfo.FromXmlScpdNode(descriptionDoc.Root);
                    }
                }
                if (item.Name == UpnpDeviceXml.ControlURLElement)
                {
                    instance.ControlURL = item.Value;
                }
                if (item.Name == UpnpDeviceXml.EventSubURLElement)
                {
                    instance.EventSubURL = item.Value;
                }
            }
            return(instance);
        }
예제 #12
0
 protected DefaultRequestPipeline() 
 {
     httpFetcher = BasicHttpFetcher.Instance;
     oauthRequestProvider = new Provider<OAuthRequest>();
 }
예제 #13
0
 public GetBarListFourSquare(IHttpFetcher fetcher)
 {
     _fetcher = fetcher;
 }
예제 #14
0
        /**
        * @param fetcherConfig configuration options for the fetcher
        * @param fetcher fetcher to use for actually making requests
        * @param trustedParams additional parameters to include in all outgoing OAuth requests, useful
        *     for client data that can't be pulled from the security token but is still trustworthy.
        */

        private OAuthRequest(OAuthFetcherConfig fetcherConfig, IHttpFetcher fetcher,
                List<OAuth.Parameter> trustedParams) 
        {
            this.fetcherConfig = fetcherConfig;
            this.fetcher = fetcher;
            this.trustedParams = trustedParams;
        }
예제 #15
0
 public JsFeatureLoader()
 {
     fetcher = BasicHttpFetcher.Instance;
 }
예제 #16
0
 public ExDown(IHttpFetcher http)
 {
     _Http = http;
 }
 public GetBarListGoogle(IHttpFetcher fetcher)
 {
     _fetcher = fetcher;
 }
예제 #18
0
파일: JsLibrary.cs 프로젝트: s7loves/pesta
 /**
 * Retrieves js content from the given url.
 *
 * @param url
 * @param fetcher
 * @return The contents of the JS file, or null if it can't be fetched.
 * @throws GadgetException
 */
 private static String LoadDataFromUrl(String url, IHttpFetcher fetcher)
 {
     
     // set up the request and response objects
     Uri uri = Uri.parse(url);
     sRequest request = new sRequest(uri);
     sResponse response = fetcher.fetch(request);
     if (response.getHttpStatusCode() == (int)HttpStatusCode.OK)
     {
         return response.responseString;
     }
     return null;
 }
예제 #19
0
파일: JsLibrary.cs 프로젝트: s7loves/pesta
 /**
 * Creates a new js library.
 *
 * @param type If FILE or RESOURCE, the content will be loaded from disk.
 *     if URL or INLINE, the content will be handled the same as html <script>
 * @param content If FILE or RESOURCE, we will also look for a file
 *     named file.opt.ext for every file.ext, and if present we will
 *     use that as the standard content and file.ext as the debug content.
 * @param feature The name of the feature that this library was created for
 *     may be null.
 * @param fetcher Used to retrieve Type.URL; if null, Type.URL will not be
 *     kept as a url reference, otherwise the file will be fetched and treated
 *     as a FILE type.
 * @return The newly created library.
 * @throws GadgetException
 */
 public static JsLibrary Create(Type type, String content, String feature, IHttpFetcher fetcher)
 {
     String optimizedContent = null;
     String debugContent;
     switch (type)
     {
         case Type.FILE:
         case Type.RESOURCE:
             if (content.EndsWith(".js"))
             {
                 optimizedContent = LoadData(content.Substring(0, content.Length - 3) + ".opt.js", type);
             }
             debugContent = LoadData(content, type);
             if (String.IsNullOrEmpty(optimizedContent))
             {
                 optimizedContent = debugContent;
             }
             break;
         case Type.URL:
             if (fetcher == null)
             {
                 debugContent = optimizedContent = content;
             }
             else
             {
                 type = Type.FILE;
                 debugContent = optimizedContent = LoadDataFromUrl(content, fetcher);
             }
             break;
         default:
             debugContent = content;
             optimizedContent = content;
             break;
     }
     return new JsLibrary(feature, type, optimizedContent, debugContent);
 }
 public GetBarListFacebook(IHttpFetcher fetcher)
 {
     _fetcher = fetcher;
 }
 protected RemoteContentFetcherFactory()
 {
     this.fetcher = BasicHttpFetcher.Instance;
 }
 public GetBarListTripAdvisor(IHttpFetcher fetcher)
 {
     _fetcher = fetcher;
 }
예제 #23
0
        protected DefaultGadgetSpecFactory()
        {
            fetcher = BasicHttpFetcher.Instance;
            refresh = long.Parse(PestaSettings.GadgetCacheXmlRefreshInterval);

        }
예제 #24
0
 protected internal ChainedContentFetcher(IHttpFetcher nextFetcher_0)
 {
     this.nextFetcher = nextFetcher_0;
 }
 protected DefaultGadgetSpecFactory()
 {
     fetcher = BasicHttpFetcher.Instance;
     refresh = long.Parse(PestaSettings.GadgetCacheXmlRefreshInterval);
 }
예제 #26
0
 public static UpnpDeviceInfo FromXmlDeviceNode(XElement aDeviceNode, Uri aDocUri, IHttpFetcher aFetcher)
 {
     var instance = new UpnpDeviceInfo();
     List<UpnpDeviceInfo> embeddedDevices = new List<UpnpDeviceInfo>();
     List<UpnpServiceInfo> services = new List<UpnpServiceInfo>();
     instance.EmbeddedDevices = embeddedDevices;
     instance.Services = services;
     foreach (var item in aDeviceNode.Elements())
     {
         if (item.Name == UpnpDeviceXml.DeviceTypeElement) { instance.DeviceType = item.Value; }
         if (item.Name == UpnpDeviceXml.FriendlyNameElement) { instance.FriendlyName = item.Value; }
         if (item.Name == UpnpDeviceXml.ManufacturerElement) { instance.Manufacturer = item.Value; }
         if (item.Name == UpnpDeviceXml.ManufacturerURLElement) { instance.ManufacturerURL = item.Value; }
         if (item.Name == UpnpDeviceXml.ModelDescriptionElement) { instance.ModelDescription = item.Value; }
         if (item.Name == UpnpDeviceXml.ModelNameElement) { instance.ModelName = item.Value; }
         if (item.Name == UpnpDeviceXml.ModelNumberElement) { instance.ModelNumber = item.Value; }
         if (item.Name == UpnpDeviceXml.ModelURLElement) { instance.ModelURL = item.Value; }
         if (item.Name == UpnpDeviceXml.SerialNumberElement) { instance.SerialNumber = item.Value; }
         if (item.Name == UpnpDeviceXml.UDNElement) { instance.UDN = item.Value; }
         if (item.Name == UpnpDeviceXml.UPCElement) { instance.UPC = item.Value; }
         if (item.Name == UpnpDeviceXml.DeviceListElement)
         {
             foreach (var embeddedDeviceNode in item.Elements(UpnpDeviceXml.DeviceElement))
             {
                 embeddedDevices.Add(UpnpDeviceInfo.FromXmlDeviceNode(embeddedDeviceNode, aDocUri, aFetcher));
             }
         }
         if (item.Name == UpnpDeviceXml.ServiceListElement)
         {
             foreach (var serviceNode in item.Elements(UpnpDeviceXml.ServiceElement))
             {
                 services.Add(UpnpServiceInfo.FromXmlServiceNode(serviceNode, aDocUri, aFetcher));
             }
         }
     }
     instance.BaseURI = aDocUri;
     return instance;
 }
예제 #27
0
 public static UpnpDeviceInfo FromXmlString(string aXml, Uri aDocUri, IHttpFetcher aFetcher)
 {
     var doc = XDocument.Parse(aXml);
     var deviceInfo = FromXmlDeviceNode(doc.Root.Element(UpnpDeviceXml.DeviceElement), aDocUri, aFetcher);
     deviceInfo.DeviceXml = aXml;
     return deviceInfo;
 }
예제 #28
0
        public static UpnpDeviceInfo FromXmlDeviceNode(XElement aDeviceNode, Uri aDocUri, IHttpFetcher aFetcher)
        {
            var instance = new UpnpDeviceInfo();
            List <UpnpDeviceInfo>  embeddedDevices = new List <UpnpDeviceInfo>();
            List <UpnpServiceInfo> services        = new List <UpnpServiceInfo>();

            instance.EmbeddedDevices = embeddedDevices;
            instance.Services        = services;
            foreach (var item in aDeviceNode.Elements())
            {
                if (item.Name == UpnpDeviceXml.DeviceTypeElement)
                {
                    instance.DeviceType = item.Value;
                }
                if (item.Name == UpnpDeviceXml.FriendlyNameElement)
                {
                    instance.FriendlyName = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ManufacturerElement)
                {
                    instance.Manufacturer = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ManufacturerURLElement)
                {
                    instance.ManufacturerURL = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ModelDescriptionElement)
                {
                    instance.ModelDescription = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ModelNameElement)
                {
                    instance.ModelName = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ModelNumberElement)
                {
                    instance.ModelNumber = item.Value;
                }
                if (item.Name == UpnpDeviceXml.ModelURLElement)
                {
                    instance.ModelURL = item.Value;
                }
                if (item.Name == UpnpDeviceXml.SerialNumberElement)
                {
                    instance.SerialNumber = item.Value;
                }
                if (item.Name == UpnpDeviceXml.UDNElement)
                {
                    instance.UDN = item.Value;
                }
                if (item.Name == UpnpDeviceXml.UPCElement)
                {
                    instance.UPC = item.Value;
                }
                if (item.Name == UpnpDeviceXml.DeviceListElement)
                {
                    foreach (var embeddedDeviceNode in item.Elements(UpnpDeviceXml.DeviceElement))
                    {
                        embeddedDevices.Add(UpnpDeviceInfo.FromXmlDeviceNode(embeddedDeviceNode, aDocUri, aFetcher));
                    }
                }
                if (item.Name == UpnpDeviceXml.ServiceListElement)
                {
                    foreach (var serviceNode in item.Elements(UpnpDeviceXml.ServiceElement))
                    {
                        services.Add(UpnpServiceInfo.FromXmlServiceNode(serviceNode, aDocUri, aFetcher));
                    }
                }
            }
            instance.BaseURI = aDocUri;
            return(instance);
        }
예제 #29
0
 protected RemoteContentFetcherFactory()
 {
     this.fetcher = BasicHttpFetcher.Instance;
 }
예제 #30
0
 protected internal ChainedContentFetcher(IHttpFetcher nextFetcher_0)
 {
     this.nextFetcher = nextFetcher_0;
 }