Пример #1
0
 internal ProjectCollection(Microsoft.TeamFoundation.WorkItemTracking.Client.ProjectCollection valueProjects)
     : base(
         valueProjects.Cast <Microsoft.TeamFoundation.WorkItemTracking.Client.Project>()
         .Select(item => ExceptionHandlingDynamicProxyFactory.Create <IProject>(new Project(item))).ToList()
         )
 {
 }
Пример #2
0
 public IEnumerator <IField> GetEnumerator()
 {
     return(_innerCollection.Cast <Tfs.Field>()
            .Select(
                field => ExceptionHandlingDynamicProxyFactory.Create <IField>(new Field(field)))
            .GetEnumerator());
 }
Пример #3
0
 internal Field(Tfs.Field field)
     : base(
         ExceptionHandlingDynamicProxyFactory.Create <IRevisionInternal>(new WorkItem(field?.WorkItem)),
         ExceptionHandlingDynamicProxyFactory.Create <IFieldDefinition>(new FieldDefinition(field?.FieldDefinition)))
 {
     NativeField = field ?? throw new ArgumentNullException(nameof(field));
 }
Пример #4
0
        public IWorkItemStore Create(Uri endpoint, IEnumerable <TfsCredentials> credentials)
        {
            Func <WorkItemStore, IQueryFactory> queryFactoryFunc = QueryFactory.GetInstance;

            foreach (var credential in credentials)
            {
                try
                {
                    var tfsNative = ConnectToTfsCollection(endpoint, credential.Credentials);

                    System.Diagnostics.Trace.TraceInformation("TFS connection attempt success with {0}/{1}.", credential.Credentials.Windows.GetType(), credential.Credentials.Federated.GetType());

                    var tfs           = ExceptionHandlingDynamicProxyFactory.Create <IInternalTfsTeamProjectCollection>(new TfsTeamProjectCollectionProxy(tfsNative));
                    var workItemStore = tfs.GetService <WorkItemStore>();
                    var queryFactory  = queryFactoryFunc.Invoke(workItemStore);

                    return(ExceptionHandlingDynamicProxyFactory.Create <IWorkItemStore>(new WorkItemStoreProxy(tfs, workItemStore, queryFactory)));
                }
                catch (TeamFoundationServerUnauthorizedException e)
                {
                    System.Diagnostics.Trace.TraceWarning("TFS connection attempt failed with {0}/{1}.\n Exception: {2}", credential.Credentials.Windows.GetType(), credential.Credentials.Federated.GetType(), e);
                }
            }

            System.Diagnostics.Trace.TraceError("All TFS connection attempts failed.");
            throw new AccessDeniedException("Invalid credentials");
        }
Пример #5
0
 internal RelatedLink(Tfs.RelatedLink relatedLink)
     : base(
         relatedLink.RelatedWorkItemId,
         ExceptionHandlingDynamicProxyFactory.Create <IWorkItemLinkTypeEnd>(new WorkItemLinkTypeEnd(relatedLink.LinkTypeEnd)),
         relatedLink.Comment)
 {
 }
Пример #6
0
 internal WorkItem(Tfs.WorkItem item)
     : base(
         ExceptionHandlingDynamicProxyFactory.Create <IWorkItemType>(new WorkItemType(item.Type)),
         () => ExceptionHandlingDynamicProxyFactory.Create <IFieldCollection>(new FieldCollection(item.Fields)))
 {
     _item = item;
     Url   = item.Uri.ToString();
 }
Пример #7
0
 public override IEnumerator <IWorkItemType> GetEnumerator()
 {
     return(_workItemTypeCollection.Cast <Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemType>()
            .Select(
                item => ExceptionHandlingDynamicProxyFactory.Create <IWorkItemType>(
                    new WorkItemType(item)))
            .GetEnumerator());
 }
Пример #8
0
 internal static IIdentityDescriptor AsProxy([NotNull] this Microsoft.TeamFoundation.Framework.Client.IdentityDescriptor descriptor)
 {
     if (descriptor == null)
     {
         throw new ArgumentNullException(nameof(descriptor));
     }
     return(ExceptionHandlingDynamicProxyFactory.Create <IIdentityDescriptor>(new Client.Soap.IdentityDescriptor(descriptor)));
 }
Пример #9
0
 internal FieldDefinitionCollection(Tfs.FieldDefinitionCollection innerCollection)
     : base(
         innerCollection.Cast <Tfs.FieldDefinition>()
         .Select(
             field => ExceptionHandlingDynamicProxyFactory.Create <IFieldDefinition>(
                 new FieldDefinition(field)))
         .ToList())
 {
 }
