Exemple #1
0
        public async Task <Dictionary <string, Attribute> > GetAttributesAsync(ID id)
        {
            IDControllerService            idcService = new IDControllerService(Web3, AccountService.PrivateKey, id.ControllerAddress);
            Dictionary <string, Attribute> dict       = new Dictionary <string, Attribute>();

            BigInteger attributes = await idcService.AttributeCountAsyncCall();

            for (BigInteger i = 0; i < attributes; i++)
            {
                //Get all attribute keys and addresses for the ID
                byte[] attributeKey = await idcService.GetAttributeKeyAsyncCall(i);

                //Get the attribute and add it to the dict
                Attribute newAttribute = await GetAttributeByKey(idcService, attributeKey);

                dict.Add(newAttribute.Description, newAttribute);
            }

            return(dict);
        }
Exemple #2
0
        public async Task <Dictionary <string, Attribute> > GetAttributesAsync(ID id, string[] accessibleAttributes)
        {
            IDControllerService            idcService = new IDControllerService(Web3, AccountService.PrivateKey, id.ControllerAddress);
            Dictionary <string, Attribute> dict       = new Dictionary <string, Attribute>();

            BigInteger attributes = await idcService.AttributeCountAsyncCall();

            for (BigInteger i = 0; i < attributes; i++)
            {
                //Get all attribute keys and addresses for the ID
                byte[] attributeKey = await idcService.GetAttributeKeyAsyncCall(i);

                string keyStr = Encoding.UTF8.GetString(attributeKey, 0, attributeKey.Length);
                keyStr = keyStr.TrimEnd('\0');//remove null characters at the end of string
                if (accessibleAttributes.Contains(keyStr))
                {
                    //Get the attribute and add it to the dict
                    Attribute newAttribute = await GetAttributeByKey(idcService, attributeKey);

                    dict.Add(newAttribute.Description, newAttribute);
                }
            }
            return(dict);
        }