Пример #1
0
    public IntPtr GetMethodText( int method, MethodTextType type ){
      if (this.methods == null) return IntPtr.Zero;
      if (method < 0 || method >= GetOverloadCount()) return IntPtr.Zero;

      string result = null;

      //a type
      if ((type == MethodTextType.MTT_TYPEPREFIX && this.typePrefixed) ||
        (type == MethodTextType.MTT_TYPEPOSTFIX && !this.typePrefixed)) {

        string str = this.methods.GetType(method);
        if (str == null) return IntPtr.Zero;
    
        result = this.typeStart + str + this.typeEnd;        
      } else {

        //other
        switch (type) {
          case MethodTextType.MTT_OPENBRACKET:
            result = this.parStart;
            break;

          case MethodTextType.MTT_CLOSEBRACKET:
            result = this.parEnd;
            break;

          case MethodTextType.MTT_DELIMITER:
            result = this.parSep;
            break;

          case MethodTextType.MTT_NAME: {
            result = this.methods.GetName();
            break;
          }

          case MethodTextType.MTT_DESCRIPTION:
            /*
            {
              BSTR description = NULL;
              hr = m_methods->GetDescription( method, &description );
              if (FAILED(hr)) return NULL;
              return description;
            }
            */
          case MethodTextType.MTT_TYPEPREFIX:
          case MethodTextType.MTT_TYPEPOSTFIX:
          default:
            break;
        }
      }
      return result == null ? IntPtr.Zero : Marshal.StringToBSTR(result);
    }
Пример #2
0
 private static int IndexOfMethodTextType(MethodTextType methodTextType)
 {
     switch (methodTextType)
     {
         case MethodTextType.MTT_TYPEPREFIX:
         case MethodTextType.MTT_TYPEPOSTFIX:
             return 0;
         case MethodTextType.MTT_NAME: return 1;
         case MethodTextType.MTT_DESCRIPTION: return 2;
     }
     throw new ArgumentOutOfRangeException("methodTextType");
 }
Пример #3
0
 public IntPtr GetOrCreatePointerToNativeString(MethodTextType methodTextType, Func<string> factory)
 {
     return nativeStringsCache.GetOrCreateStringPointer(IndexOfMethodTextType(methodTextType), factory);
 }
Пример #4
0
 private int IndexOfCommonString(MethodTextType methodTextType)
 {
     switch(methodTextType)
     {
         case MethodTextType.MTT_OPENBRACKET: return 0;
         case MethodTextType.MTT_CLOSEBRACKET: return 1;
         case MethodTextType.MTT_DELIMITER: return 2;                    
     }
     throw new ArgumentOutOfRangeException("methodTextType");
 }
Пример #5
0
        public IntPtr GetMethodText(int method, MethodTextType type)
        {
            if (this.methods == null) return IntPtr.Zero;

            if (method < 0 || method >= GetOverloadCount()) return IntPtr.Zero;

            //a type
            if ((type == MethodTextType.MTT_TYPEPREFIX && this.methods.TypePrefixed) ||
                (type == MethodTextType.MTT_TYPEPOSTFIX && !this.methods.TypePrefixed))
            {
                var overload = nativeStringsCacheForOverloads.GetOverload(method);
                return overload.GetOrCreatePointerToNativeString(
                    MethodTextType.MTT_TYPEPREFIX,
                    () =>
                        {
                            string str = this.methods.GetType(method);
                            if (str == null) return null;
                            return this.methods.TypePrefix + str + this.methods.TypePostfix;
                        }
                    );
            }
            else
            {
                //other
                switch (type)
                {
                    case MethodTextType.MTT_OPENBRACKET:
                        return nativeStringsCacheForOverloads.GetOrCreateNativePointerForCommonString(MethodTextType.MTT_OPENBRACKET, () => methods.OpenBracket);

                    case MethodTextType.MTT_CLOSEBRACKET:
                        return nativeStringsCacheForOverloads.GetOrCreateNativePointerForCommonString(MethodTextType.MTT_CLOSEBRACKET, () => methods.CloseBracket);

                    case MethodTextType.MTT_DELIMITER:
                        return nativeStringsCacheForOverloads.GetOrCreateNativePointerForCommonString(MethodTextType.MTT_DELIMITER, () => methods.Delimiter);

                    case MethodTextType.MTT_NAME:
                        {
                            var overload = nativeStringsCacheForOverloads.GetOverload(method);
                            return overload.GetOrCreatePointerToNativeString(MethodTextType.MTT_NAME, () => methods.GetName(method));
                        }
                    case MethodTextType.MTT_DESCRIPTION:
                        {
                            var overload = nativeStringsCacheForOverloads.GetOverload(method);
                            return overload.GetOrCreatePointerToNativeString(MethodTextType.MTT_DESCRIPTION, () => methods.GetDescription(method));
                        }

                    case MethodTextType.MTT_TYPEPREFIX:
                    case MethodTextType.MTT_TYPEPOSTFIX:
                    default:
                        break;
                }
            }
            return IntPtr.Zero;
        }
Пример #6
0
        /// <include file='doc\Source.uex' path='docs/doc[@for="MethodData.GetMethodText"]/*' />
        public IntPtr GetMethodText(int method, MethodTextType type)
        {
            if (this.methods == null) return IntPtr.Zero;

            if (method < 0 || method >= GetOverloadCount()) return IntPtr.Zero;

            string result = null;

            //a type
            if ((type == MethodTextType.MTT_TYPEPREFIX && this.methods.TypePrefixed) ||
                (type == MethodTextType.MTT_TYPEPOSTFIX && !this.methods.TypePrefixed)) {
                string str = this.methods.GetType(method);

                if (str == null) return IntPtr.Zero;

                result = this.methods.TypePrefix + str + this.methods.TypePostfix;
            } else {
                //other
                switch (type) {
                case MethodTextType.MTT_OPENBRACKET:
                result = this.methods.OpenBracket;
                break;

                case MethodTextType.MTT_CLOSEBRACKET:
                result = this.methods.CloseBracket;
                break;

                case MethodTextType.MTT_DELIMITER:
                result = this.methods.Delimiter;
                break;

                case MethodTextType.MTT_NAME:
                result = this.methods.GetName(method);
                break;

                case MethodTextType.MTT_DESCRIPTION:
                result = this.methods.GetDescription(method);
                break;

                case MethodTextType.MTT_TYPEPREFIX:
                case MethodTextType.MTT_TYPEPOSTFIX:
                default:
                break;
                }
            }

            return result == null ? IntPtr.Zero : Marshal.StringToBSTR(result);
        }