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); } }
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)); }
protected override Collection <string> ParameterizedPropertyDefinitions(PSParameterizedProperty property) { ComProperty adapterData = (ComProperty)property.adapterData; return(new Collection <string> { adapterData.GetDefinition() }); }
/// <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); }
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)); }
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); }
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); } }
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); } }
/// <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); }
/// <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()); }
/// <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)); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
protected override bool PropertyIsGettable(PSProperty property) { ComProperty adapterData = (ComProperty)property.adapterData; return(adapterData.IsGettable); }
/// <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)); }
protected override string PropertyToString(PSProperty property) { ComProperty adapterData = (ComProperty)property.adapterData; return(adapterData.ToString()); }