protected IEnumerable<ArgumentDefinition> GetQueryArguments(BaseWebApiQuerySymbol query)
 {
     //get query argument, if any, then append filters, if any
     return new[]{
                     query.Argument
                         .Select(x => new ArgumentDefinition(GetPublicTypeString(x, query), x.Name.ToString(), x.Cardinality))
                         .ValueOrDefault((ArgumentDefinition)null)}
         .Concat(query.Filters
                     .Select(x => new ArgumentDefinition(GetPublicTypeString(x, query), x.Name.ToString(), x.Cardinality)))
         .Where(x => x != null);
 }
        public void WriteOverrideableMethod(BaseWebApiQuerySymbol query)
        {
            var rawReturnType = TypeNameFactory(query.Result, query);
            var arguments = GetQueryArguments(query);

            var isResourceCollection = !query.Result.Cardinality.Maximum.HasValue ||
                                       query.Result.Cardinality.Maximum.Value > 1;

            var returnType = isResourceCollection
                                ? String.Format("ApiCollectionResource<{0}>", _relativeNameFactory(query.Result.Type.FullName, query.FullName))
                                : String.Format("ApiResource<{0}>", rawReturnType);

            _writer(String.Format("public abstract Result<{0}, Observation> On{1}_Resource({2});",
                                     returnType,
                                     GetQueryName(query),
                                     arguments.Select(x => x.FullTypeDefinition).Delimit(", ")));
        }
        public void WriteInnerMethod(BaseWebApiQuerySymbol query)
        {
            var rawReturnType = TypeNameFactory(query.Result, query);
            var arguments = GetQueryArguments(query);

            var isResourceCollection = !query.Result.Cardinality.Maximum.HasValue ||
                                       query.Result.Cardinality.Maximum.Value > 1;

            var returnType = isResourceCollection
                                ? String.Format("ApiCollectionResource<{0}>", _relativeNameFactory(query.Result.Type.FullName, query.FullName))
                                : String.Format("ApiResource<{0}>", rawReturnType);

            _writer("if (acceptType.Any(x => x.Contains(\"vnd.thomsonreuters.apiresource\")))");
            _writer("{");
            _writer(String.Format("    return new DataResult<Possible<{0}, Observation>>(On{1}_Resource({2}).AsPossible());",
                            returnType,
                            GetQueryName(query),
                            arguments.Select(x => x.Name).Delimit(", ")));
            _writer("}");
        }
        public void WriteOverrideableMethod(BaseWebApiQuerySymbol query)
        {
            var resultType = TypeNameFactory(query.Result, query);
            var arguments = GetQueryArguments(query);

            _writer(String.Format("public abstract Result<{0}, Observation> On{1}_Json({2});",
                                    resultType,
                                    GetQueryName(query),
                                    arguments.Select(x => x.FullTypeDefinition).Delimit(", ")));
        }
        public void WriteInnerMethod(BaseWebApiQuerySymbol query)
        {
            var resultType = TypeNameFactory(query.Result, query);
            var arguments = GetQueryArguments(query);

            _writer("if (acceptType.Any(x => x.Contains(\"json\")))");
            _writer("{");
            _writer(String.Format("    return new DataResult<Possible<{0}, Observation>>(On{1}_Json({2}).AsPossible());",
                                        resultType,
                                        GetQueryName(query),
                                        arguments.Select(a => a.Name).Delimit(", ")));
            _writer("}");
        }
 public void WriteOverrideableMethod(BaseWebApiQuerySymbol query)
 {
     _writer(String.Format("public abstract ViewData On{0}_Html();", GetQueryName(query)));
 }
 public void WriteInnerMethod(BaseWebApiQuerySymbol query)
 {
     _writer("if (acceptType.Any(x => x.Contains(\"html\") || x.Contains(\"*/*\")))");
     _writer("{");
     _writer(String.Format("    var viewData = On{0}_Html();", GetQueryName(query)));
     _writer("    return View(viewData.ViewName, viewData.ViewModel);");
     _writer("}");
 }
 protected string GetQueryName(BaseWebApiQuerySymbol query)
 {
     return (query is WebApiQuerySymbol) ? query.Name.ToString() : "Index";
 }
        public void WriteInnerMethod(BaseWebApiQuerySymbol query)
        {
            var arguments = GetQueryArguments(query);

            _writer(String.Format("return new DataResult<Possible<{0}, Observation>>(On{1}({2}).AsPossible());",
                                    TypeNameFactory(query.Result, query),
                                    GetQueryName(query),
                                    arguments.Select(a => a.Name).Delimit(", ")));
        }