Пример #10
0
        public IEnumerable <ITeamFoundationIdentity> ReadIdentities(ICollection <IIdentityDescriptor> descriptors)
        {
            var rawDescriptors = descriptors.Select(descriptor =>
                                                    new Tfs.Client.IdentityDescriptor(descriptor.IdentityType, descriptor.Identifier)).ToArray();

            var identities = _identityManagementService2.ReadIdentities(rawDescriptors, Tfs.Common.MembershipQuery.None,
                                                                        Tfs.Common.ReadIdentityOptions.IncludeReadFromSource);

            return(identities.Select(identity => identity == null ? null : ExceptionHandlingDynamicProxyFactory.Create <ITeamFoundationIdentity>(new TeamFoundationIdentityProxy(identity))));
        }
Пример #11
0
        public override IWorkItemStore Create(AuthenticationOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            var tfsProxy = (IInternalTeamProjectCollection)TfsConnectionFactory.Default.Create(options);

            return(ExceptionHandlingDynamicProxyFactory.Create(CreateSoapWorkItemStore(tfsProxy)));
        }
Пример #12
0
        public IQuery Create(string wiql, bool dayPrecision)
        {
            var q = new Query(
                new Microsoft.TeamFoundation.WorkItemTracking.Client.Query(_store.NativeWorkItemStore, wiql, null, dayPrecision),
                _store.Configuration.PageSize);

            return(_store.Configuration.ProxyCreationEnabled
                ? ExceptionHandlingDynamicProxyFactory.Create <IQuery>(q)
                : q);
        }
 public override void Given()
 {
     ProxiedInstance =
         ExceptionHandlingDynamicProxyFactory.Create(
             InstanceToProxy,
             Enumerable.Empty <IExceptionExploder>(),
             new[]
     {
         new MockArgumentExceptionMapper()
     });
 }
Пример #14
0
        private ITeamFoundationIdentity TryCreateProxy(Tfs.Client.TeamFoundationIdentity identity)
        {
            if (identity == null)
            {
                return(null);
            }

            return
                (ExceptionHandlingDynamicProxyFactory.Create <ITeamFoundationIdentity>(
                     new TeamFoundationIdentityProxy(identity)));
        }
Пример #15
0
 internal WorkItemType(Tfs.WorkItemType type)
     : base(
         type?.Name,
         type?.Description,
         new Lazy <IFieldDefinitionCollection>(() => ExceptionHandlingDynamicProxyFactory.Create <IFieldDefinitionCollection>(new FieldDefinitionCollection(type?.FieldDefinitions))),
         () => ExceptionHandlingDynamicProxyFactory.Create <IWorkItem>(new WorkItem(type?.NewWorkItem()))
         )
 {
     if (type == null)
     {
         throw new ArgumentNullException(nameof(type));
     }
 }
Пример #16
0
        internal TeamFoundationIdentity(Tfs.TeamFoundationIdentity identity)
            : base(
                identity.IsActive,
                identity.TeamFoundationId,
                identity.UniqueUserId,
                identity.MemberOf.Select(i => new IdentityDescriptor(i)).ToArray(),
                identity.Members.Select(i => new IdentityDescriptor(i)).ToArray())
        {
            _identity = identity;

            _descriptor = new Lazy <IIdentityDescriptor>(
                () => ExceptionHandlingDynamicProxyFactory.Create <IIdentityDescriptor>(
                    new IdentityDescriptor(_identity.Descriptor)));
        }
Пример #17
0
        public ILink Map(Tfs.Link link)
        {
            if (link.BaseType == Tfs.BaseLinkType.RelatedLink)
            {
                var relatedLink = (Tfs.RelatedLink)link;
                return(ExceptionHandlingDynamicProxyFactory.Create <IRelatedLink>(new RelatedLinkProxy(relatedLink)));
            }
            if (link.BaseType == Tfs.BaseLinkType.Hyperlink)
            {
                var hyperlink = (Tfs.Hyperlink)link;
                return(ExceptionHandlingDynamicProxyFactory.Create <IHyperlink>(new HyperlinkProxy(hyperlink)));
            }

            throw new ArgumentException("Unknown link type", nameof(link));
        }
Пример #18
0
        public bool TryGetById(int id, out IField value)
        {
            try
            {
                var nativeField = _innerCollection.TryGetById(id);
                if (nativeField != null)
                {
                    value = ExceptionHandlingDynamicProxyFactory.Create <IField>(new Field(nativeField));
                    return(true);
                }
            }
            catch (Exception)
            {
            }

            value = null;
            return(false);
        }
Пример #19
0
        public IWorkItemCollection RunQuery()
        {
            var wic = _query.RunQuery();

            wic.PageSize = _pageSize;

            // TODO: Use Lazy config options
            var items = new List <IWorkItem>(wic.Count);

            for (var i = 0; i < wic.Count; i++)
            {
                // TODO: Use proxy config options
                var item = ExceptionHandlingDynamicProxyFactory.Create <IWorkItem>((WorkItem)wic[i]);
                items.Add(item);
            }

            return(new WorkItemCollection(items));
        }
