Пример #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
        private void AddMethod(string strName, int index)
        {
            ComMethod method;

            if (!_methods.TryGetValue(strName, out method))
            {
                method            = new ComMethod(_typeinfo, strName);
                _methods[strName] = method;
            }

            if (method != null)
            {
                method.AddFuncDesc(index);
            }
        }
Пример #4
0
        private void AddMethod(string strName, int index)
        {
            ComMethod comMethod;

            if (this.methods.ContainsKey(strName))
            {
                comMethod = this.methods[strName];
            }
            else
            {
                comMethod             = new ComMethod(this.typeinfo, strName);
                this.methods[strName] = comMethod;
            }
            comMethod?.AddFuncDesc(index);
        }
Пример #5
0
 private void AddMethod(string strName, int index)
 {
     ComMethod method = null;
     if (this.methods.ContainsKey(strName))
     {
         method = this.methods[strName];
     }
     else
     {
         method = new ComMethod(this.typeinfo, strName);
         this.methods[strName] = method;
     }
     if (method != null)
     {
         method.AddFuncDesc(index);
     }
 }
Пример #6
0
        private void AddMethod(string strName, int index)
        {
            ComMethod method = null;

            if (this.methods.ContainsKey(strName))
            {
                method = this.methods[strName];
            }
            else
            {
                method = new ComMethod(this.typeinfo, strName);
                this.methods[strName] = method;
            }
            if (method != null)
            {
                method.AddFuncDesc(index);
            }
        }
Пример #7
0
        /// <summary>
        /// Called after a non null return from GetMethodData to return the overloads
        /// </summary>
        /// <param name="method">the return of GetMethodData</param>
        /// <returns></returns>
        protected override Collection <String> MethodDefinitions(PSMethod method)
        {
            ComMethod commethod = (ComMethod)method.adapterData;

            return(commethod.MethodDefinitions());
        }
Пример #8
0
        /// <summary>
        /// Called after a non null return from GetMethodData to try to call
        /// the method with the arguments
        /// </summary>
        /// <param name="method">the non empty return from GetMethods</param>
        /// <param name="arguments">the arguments to use</param>
        /// <returns>the return value for the method</returns>
        protected override object MethodInvoke(PSMethod method, object[] arguments)
        {
            ComMethod commethod = (ComMethod)method.adapterData;

            return(commethod.InvokeMethod(method, arguments));
        }
Пример #9
0
        protected override Collection <string> MethodDefinitions(PSMethod method)
        {
            ComMethod adapterData = (ComMethod)method.adapterData;

            return(adapterData.MethodDefinitions());
        }
Пример #10
0
        private void AddMethod(string strName, int index)
        {
            ComMethod method;
            if (!_methods.TryGetValue(strName, out method))
            {
                method = new ComMethod(_typeinfo, strName);
                _methods[strName] = method;
            }

            if (method != null)
            {
                method.AddFuncDesc(index);
            }
        }