Beispiel #1
0
#pragma warning restore CS0618

        public void LoadFunction(IFunction function, FunctionMetadata functionMetadata)
        {
            if (function == null)
            {
                throw new ArgumentNullException(nameof(function));
            }
            if (functionMetadata == null)
            {
                return;
            }

            //Fix the bloody metadata
            FixFunctionMetadata(functionMetadata);

            //Now get the simple stuff
            function.Name         = functionMetadata.Name;
            function.ReturnTypeId = functionMetadata.ReturnTypeId;

            //Add variables
            if (functionMetadata.Variables != null)
            {
                AddToOwner(function, functionMetadata.Variables);
            }

            //Add arguments
            if (functionMetadata.Arguments != null)
            {
                AddToOwner(function, functionMetadata.Arguments);
            }

            //Add return variable
            if (functionMetadata.ReturnTypeId != null)
            {
                //Get the type for the return variable.
                var type = function.GetVplTypeOrThrow(functionMetadata.ReturnTypeId.Value);

                //Add the return variable.
                function.AddVariable(new ReturnValueVariable(function, type));
            }

            //Add elements
            if (functionMetadata.Elements != null)
            {
                AddToOwner(function, functionMetadata.Elements);
            }

            function.MarkClean();
        }
Beispiel #2
0
#pragma warning restore CS0618

        public void LoadFunction(IFunction function, FunctionMetadata functionMetadata)
        {
            if (function == null) throw new ArgumentNullException(nameof(function));
            if (functionMetadata == null)
                return;

            //Fix the bloody metadata
            FixFunctionMetadata(functionMetadata);

            //Now get the simple stuff
            function.Name = functionMetadata.Name;
            function.ReturnTypeId = functionMetadata.ReturnTypeId;

            //Add variables
            if (functionMetadata.Variables != null)
            {
                AddToOwner(function, functionMetadata.Variables);
            }

            //Add arguments
            if (functionMetadata.Arguments != null)
            {
                AddToOwner(function, functionMetadata.Arguments);
            }

            //Add return variable
            if (functionMetadata.ReturnTypeId != null)
            {
                //Get the type for the return variable.
                var type = function.GetVplTypeOrThrow(functionMetadata.ReturnTypeId.Value);

                //Add the return variable.
                function.AddVariable(new ReturnValueVariable(function, type));
            }

            //Add elements
            if (functionMetadata.Elements != null)
            {
                AddToOwner(function, functionMetadata.Elements);
            }           

            function.MarkClean();
        }