コード例 #1
0
        /// <summary>
        /// Same as <see cref="TryCallCreateLoadInstance(string, object)"/> except it won't
        /// take care of IronPython objects
        /// </summary>
        /// <param name="type"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static object TryCallCreateLoadInstance(Type type, object parent)
        {
            MethodInfo method = TimelineSaver.SearchMethodWithAttr <CreateLoadInstanceAttribute>(type,
                                                                                                 BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

            return(method?.Invoke(null, new object[] { parent, type }));
        }
コード例 #2
0
 /// <summary>
 /// call the method marked with on done loading on the given object
 /// we use ref that way is objInstance is a struct it's still good
 /// </summary>
 /// <param name="objInstance"></param>
 public static void CallOnDoneLoading(ref object objInstance)
 {
     if (provider?.IsCustomCreated(objInstance) == true)
     {
         provider.CallOnDoneLoading(objInstance);
     }
     else
     {
         MethodInfo method = TimelineSaver.SearchMethodWithAttr <OnDoneLoadingAttribute>(objInstance.GetType(),
                                                                                         BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
         if (method != null)
         {
             method.Invoke(objInstance, null);
         }
     }
 }
コード例 #3
0
 private static void CallOnAllLoaded(ref object objInstance, JObject jobj)
 {
     if (provider?.IsCustomCreated(objInstance) == true)
     {
         provider.CallOnAllLoaded(objInstance, jobj);
     }
     else
     {
         MethodInfo method = TimelineSaver.SearchMethodWithAttr <OnAllLoadedAttribute>(objInstance.GetType(),
                                                                                       BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
         if (method != null)
         {
             method.Invoke(objInstance, new object[] { jobj });
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// call the method marked with CustomLoader on the object, if there is one
        /// otherwise return false
        /// </summary>
        /// <param name="objInstance"></param>
        /// <param name="jobj"></param>
        /// <returns></returns>
        private static bool TryCallCustomLoader(ref object objInstance, JObject jobj)
        {
            if (provider?.IsCustomCreated(objInstance) == true)
            {
                bool hasLoader = provider.HasCustomLoader(objInstance);
                if (hasLoader)
                {
                    provider.CallCustomLoader(objInstance, jobj);
                }

                return(hasLoader);
            }
            else
            {
                MethodInfo method = TimelineSaver.SearchMethodWithAttr <CustomLoaderAttribute>(objInstance.GetType(),
                                                                                               BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                if (method != null)
                {
                    method.Invoke(objInstance, new object[] { jobj });
                }

                return(method != null);
            }
        }