public bool TryGetValue(K key, out OV value)
        {
            IV  firstOut;
            var result = original.TryGetValue(key, out firstOut);

            value = firstOut;
            return(result);
        }
        internal AzFunctionInfo GetFunctionInfo(string functionId)
        {
            if (_loadedFunctions.TryGetValue(functionId, out AzFunctionInfo funcInfo))
            {
                return(funcInfo);
            }

            throw new InvalidOperationException($"Function with the ID '{functionId}' was not loaded.");
        }
        /// <summary>
        /// Gets the persons number from the specified contact.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <returns>The extracted phone number.</returns>
        public static string GetPersonNumber(MapField <string, Value> parameters)
        {
            var uri        = ContactsContract.CommonDataKinds.Phone.ContentUri;
            var projection = new string[]
            {
                ContactsContract.Contacts.InterfaceConsts.Id,
                ContactsContract.CommonDataKinds.Phone.Number,
                ContactsContract.Contacts.InterfaceConsts.DisplayName
            };
            var cursor = Application.Context.ContentResolver.Query(uri, projection, null, null, null);

            string name;

            parameters.TryGetValue("firstname", out Value firstname);
            parameters.TryGetValue("lastname", out Value lastname);

            if (string.IsNullOrWhiteSpace(lastname.StringValue))
            {
                name = firstname.StringValue;
            }
            else
            {
                name = string.Concat(firstname.StringValue, " ", lastname.StringValue);
            }


            if (cursor.MoveToNext())
            {
                do
                {
                    var number      = cursor.GetString(cursor.GetColumnIndex(projection[1]));
                    var displayName = cursor.GetString(cursor.GetColumnIndex(projection[2]));

                    if (displayName == name)
                    {
                        return(number);
                    }
                }while (cursor.MoveToNext());
            }

            return(string.Empty);
        }
        /// <summary>
        /// Executes the task asynchronously.
        /// </summary>
        /// <param name="command">The command, e.g "call".</param>
        /// <param name="parameters">The specified parameters.</param>
        /// <returns>The executed task.</returns>
        public override Task ExecuteAsync(string command, MapField <string, Value> parameters)
        {
            switch (command)
            {
            case "WriteMessage":
                parameters.TryGetValue("message", out Value message);
                this.SendSMS(ContactManager.GetPersonNumber(parameters), message.ToString());
                break;

            case "help":
                this.SendSMS(this.User.MainCarerPhoneNumber, $"{this.User.FirstName} {this.User.LastName} braucht Hilfe!");
                break;

            default:
                break;
            }

            return(Task.CompletedTask);
        }
 protected override void ApplyMeta(MapField <uint, SerializedMetadata.Types.MetadataEntry> meta)
 {
     if (meta.ContainsKey(0xBA))
     {
         // Debug.Log("GOT ITEM META");
         SerializedMetadata.Types.MetadataEntry ent = null;
         meta.TryGetValue(0xBA, out ent);
         if (ent == null)
         {
             return;
         }
         Debug.Log("GOT ITEM META -- not null");
         MapField <uint, SerializedMetadata.Types.MetadataEntry> item = ent.MetaValue.Entries;
         int item_id   = item[0].Int32Value;
         int item_meta = item[1].Int32Value;
         // int item_count = item[2].Int32Value;
         MeshRenderer renderer = GetComponentInChildren <MeshRenderer>();
         Material     mat      = new Material(itemMaterial);
         mat.mainTexture   = Inventory.getItemTexture(item_id);
         renderer.material = mat;
     }
 }
Beispiel #6
0
    protected override void ApplyMeta(MapField <uint, SerializedMetadata.Types.MetadataEntry> meta)
    {
        if (meta.ContainsKey(0xBA))
        {
            // Debug.Log("GOT ITEM META");
            SerializedMetadata.Types.MetadataEntry ent = null;
            meta.TryGetValue(0xBA, out ent);
            if (ent == null)
            {
                return;
            }
            Debug.Log("GOT ITEM META -- not null");
            MapField <uint, SerializedMetadata.Types.MetadataEntry> item = ent.MetaValue.Entries;
            int item_id = item[0].Int32Value;
            // int item_count = item[1].Int32Value;

            Transform cube = transform.Find("Cube");
            if (item_id < Block.prototypes.Length && Block.prototypes[item_id] != null)
            {
                MeshRenderer renderer = cube.GetComponent <MeshRenderer>();
                Material     mat      = new Material(itemMaterial);
                mat.mainTexture   = Inventory.getItemTexture(item_id);
                renderer.material = mat;
                cube.gameObject.SetActive(true);
            }
            else
            {
                cube.gameObject.SetActive(false);
                Transform model = transform.Find("Model");
                if (model != null)
                {
                    DestroyImmediate(model.gameObject);
                    GameObject prefab = (GameObject)Resources.Load("Entities/Items/" + item_id);
                    GameObject.Instantiate(prefab, transform, false);
                }
            }
        }
    }
 public bool TryGetValue(TKey key, out TValue value)
 {
     return(_internal.TryGetValue(key, out value));
 }