Beispiel #1
0
 public ClassTranslationInfo GetOrMakeTranslationInfo(Type type)
 {
     if ((object)type == null)
     {
         throw new ArgumentNullException(nameof(type));
     }
     if (ClassTranslations.TryGetValue(type, out var cti))
     {
         return(cti);
     }
     cti = ClassTranslations[type] = new ClassTranslationInfo(type, this);
     if (OnTranslationInfoCreated != null)
     {
         OnTranslationInfoCreated(this, new TranslationInfoCreatedEventArgs {
             ClassTranslation = cti
         });
     }
     return(cti);
 }
Beispiel #2
0
        public static MethodTranslationInfo FromMethodInfo(MethodBase methodInfo,
                                                           ClassTranslationInfo classTranslationInfo)
        {
            var result = new MethodTranslationInfo
            {
                ScriptName = methodInfo.Name,
                ClassTi    = classTranslationInfo
            };
            var scriptNameAttribute = methodInfo.GetCustomAttribute <PyNameAttribute>();

            if (scriptNameAttribute != null)
            {
                result.ScriptName = scriptNameAttribute.Name.Trim();
            }
            if (string.IsNullOrEmpty(result.ScriptName))
            {
                throw new Exception("Method name is empty");
            }
            return(result);
        }