Exemplo n.º 1
0
        /// <summary>
        /// Get information for each app GUId and then creates an output file formatted in json
        /// </summary>
        /// <param name="appGuids">Array of GUIDs</param>
        /// <param name="behavior">Behavior describing the Store App kind</param>
        /// <param name="outputName">Name for the output file</param>
        private static void GetInformationAndCreateOutput(string[] appGuids, StoreBehavior behavior, string outputName)
        {
            if (appGuids.Length > 0 && !string.IsNullOrWhiteSpace(outputName))
            {
                var wsaf = new StoreParser(behavior);

                Console.WriteLine("Getting information for {0} from internet...", outputName);

                try
                {
                    var listaStoreApps = wsaf.GetStoreAppDataCollection(appGuids);
                    Console.WriteLine("{0} Done", outputName);

                    Console.WriteLine("Generating output in {0}", outputName);
                    File.WriteAllText(outputName,
                                      JsonConvert.SerializeObject(listaStoreApps, Formatting.Indented));

                    Console.WriteLine("{0} output file generated", outputName);
                }
                catch (WebException)
                {
                    Console.WriteLine("This program requires internet connection to work properly");
                }
            }
        }
Exemplo n.º 2
0
 public void AddButtonValues(string _name, Sprite _icon, string _description, int _cost, StoreBehavior _storeBehavior)
 {
     nameText.text   = _name;
     icon.sprite     = _icon;
     descriptionText = _description;
     costText.text   = _cost.ToString();
     storeBehavior   = _storeBehavior;
     bought          = false;
 }
Exemplo n.º 3
0
 private void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else if (_instance != this)
     {
         Destroy(gameObject);
     }
 }
        /// <summary>
        /// Get related app information from internet
        /// </summary>
        /// <param name="appGuid">App unique Id, doesn't matter the app kind. Method resolves app kind itself using
        /// StoreBehavior property</param>
        /// <returns>A complete IStoreApp compatible object</returns>
        public async Task <IStoreApp> GetStoreAppDataAsync(string appGuid)
        {
            string htmlContents = string.Empty;
            //using behavior factory this return the right object type for each app kind
            var storeApp = StoreBehavior.CreateStoreAppObject();

            //setup 'local' fields
            storeApp.GUID = appGuid;

            storeApp.StoreUri = new Uri(string.Format(StoreBehavior.StoreBaseUri,
                                                      StoreBehavior.StoreCulture, appGuid));

            if (NetWorkHelper.IsInternetAvailable)
            {
                //setup field getting information from web
                try
                {
                    //creating C# query object

                    CQ dom = await HttpClient.GetStringAsync(storeApp.StoreUri);

                    //fill all IStoreApp fields using web information according to behavior
                    StoreBehavior.ObjectDOMMapper(storeApp, dom);
                }
                catch
                {
                    //easing error reporting for user point of view
                    storeApp.Name = string.Format(GeneralResources.AppUrlNotFound, storeApp.StoreUri, appGuid);
                }
            }
            else
            {
                throw new WebException(GeneralResources.InternetRequiredForAppsDataException);
            }

            return(storeApp);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new instance of the <see cref="StoreInitializationParameters"/> class.
 /// </summary>
 /// <param name="storeBehavior">Store behavior.</param>
 /// <param name="allowReadableSecondary">Allow reads on secondaries.</param>
 public StoreInitializationParameters(StoreBehavior storeBehavior, bool allowReadableSecondary)
 {
     this.Version                = SerializationVersion;
     this.StoreBehavior          = storeBehavior;
     this.AllowReadableSecondary = allowReadableSecondary;
 }
 /// <summary></summary>
 /// <param name="behavior">logic container to get information for specific App Kind</param>
 public StoreParser(StoreBehavior behavior)
 {
     StoreBehavior = behavior;
     HttpClient    = new HttpClient();
 }