public OperationMetadata(UriModel uri, IMember returnType)
 {
     Uri = uri;
     DesiredReturnType = returnType;
     ResponseCodes = new List<ResponseCode>();
     UriParser=new UriParameterParser(Uri.Uri);
 }
        public static HasTheUri TheUri(this IHas anchor, string uri)
        {
            var target = (IFluentTarget)anchor;

            var uriModel = new UriModel { Uri = uri };
            var resourceModel = new ResourceModel
                {
                    Uris = { uriModel },
                    Handlers = { new ReflectionBasedTypeSystem().FromClr<WebFormsDefaultHandler>() }
                };
            target.Repository.ResourceRegistrations.Add(resourceModel);
            return new HasTheUri(resourceModel, uriModel);
        }
        public OperationGroup Group(ResourceModel resourceModel, UriModel uriModel, OperationMetadata operation)
        {
            var operationCanBeGroupedByUri = _groupRegex.Match(uriModel.Uri);

            if (!operationCanBeGroupedByUri.Success)
            {
                return new OperationGroup { Name = "everything else", Path = "misc" };
            }

            string resourceName = operationCanBeGroupedByUri.Groups[1].Value.ToLower();

            return new OperationGroup
            {
                Name = string.Format("Operations about {0}", resourceName),
                Path = resourceName
            };
        }
        public OperationGroup Group(ResourceModel resourceModel, UriModel uriModel, OperationMetadata operation)
        {
            if (IsUnknownReturnType(operation.ReturnType))
            {
                return new OperationGroup { Name = "Unknown", Path = "unknown" };                
            }

            if (IsEnumerableButNotAString(operation))
            {
                var collectionType = operation.ReturnType.GetElementType();
                if (operation.ReturnType.IsGenericType)
                {
                    collectionType = operation.ReturnType.GetGenericArguments()[0];
                }

                return new OperationGroup
                {
                    Name = "Collection of " + collectionType.Name,
                    Path = collectionType.Name.ToLower() + "[]"
                };
            }

            return new OperationGroup {Name = operation.ReturnType.Name, Path = operation.ReturnType.Name.ToLower()};
        }
 public OperationMetadata(UriModel uri)
 {
     Uri = uri;
     ResponseCodes = new List<ResponseCode>();
     UriParser=new UriParameterParser(Uri.Uri);
 }
Exemple #6
0
 public HasTheUri(ResourceModel model, UriModel uriModel)
 {
     _model = model;
     _uriModel = uriModel;
 }