Beispiel #1
0
        public object Get(string name)
        {
            this.CheckIfInitialized();
            PropertyBag.PROPBAG2 pPropBag = new PropertyBag.PROPBAG2()
            {
                Name = name
            };
            object pvarValue;
            Result phrError;

            if (this.nativePropertyBag.Read(1, ref pPropBag, IntPtr.Zero, out pvarValue, out phrError).Failure || phrError.Failure)
            {
                throw new InvalidOperationException(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "Property with name [{0}] is not valid for this instance", new object[1]
                {
                    (object)name
                }));
            }
            else
            {
                pPropBag.Dispose();
                return(pvarValue);
            }
        }
Beispiel #2
0
        public void Set(string name, object value)
        {
            this.CheckIfInitialized();
            object obj1 = this.Get(name);

            value = Convert.ChangeType(value, obj1 == null ? value.GetType() : obj1.GetType());
            PropertyBag.PROPBAG2 propbaG2 = new PropertyBag.PROPBAG2()
            {
                Name = name
            };
            PropertyBag.IPropertyBag2 propertyBag2 = this.nativePropertyBag;
            int cProperties = 1;

            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            PropertyBag.PROPBAG2& pPropBag = @propbaG2;
            object obj2 = value;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            object& local = @obj2;

            propertyBag2.Write(cProperties, pPropBag, local).CheckError();
            propbaG2.Dispose();
        }