예제 #1
0
 protected override T GetMember <T>(object obj, string memberName)
 {
     using (ComAdapter.tracer.TraceMethod())
     {
         ComTypeInfo typeInfo = this.GetTypeInfo();
         if (typeInfo != null && typeInfo.Properties.ContainsKey(memberName))
         {
             ComProperty property = typeInfo.Properties[memberName];
             if (property.IsParameterized)
             {
                 if (typeof(T).IsAssignableFrom(typeof(PSParameterizedProperty)))
                 {
                     return(new PSParameterizedProperty(property.Name, (Adapter)this, obj, (object)property) as T);
                 }
             }
             else if (typeof(T).IsAssignableFrom(typeof(PSProperty)))
             {
                 return(new PSProperty(property.Name, (Adapter)this, obj, (object)property) as T);
             }
         }
         if (!typeof(T).IsAssignableFrom(typeof(PSMethod)) || typeInfo == null || !typeInfo.Methods.ContainsKey(memberName))
         {
             return(default(T));
         }
         ComMethod method = typeInfo.Methods[memberName];
         return(new PSMethod(method.Name, (Adapter)this, obj, (object)method) as T);
     }
 }
예제 #2
0
 protected override T GetMember <T>(object obj, string memberName)
 {
     if (this._comTypeInfo.Properties.ContainsKey(memberName))
     {
         ComProperty adapterData = this._comTypeInfo.Properties[memberName];
         if (adapterData.IsParameterized)
         {
             if (typeof(T).IsAssignableFrom(typeof(PSParameterizedProperty)))
             {
                 return(new PSParameterizedProperty(adapterData.Name, this, obj, adapterData) as T);
             }
         }
         else if (typeof(T).IsAssignableFrom(typeof(PSProperty)))
         {
             return(new PSProperty(adapterData.Name, this, obj, adapterData) as T);
         }
     }
     if ((typeof(T).IsAssignableFrom(typeof(PSMethod)) && (this._comTypeInfo != null)) && this._comTypeInfo.Methods.ContainsKey(memberName))
     {
         ComMethod method  = this._comTypeInfo.Methods[memberName];
         PSMethod  method2 = new PSMethod(method.Name, this, obj, method);
         return(method2 as T);
     }
     return(default(T));
 }
예제 #3
0
        protected override Collection <string> ParameterizedPropertyDefinitions(PSParameterizedProperty property)
        {
            ComProperty adapterData = (ComProperty)property.adapterData;

            return(new Collection <string> {
                adapterData.GetDefinition()
            });
        }
예제 #4
0
        /// <summary>
        /// Called after a non null return from GetMember to return the overloads
        /// </summary>
        /// <param name="property">the return of GetMember</param>
        protected override Collection <String> ParameterizedPropertyDefinitions(PSParameterizedProperty property)
        {
            ComProperty         prop        = (ComProperty)property.adapterData;
            Collection <string> returnValue = new Collection <string> {
                prop.GetDefinition()
            };

            return(returnValue);
        }
예제 #5
0
        protected override string PropertyType(PSProperty property, bool forDisplay)
        {
            ComProperty adapterData = (ComProperty)property.adapterData;

            if (!forDisplay)
            {
                return(adapterData.Type.FullName);
            }
            return(ToStringCodeMethods.Type(adapterData.Type, false));
        }
예제 #6
0
        private void AddProperty(string strName, System.Runtime.InteropServices.ComTypes.FUNCDESC funcdesc, int index)
        {
            ComProperty comProperty;

            if (this.properties.ContainsKey(strName))
            {
                comProperty = this.properties[strName];
            }
            else
            {
                comProperty = new ComProperty(this.typeinfo, strName);
                this.properties[strName] = comProperty;
            }
            comProperty?.UpdateFuncDesc(funcdesc, index);
        }
예제 #7
0
        private void AddProperty(string strName, COM.FUNCDESC funcdesc, int index)
        {
            ComProperty prop;

            if (!_properties.TryGetValue(strName, out prop))
            {
                prop = new ComProperty(_typeinfo, strName);
                _properties[strName] = prop;
            }

            if (prop != null)
            {
                prop.UpdateFuncDesc(funcdesc, index);
            }
        }
예제 #8
0
 private void AddProperty(string strName, System.Runtime.InteropServices.ComTypes.FUNCDESC funcdesc, int index)
 {
     ComProperty property = null;
     if (this.properties.ContainsKey(strName))
     {
         property = this.properties[strName];
     }
     else
     {
         property = new ComProperty(this.typeinfo, strName);
         this.properties[strName] = property;
     }
     if (property != null)
     {
         property.UpdateFuncDesc(funcdesc, index);
     }
 }
