Ejemplo n.º 1
0
        private bool TryCreateFunctionMetadata(MethodDefinition method, out SdkFunctionMetadata?function)
        {
            function = null;

            foreach (CustomAttribute attribute in method.CustomAttributes)
            {
                if (attribute.AttributeType.FullName == "Microsoft.Azure.WebJobs.FunctionNameAttribute")
                {
                    TypeDefinition declaringType = method.DeclaringType;

                    string assemblyName = declaringType.Module.Assembly.Name.Name;

                    var functionName = attribute.ConstructorArguments.SingleOrDefault().Value.ToString();

                    if (string.IsNullOrEmpty(functionName))
                    {
                        continue;
                    }

                    function = new SdkFunctionMetadata
                    {
                        Name       = functionName,
                        ScriptFile = $"bin/{assemblyName}.dll",
                        EntryPoint = $"{declaringType.GetReflectionFullName()}.{method.Name}",
                        Language   = "dotnet-isolated"
                    };

                    function.Properties["IsCodeless"] = false;

                    return(true);
                }
            }

            return(false);
        }
        private SdkFunctionMetadata CreateSdkFunctionMetadata(string functionName, string actualMethodName, string declaringTypeName, string assemblyName)
        {
            var function = new SdkFunctionMetadata
            {
                Name       = functionName,
                ScriptFile = $"{assemblyName}.dll",
                EntryPoint = $"{declaringTypeName}.{actualMethodName}",
                Language   = "dotnet-isolated"
            };

            function.Properties["IsCodeless"] = false;

            return(function);
        }