Esempio n. 1
0
        /// <inheritdoc />
        public async Task <int> AddAnnotation(ModelAnnotation annotation)
        {
            await _context.ModelAnnotations.AddAsync(annotation);

            await _context.SaveChangesAsync();

            return(annotation.Id);
        }
Esempio n. 2
0
        public SmartContractMethodsModel GetContractMethods(RequestKeyApiModel model)
        {
            var response = new SmartContractMethodsModel();

            using (var client = GetClientByModel(model))
            {
                var publicKeyByte = SimpleBase.Base58.Bitcoin.Decode(model.PublicKey);
                var preResult     = client.SmartContractGet(publicKeyByte.ToArray());
                if (preResult.SmartContract != null && preResult.SmartContract.SmartContractDeploy != null)
                {
                    //response.SourceString = result.SmartContract.SmartContractDeploy.SourceCode;
                    var finalResult = client.ContractAllMethodsGet(preResult.SmartContract.SmartContractDeploy.ByteCodeObjects);
                    foreach (var met in finalResult.Methods)
                    {
                        var method = new ContractMethod();
                        method.Name       = met.Name;
                        method.ReturnType = met.ReturnType;
                        foreach (var arg in met.Arguments)
                        {
                            var ar = new ModelMethodArgument();
                            ar.Name = arg.Name;
                            ar.Type = arg.Type;
                            foreach (var ann in arg.Annotations)
                            {
                                var an = new ModelAnnotation();
                                an.Name      = ann.Name;
                                an.Arguments = ann.Arguments;
                                ar.Annotations.Add(an);
                            }
                            method.Arguments.Add(ar);
                        }
                        foreach (var ann in met.Annotations)
                        {
                            var an = new ModelAnnotation();
                            an.Name      = ann.Name;
                            an.Arguments = ann.Arguments;
                            method.Annotations.Add(an);
                        }
                        response.Methods.Add(method);
                    }
                }
            }

            return(response);
        }
Esempio n. 3
0
 /// <inheritdoc />
 public Task DeleteAnnotation(ModelAnnotation annotation)
 {
     _context.ModelAnnotations.Remove(annotation);
     return(_context.SaveChangesAsync());
 }