コード例 #1
0
        private IProcessTemplateVersionWrapper GetProjectProcessVersion(string projectUri, string versionPropertyName)
        {
            var context = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(this.teamProjectCollectionUrl));
            var ics     = context.GetService <ICommonStructureService4>();

            string projectName;
            string projectState;

            int templateId = 0;

            ProjectProperty[] projectProperties = null;

            ics.GetProjectProperties(projectUri, out projectName, out projectState, out templateId, out projectProperties);

            string rawVersion =
                projectProperties.FirstOrDefault(p => p.Name == versionPropertyName).Value;

            if (rawVersion == null)
            {
                return(new ProcessTemplateVersionWrapper()
                {
                    TypeId = Guid.Empty, Major = 0, Minor = 0
                });
            }
            else
            {
                var result = TeamFoundationSerializationUtility.Deserialize <ProcessTemplateVersion>(rawVersion);
                return(new ProcessTemplateVersionWrapper()
                {
                    TypeId = result.TypeId, Major = result.Major, Minor = result.Minor
                });
            }
        }
コード例 #2
0
        private IProcessTemplateVersion GetProjectProcessVersion(string projectUri, string versionPropertyName)
        {
            ArtifactSpec processTemplateVersionSpec = this.GetProcessTemplateVersionSpec(projectUri);

#if TFS2015
            ProcessTemplateVersion unknown = null;
#elif TFS2013
            ProcessTemplateVersion unknown = ProcessTemplateVersion.Unknown;
#else
#error Define TFS version!
#endif
            ProcessTemplateVersion result = unknown;

            using (TeamFoundationDataReader reader = this.context.GetService <TeamFoundationPropertyService>().GetProperties(this.context, processTemplateVersionSpec, new string[] { versionPropertyName }))
            {
                foreach (ArtifactPropertyValue value2 in reader.Cast <ArtifactPropertyValue>())
                {
                    foreach (PropertyValue value3 in value2.PropertyValues)
                    {
                        result =
                            TeamFoundationSerializationUtility.Deserialize <ProcessTemplateVersion>(
                                value3.Value as string);
                        break;
                    }

                    break;
                }
            }

            return(result == unknown
                ? new ProcessTemplateVersionWrapper()
            {
                TypeId = Guid.Empty, Major = 0, Minor = 0
            }
                : new ProcessTemplateVersionWrapper()
            {
                TypeId = result.TypeId, Major = result.Major, Minor = result.Minor
            });
        }