Пример #20
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="TfsTeamProjectCollection" /> class.
        /// </summary>
        /// <param name="teamProjectCollection">The TFS.</param>
        /// <exception cref="ArgumentNullException">tfs</exception>
        internal TfsTeamProjectCollection(Microsoft.TeamFoundation.Client.TfsTeamProjectCollection teamProjectCollection)
        {
            Native = teamProjectCollection ?? throw new ArgumentNullException(nameof(teamProjectCollection));

            AuthorizedCredentials = Native.ClientCredentials;
            AuthorizedIdentity    = new TeamFoundationIdentity(Native.AuthorizedIdentity);
            Uri = Native.Uri;

            _css = new Lazy <ICommonStructureService>(
                () => ExceptionHandlingDynamicProxyFactory.Create <ICommonStructureService>(
                    new
                    CommonStructureService(
                        Native
                        .GetService
                        <
                            ICommonStructureService4
                        >())));
        }
Пример #21
0
        public IQuery Create(IEnumerable <int> ids, string wiql)
        {
            if (ids == null)
            {
                throw new ArgumentNullException(nameof(ids));
            }
            if (string.IsNullOrWhiteSpace(wiql))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(wiql));
            }

            var q = new Query(
                new Microsoft.TeamFoundation.WorkItemTracking.Client.Query(_store.NativeWorkItemStore, wiql, ids.ToArray()),
                _store.Configuration.PageSize);

            return(_store.Configuration.ProxyCreationEnabled
                       ? ExceptionHandlingDynamicProxyFactory.Create <IQuery>(q)
                       : q);
        }
Пример #22
0
        internal ILink Map(Tfs.Link link)
        {
            switch (link.BaseType)
            {
            case Tfs.BaseLinkType.RelatedLink:
                var relatedLink = (Tfs.RelatedLink)link;
                return(ExceptionHandlingDynamicProxyFactory.Create <IRelatedLink>(new RelatedLink(relatedLink)));

            case Tfs.BaseLinkType.Hyperlink:
                var hyperlink = (Tfs.Hyperlink)link;
                return(ExceptionHandlingDynamicProxyFactory.Create <IHyperlink>(new Hyperlink(hyperlink)));

            case Tfs.BaseLinkType.ExternalLink:
                var externalLink = (Tfs.ExternalLink)link;
                return(ExceptionHandlingDynamicProxyFactory.Create <IExternalLink>(new ExternalLink(externalLink)));

            default:
                throw new ArgumentException("Unknown link type", nameof(link));
            }
        }
Пример #23
0
 public IIdentityDescriptor CreateIdentityDescriptor(string identityType, string identifier)
 {
     return(ExceptionHandlingDynamicProxyFactory.Create <IIdentityDescriptor>(new IdentityDescriptorProxy(new Tfs.Client.IdentityDescriptor(identityType, identifier))));
 }
Пример #24
0
 internal static IIdentityManagementService AsProxy([CanBeNull] this IIdentityManagementService2 ims)
 {
     return(ims == null
                ? null
                : ExceptionHandlingDynamicProxyFactory.Create <IIdentityManagementService>(new IdentityManagementService(ims)));
 }
Пример #25
0
 public override IWorkItemType this[string name] => ExceptionHandlingDynamicProxyFactory
 .Create <IWorkItemType>(new WorkItemType(_workItemTypeCollection[name]));
Пример #26
0
 internal static ITeamFoundationIdentity AsProxy(this Microsoft.TeamFoundation.Framework.Client.TeamFoundationIdentity identity)
 {
     return(identity == null
         ? null
         : ExceptionHandlingDynamicProxyFactory.Create <ITeamFoundationIdentity>(new TeamFoundationIdentity(identity)));
 }
Пример #27
0
 public IEnumerable <IWorkItemLinkInfo> RunLinkQuery()
 {
     return(_query.RunLinkQuery().Select(item => ExceptionHandlingDynamicProxyFactory.Create <IWorkItemLinkInfo>(new WorkItemLinkInfoProxy(item))));
 }
Пример #28
0
 public IEnumerable <IWorkItem> RunQuery()
 {
     return(_query.RunQuery().Cast <TeamFoundation.WorkItemTracking.Client.WorkItem>().Select(item => ExceptionHandlingDynamicProxyFactory.Create <IWorkItem>(new WorkItemProxy(item))));
 }
Пример #29
0
 public IWorkItem NewWorkItem()
 {
     return(ExceptionHandlingDynamicProxyFactory.Create <IWorkItem>(new WorkItemProxy(_type.NewWorkItem())));
 }
Пример #30
0
 public IField this[string name]
 {
     get { return(ExceptionHandlingDynamicProxyFactory.Create <IField>(new FieldProxy(_innerCollection[name]))); }
 }