Exemple #1
0
        /// <summary>
        ///     Generates Data Services' method description which is convertable to JSON
        ///     and can be consumed by clients
        /// </summary>
        public static MethodDescription FromMethodInfo(MethodInfoData data, IServiceContainer container)
        {
            var methDescription = new MethodDescription(data);
            //else Result is Converted to JSON
            var paramsInfo = data.methodInfo.GetParameters();

            for (var i = 0; i < paramsInfo.Length; ++i)
            {
                var param = ParamMetadata.FromParamInfo(paramsInfo[i], container);
                param.ordinal = i;
                methDescription.parameters.Add(param);
            }
            return(methDescription);
        }
Exemple #2
0
        public object GetValue(string name, MethodDescription methodDescription, IServiceContainer serviceContainer)
        {
            var par = parameters.Where(p => p.name == name).FirstOrDefault();

            if (par == null)
            {
                return(null);
            }
            var paraminfo = methodDescription.parameters.Where(p => p.name == name).FirstOrDefault();

            if (paraminfo == null)
            {
                throw new DomainServiceException(string.Format("Method: {0} has no parameter with a name: {1}",
                                                               methodDescription.methodName, name));
            }
            return(serviceContainer.DataHelper.ParseParameter(paraminfo.ParameterType, paraminfo, paraminfo.isArray,
                                                              par.value));
        }