Ejemplo n.º 1
0
        private static IItem FindSourceItemForElement(IProductElement element, Func <IEnumerable <IItem>, IItem> filter)
        {
            var references = ServiceProviderExtensions
                             .GetService <IUriReferenceService>(element.Product.ProductState);

            var sourceFile = filter(SolutionArtifactLinkReference.GetResolvedReferences(element, references).OfType <IItem>());

            return(sourceFile);
        }
        public static string GetServiceTemplate(MethodInfo methodInfo, IServiceProvider serviceLocator)
        {
            var template = ServiceProviderExtensions.GetService <IRouteTemplateResolver>(serviceLocator)?.GetTemplate(methodInfo);

            if (!String.IsNullOrWhiteSpace(template))
            {
                return(template);
            }
            var verbAttribute  = methodInfo.GetCustomAttribute <VerbAttribute>();
            var templateAttrib = methodInfo.GetCustomAttribute <IRouteAttribute>();

            if (templateAttrib == null)
            {
                return(verbAttribute?.Route ?? template ?? "");
            }
            template = templateAttrib.Template;
            return(template ?? "");
        }
        public static void BuildParameterInfo(MethodInfo methodInfo, ActionWrapper action, IServiceProvider serviceLocator)
        {
            var parameterHandler = ServiceProviderExtensions.GetService <IServiceParameterResolver>(serviceLocator);

            if (parameterHandler != null)
            {
                var parameters = parameterHandler.ResolveParameters(methodInfo);
                if (parameters != null && parameters.Any())
                {
                    action.Parameters.AddRange(parameters);
                    foreach (var pi in methodInfo.GetParameters())
                    {
                        action.MessageExtesionLevel = pi.GetCustomAttribute <ExtensionLevelAttribute>() == null
                            ? action.MessageExtesionLevel
                            : pi.GetCustomAttribute <ExtensionLevelAttribute>().PropertInjectionLevel;
                    }
                    return;
                }
            }
            foreach (var parameterInfo in methodInfo.GetParameters())
            {
                var @in = parameterInfo.GetCustomAttribute <InAttribute>(true);
                //if (@in == null)
                //{
                //    var fromBody = parameterInfo.GetCustomAttribute<FromBodyAttribute>(true);
                //    if (fromBody != null)
                //        @in = new InAttribute(InclutionTypes.Body);
                //    if (@in == null)
                //    {
                //        var fromUri = parameterInfo.GetCustomAttribute<FromUriAttribute>(true);
                //        if (fromUri != null)
                //            @in = new InAttribute(InclutionTypes.Path);
                //    }

                //}
                action.MessageExtesionLevel = parameterInfo.GetCustomAttribute <ExtensionLevelAttribute>() == null
                           ? action.MessageExtesionLevel
                           : parameterInfo.GetCustomAttribute <ExtensionLevelAttribute>().PropertInjectionLevel;
                action.Parameters.Add(new ParameterWrapper {
                    Name = parameterInfo.Name, Type = parameterInfo.ParameterType, In = @in?.InclutionType ?? InclutionTypes.Body
                });
            }
        }
        public static List <HttpMethod> GetHttpMethods(List <VerbAttribute> actions, MethodInfo method, IServiceProvider serviceLocator)
        {
            var methodResolver = ServiceProviderExtensions.GetService <IWebMethodConverter>(serviceLocator);
            var methods        = new List <HttpMethod>();

            if (methodResolver != null)
            {
                methods.AddRange(methodResolver.GetHttpMethods(method));
            }
            foreach (var actionHttpMethodProvider in actions)
            {
                methods.Add(new HttpMethod(actionHttpMethodProvider.Verb));
            }
            if (methods.Count == 0)
            {
                methods.Add(HttpMethod.Get);
            }
            return(methods);
        }
Ejemplo n.º 5
0
 public RegisterItemDialog(IServiceProvider services, ITrackedItemType type, IList <ITrackedItemType> allTypes, string defaultTitle, string defaultDescription, string[] fileAttachments)
 {
     this.services           = services;
     this.configuration      = ServiceProviderExtensions.GetService <IConfigurationService>(this.services)["SaveTFSWorkItem"];
     this.defaultTitle       = defaultTitle;
     this.defaultDescription = defaultDescription;
     this.fileAttachments    = fileAttachments;
     this.allTypes           = allTypes;
     this.InitializeComponent();
     this.DataContext         = (object)this;
     this.Title               = StringTable.RegisterTFSItemDialogTitle;
     this.type                = type;
     this.AcceptButton.Click += new RoutedEventHandler(this.Button_Click);
     this.CancelButton.Click += new RoutedEventHandler(this.Button_Click);
     this.ChooseButton.Click += new RoutedEventHandler(this.Button_Click);
     this.RegenerateForm(type);
     this.Height       = (double)this.configuration.GetProperty("Height", (object)645.0);
     this.Width        = (double)this.configuration.GetProperty("Width", (object)750.0);
     this.SizeChanged += new SizeChangedEventHandler(this.RegisterItemDialog_SizeChanged);
 }
        public static string GetRouteTemplate(IRoutePrefix templatePrefix, IRoute template, MethodInfo methodInfo, IServiceProvider serviceLocator)
        {
            var interfaceType    = methodInfo.DeclaringType;
            var templateResolver = ServiceProviderExtensions.GetService <IRouteTemplateResolver>(serviceLocator);
            var route            = templateResolver?.GetTemplate(methodInfo);

            if (!String.IsNullOrWhiteSpace(route))
            {
                return(route);
            }
            string prefix = "";

            if (templatePrefix != null)
            {
                prefix = templatePrefix.Prefix;
                if (templatePrefix.IncludeTypeName)
                {
                    prefix = prefix + "/" + (interfaceType.GetGenericArguments().Any() ? interfaceType.GetGenericArguments().FirstOrDefault()?.Name.ToLower() : interfaceType.GetInterfaces().FirstOrDefault()?.GetGenericArguments().First().Name.ToLower());
                }
            }
            return((templatePrefix == null ? "" : (prefix + "/") + template.Template).Replace("//", "/"));
        }