Exemplo n.º 1
0
        /// <summary>
        /// Executes the query performing the underlying operation
        /// </summary>
        /// <typeparam name="T">The type used to define the query - CloudService or StorageAccount</typeparam>
        /// <param name="inputs">The Authentication inputs needed to fulfil the operation</param>
        /// <returns>An IQueryable interface</returns>
        public IQueryable <T> Execute <T>(LinqToAzureInputs inputs)
        {
            if (typeof(T) != GetValidType())
            {
                throw new InvalidQueryException("Mismatch between generic types StorageAccount type expected");
            }

            // Get the place name(s) to query the Web service with.
            var sf = new StorageFinder(_expression != null ? _expression.Body : null);
            var storageAccounts = sf.StorageAccounts;
            //if (storageAccounts.Count == 0)
            //    throw new InvalidQueryException("You must specify at least one place name in your query.");

            // Call the Web service and get the results.
            var manager = new SubscriptionManager(inputs.SubscriptionId);
            List <StorageAccount> accounts;

            try
            {
                var storageManager = manager.GetStorageManager();
                accounts = storageManager.ForStorageInformationQuery()
                           .AddCertificateFromStore(inputs.ManagementCertificateThumbprint)
                           .GetStorageAccountList(true);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Unable to query Windows Azure", ex);
            }

            return((IQueryable <T>)accounts.AsQueryable());
        }
Exemplo n.º 2
0
    void Start()
    {
        // Reproduction
        workersParent = GameObject.Find("Workers").transform;
        canMate       = true;

        // Finders and managers
        resourceFinder  = GetComponent <ResourceFinder>();
        storageFinder   = GetComponent <StorageFinder>();
        resourceManager = FindObjectOfType <ResourceManager>();
        workersManager  = FindObjectOfType <WorkersManager>();
        workersManager.workers.Add(this);
        buildingManager = FindObjectOfType <BuildingManager>();

        // Navigation
        agent = GetComponent <NavMeshAgent>();
        agent.avoidancePriority = Random.Range(1, 99);

        // Resting
        mainBuilding = GameObject.Find("MainBuilding").transform;
        energy.value = 100;
        exactEnergy  = energy.value;

        animator = GetComponent <Animator>();
        animator.SetFloat("Energy", energy.value);

        // Hero stuff
        hero         = GameObject.FindGameObjectWithTag("Player").transform;
        heroDetector = GetComponentInChildren <SphereCollider>();
    }