예제 #9
0
        /// <summary>
        /// Sets the value of a property coming from a previous call to DoGetProperty
        /// </summary>
        /// <param name="property">PSProperty coming from a previous call to DoGetProperty</param>
        /// <param name="setValue">value to set the property with</param>
        ///  <param name="convertIfPossible">instructs the adapter to convert before setting, if the adapter supports conversion</param>
        protected override void PropertySet(PSProperty property, object setValue, bool convertIfPossible)
        {
            ComProperty prop = (ComProperty)property.adapterData;

            prop.SetValue(property.baseObject, setValue);
        }
예제 #10
0
        /// <summary>
        /// Returns the string representation of the property in the object
        /// </summary>
        /// <param name="property">property obtained in a previous GetMember</param>
        /// <returns>the string representation of the property in the object</returns>
        protected override string ParameterizedPropertyToString(PSParameterizedProperty property)
        {
            ComProperty prop = (ComProperty)property.adapterData;

            return(prop.ToString());
        }
예제 #11
0
        private void AddProperty(string strName, COM.FUNCDESC funcdesc, int index)
        {
            ComProperty prop;
            if (!_properties.TryGetValue(strName, out prop))
            {
                prop = new ComProperty(_typeinfo, strName);
                _properties[strName] = prop;
            }

            if (prop != null)
            {
                prop.UpdateFuncDesc(funcdesc, index);
            }
        }
예제 #12
0
        /// <summary>
        /// Called after a non null return from GetMember to get the property value
        /// </summary>
        /// <param name="property">the non empty return from GetMember</param>
        /// <param name="arguments">the arguments to use</param>
        /// <returns>the return value for the property</returns>
        protected override object ParameterizedPropertyGet(PSParameterizedProperty property, object[] arguments)
        {
            ComProperty prop = (ComProperty)property.adapterData;

            return(prop.GetValue(property.baseObject, arguments));
        }
예제 #13
0
        /// <summary>
        /// Called after a non null return from GetMember to set the property value
        /// </summary>
        /// <param name="property">the non empty return from GetMember</param>
        /// <param name="setValue">the value to set property with</param>
        /// <param name="arguments">the arguments to use</param>
        protected override void ParameterizedPropertySet(PSParameterizedProperty property, object setValue, object[] arguments)
        {
            ComProperty prop = (ComProperty)property.adapterData;

            prop.SetValue(property.baseObject, setValue, arguments);
        }
예제 #14
0
        /// <summary>
        /// Returns the name of the type corresponding to the property's value
        /// </summary>
        /// <param name="property">property obtained in a previous GetMember</param>
        /// <returns>the name of the type corresponding to the member</returns>
        protected override string ParameterizedPropertyType(PSParameterizedProperty property)
        {
            ComProperty prop = (ComProperty)property.adapterData;

            return(prop.Type.FullName);
        }
예제 #15
0
        /// <summary>
        /// Returns true if the property is gettable
        /// </summary>
        /// <param name="property">property to check</param>
        /// <returns>true if the property is gettable</returns>
        protected override bool ParameterizedPropertyIsGettable(PSParameterizedProperty property)
        {
            ComProperty prop = (ComProperty)property.adapterData;

            return(prop.IsGettable);
        }
예제 #16
0
        /// <summary>
        /// Returns the name of the type corresponding to the property
        /// </summary>
        /// <param name="property">PSProperty obtained in a previous DoGetProperty</param>
        /// <param name="forDisplay">True if the result is for display purposes only</param>
        /// <returns>the name of the type corresponding to the property</returns>
        protected override string PropertyType(PSProperty property, bool forDisplay)
        {
            ComProperty prop = (ComProperty)property.adapterData;

            return(forDisplay ? ToStringCodeMethods.Type(prop.Type) : prop.Type.FullName);
        }
예제 #17
0
        /// <summary>
        /// Returns true if the property is settable
        /// </summary>
        /// <param name="property">property to check</param>
        /// <returns>true if the property is settable</returns>
        protected override bool PropertyIsSettable(PSProperty property)
        {
            ComProperty prop = (ComProperty)property.adapterData;

            return(prop.IsSettable);
        }
예제 #18
0
        protected override bool PropertyIsGettable(PSProperty property)
        {
            ComProperty adapterData = (ComProperty)property.adapterData;

            return(adapterData.IsGettable);
        }
예제 #19
0
        /// <summary>
        /// Returns the value from a property coming from a previous call to DoGetProperty
        /// </summary>
        /// <param name="property">PSProperty coming from a previous call to DoGetProperty</param>
        /// <returns>The value of the property</returns>
        protected override object PropertyGet(PSProperty property)
        {
            ComProperty prop = (ComProperty)property.adapterData;

            return(prop.GetValue(property.baseObject));
        }
예제 #20
0
        protected override string PropertyToString(PSProperty property)
        {
            ComProperty adapterData = (ComProperty)property.adapterData;

            return(adapterData.ToString());
        }