示例#1
0
            public override object ConvertFrom
            (
                ITypeDescriptorContext ctx,
                CultureInfo ci,
                object data)
            {
                BuildLabel vfp = null;

                if (data != null)
                {
                    vfp = BuildLabel.Parse(data.ToString());
                }

                return(vfp);
            }
示例#2
0
            /// <summary>
            /// This code performs the actual conversion from a BuildLabel to an InstanceDescriptor.
            /// </summary>
            public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
            {
                if (destinationType == typeof(InstanceDescriptor))
                {
                    ConstructorInfo ci = typeof(BuildLabel).GetConstructor
                                         (
                        new Type[] { typeof(string) }
                                         );

                    BuildLabel t = ( BuildLabel )value;

                    return(new InstanceDescriptor(ci, new object[] { t.ToString() }));
                }

                // Always call base, even if you can't convert.
                return(base.ConvertTo(context, culture, value, destinationType));
            }
示例#3
0
        public override Boolean Equals(object obj)
        {
            // If parameter is null return false
            if (obj == null)
            {
                return(false);
            }

            BuildLabel other = obj as BuildLabel;

            if ((System.Object)other == null)
            {
                return(false);
            }

            // Return true if the fields match (may be referenced by derived classes)
            return(this.GetHashCode() == other.GetHashCode());
        }
示例#4
0
        /// <summary>
        /// Returns a BuildLabel object for a source depot label syntax or Official Build Name syntax string
        /// </summary>
        /// <param name="buildLabelOrBuildName">
        /// Can be the source depot label syntax (e.g., "[branch]_7792_0_100802-1750" or
        /// "winblue_gdr_9600_16442_131022-1819" or "winmain_9889_0_141114-1920") or the build
        /// lab Official Build Name syntax, version.qfe.flavor.branch.revision (e.g,
        /// "5456.0.amd64fre.vbl_tools_build.060614-1215" or "10240.0.winmain.150709-1450");
        /// see http://windowssites/sites/winbuilddocs/Wiki%20Pages/FindBuild%20Web%20Service.aspx
        /// </param>
        /// <returns>A BuildLabel object if the input string is nonnull and valid, NULL otherwise</returns>
        public static BuildLabel Parse(string buildLabelOrBuildName)
        {
            BuildLabel ret = null;

            if (!string.IsNullOrWhiteSpace(buildLabelOrBuildName))
            {
                Match buildLabelMatch = CommonRegex.BuildLabelRegex.Match(buildLabelOrBuildName);

                if (buildLabelMatch.Success)
                {
                    ret = new BuildLabel
                          (
                        buildLabelMatch.Groups[1].ToString(),
                        Int16.Parse(buildLabelMatch.Groups[2].ToString()),
                        Int16.Parse(buildLabelMatch.Groups[3].ToString()),
                        buildLabelMatch.Groups[4].ToString()
                          );
                }
                else
                {
                    Match buildNameMatch = CommonRegex.BuildNameRegex.Match(buildLabelOrBuildName);

                    if (buildNameMatch.Success)
                    {
                        string flavor = buildNameMatch.Groups[3].ToString();                           // TODO Pri 2: expose this?

                        ret = new BuildLabel
                              (
                            buildNameMatch.Groups[3].ToString(),
                            Int16.Parse(buildNameMatch.Groups[1].ToString()),
                            Int16.Parse(buildNameMatch.Groups[2].ToString()),
                            buildNameMatch.Groups[4].ToString()
                              );
                    }
                }
            }

            return(ret);
        }