public static Parameter FromOdcmParameter(OdcmParameter odcmParameter) { return new Parameter { Name = odcmParameter.Name, Description = odcmParameter.Description, Type = odcmParameter.IsCollection ? new Type(new Identifier("System.Collections.Generic", "ICollection"), new Type(NamesService.GetConcreteTypeName(odcmParameter.Type))) : TypeService.GetParameterType(odcmParameter) }; }
public Given_an_OdcmParameter() { _model = new OdcmModel(Any.ServiceMetadata()); _namespace = Any.EmptyOdcmNamespace(); _model.Namespaces.Add(_namespace); _class = Any.OdcmEntityClass(_namespace); _model.AddType(_class); _method = Any.OdcmMethod(m => m.Parameters.Clear()); _class.Methods.Add(_method); _param = Any.OdcmParameter(); _method.Parameters.Add(_param); _expectedMethodName = _method.Name + "Async"; }
public static OdcmParameter OdcmParameter(Action<OdcmParameter> config = null) { var retVal = new OdcmParameter(Any.CSharpIdentifier()); if (config != null) config(retVal); return retVal; }
private void WriteMethod(OdcmClass odcmClass, IEdmOperation operation, IEdmOperationImport operationImport = null) { var parameters = operation.IsBound ? (from parameter in operation.Parameters where parameter != operation.Parameters.First() select parameter) : (operation.Parameters); var isBoundToCollection = operation.IsBound && operation.Parameters.First().Type.IsCollection(); var odcmMethod = new OdcmMethod(operation.Name, odcmClass.Namespace) { IsComposable = operation.IsFunction() && ((IEdmFunction)operation).IsComposable, IsBoundToCollection = isBoundToCollection, Verbs = operation.IsAction() ? OdcmAllowedVerbs.Post : OdcmAllowedVerbs.Any, Class = odcmClass }; AddVocabularyAnnotations(odcmMethod, operation); if (operationImport != null) { AddVocabularyAnnotations(odcmMethod, operationImport); } odcmClass.Methods.Add(odcmMethod); if (operation.ReturnType != null) { odcmMethod.ReturnType = ResolveType(operation.ReturnType); odcmMethod.IsCollection = operation.ReturnType.IsCollection(); } var callingConvention = operation.IsAction() ? OdcmCallingConvention.InHttpMessageBody : OdcmCallingConvention.InHttpRequestUri; foreach (var parameter in parameters) { var odcmParameter = new OdcmParameter(parameter.Name) { CallingConvention = callingConvention, Type = ResolveType(parameter.Type), IsCollection = parameter.Type.IsCollection(), IsNullable = parameter.Type.IsNullable }; AddVocabularyAnnotations(odcmParameter, parameter); odcmMethod.Parameters.Add(odcmParameter); } }
public static Type GetParameterType(OdcmParameter parameter) { return parameter.IsNullable && IsValueType(parameter.Type) && !(parameter.Type is OdcmEnum) ? GetNullableType(parameter.Type) : new Type(NamesService.GetPublicTypeName(parameter.Type)); }