Exemple #1
0
        // =========================================================================================
        // Methods
        // =========================================================================================

        /// <summary>
        /// Sets the node property.
        /// </summary>
        /// <param name="propid">Property id.</param>
        /// <param name="value">Property value.</param>
        /// <returns>Returns success or failure code.</returns>
        public override int SetProperty(int propid, object value)
        {
            int         result;
            __VSHPROPID id = (__VSHPROPID)propid;

            switch (id)
            {
            case __VSHPROPID.VSHPROPID_IsNonMemberItem:
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }

                bool boolValue = false;
                CCITracing.TraceCall(this.ID + "," + id.ToString());
                if (bool.TryParse(value.ToString(), out boolValue))
                {
                    this.isNonMemberItem = boolValue;
                }
                else
                {
                    WixHelperMethods.TraceFail("Could not parse the IsNonMemberItem property value.");
                }

                result = VSConstants.S_OK;
                break;

            default:
                result = base.SetProperty(propid, value);
                break;
            }

            return(result);
        }
 /// <summary>
 /// Casts the value read from the registry to the appropriate type and caches it.
 /// </summary>
 /// <param name="value">The value read from the registry.</param>
 protected override void CastAndStoreValue(object value)
 {
     try
     {
         this.Value = (string)value;
     }
     catch (InvalidCastException)
     {
         this.Value = this.DefaultValue;
         WixHelperMethods.TraceFail("Cannot convert '{0}' to a string.", value);
     }
 }
 /// <summary>
 /// Casts the value read from the registry to the appropriate type and caches it.
 /// </summary>
 /// <param name="value">The value read from the registry.</param>
 protected override void CastAndStoreValue(object value)
 {
     try
     {
         this.Value = (T)Enum.Parse(typeof(T), value.ToString(), true);
     }
     catch (Exception e)
     {
         if (e is FormatException || e is InvalidCastException)
         {
             this.Value = this.DefaultValue;
             WixHelperMethods.TraceFail("Cannot convert '{0}' to an enum of type '{1}'.", value, typeof(T).Name);
         }
         else
         {
             throw;
         }
     }
 }