public static bool _ <T>(this go.main_package.V target, out T result)
 {
     try
     {
         result = target._ <T>();
         return(true);
     }
     catch (PanicException)
     {
         result = default !;
 public static T _ <T>(this go.main_package.V target)
 {
     try
     {
         return(((go.main_package.V <T>)target).Target);
     }
     catch (NotImplementedException ex)
     {
         throw new PanicException($"interface conversion: {GetGoTypeName(target.GetType())} is not {GetGoTypeName(typeof(T))}: missing method {ex.InnerException?.Message}");
     }
 }
示例#3
0
 public static T TypeAssert <T>(this go.main_package.V target)
 {
     try
     {
         return(((go.main_package.V <T>)target).Target);
     }
     catch (NotImplementedException ex)
     {
         throw new PanicException($"panic: interface conversion: {target.GetType().FullName} is not {typeof(T).FullName}: missing method {ex.InnerException?.Message}");
     }
 }
示例#4
0
 public static bool TryTypeAssert(this go.main_package.V target, Type type, out object result)
 {
     try
     {
         result = target.TypeAssert(type);
         return(true);
     }
     catch (PanicException)
     {
         result = type.IsValueType ? Activator.CreateInstance(type) : null;
         return(false);
     }
 }
示例#5
0
 public static bool TryTypeAssert <T>(this go.main_package.V target, out T result)
 {
     try
     {
         result = target.TypeAssert <T>();
         return(true);
     }
     catch (PanicException)
     {
         result = default(T);
         return(false);
     }
 }
示例#6
0
        public static object TypeAssert(this go.main_package.V target, Type type)
        {
            try
            {
                MethodInfo conversionOperator = s_conversionOperators.GetOrAdd(type, _ => typeof(go.main_package.V <>).GetExplicitGenericConversionOperator(type));

                if ((object)conversionOperator == null)
                {
                    throw new PanicException($"panic: interface conversion: {target.GetType().FullName} is not {type.FullName}");
                }

                return(conversionOperator.Invoke(null, new object[] { target }));
            }
            catch (NotImplementedException ex)
            {
                throw new PanicException($"panic: interface conversion: {target.GetType().FullName} is not {type.FullName}: missing method {ex.InnerException?.Message}");
            }
        }