Example #1
0
        public WWW Initialize(InitializeDelegate callback)
        {
            if (CallbackManager.NetmarbleGameObject == null)
            {
                return(null);
            }

            string gmc2Url = GMC2;

            string[] versionArray = Configuration.GetUnityPluginVersion().Split('.');
            string   version      = versionArray[0] + "." + versionArray[1];

            WWWForm wwwForm = new WWWForm();

            wwwForm.AddField("localeCode", LOCALE);
            wwwForm.AddField("serviceCode", SERVICE_CODE);
            wwwForm.AddField("gameCode", Configuration.GetGameCode());
            wwwForm.AddField("version", version);
            wwwForm.AddField("zone", Configuration.GetZone());
            //      wwwForm.AddField("checksum", checksum);


            wwwForm.headers["Content-Type"] = "application/octet-stream";

            WWW www = new WWW(gmc2Url, wwwForm);

            CallbackManager.NetmarbleGameObject.StartCoroutine(WaitForInitialize(www, callback));
            return(www);
        }
        public NavigationPresenter(INavigationView view,
                                   ISettingsSerializer settingsSerializer,
                                   IKeyboardListener keyboardListener,
                                   IMatchModelMapper matchModelMapper,
                                   IPresentationService presentationService,
                                   INavigationServiceBuilder navigationServiceBuilder)
        {
            _view = view;
            _settingsSerializer       = settingsSerializer;
            _keyboardListener         = keyboardListener;
            _matchModelMapper         = matchModelMapper;
            _navigationServiceBuilder = navigationServiceBuilder;
            _presentationService      = presentationService;

            Settings settings = _settingsSerializer.Deserialize();

            _keyboardListener.KeyCombinationPressed += GlobalKeyCombinationPressed;
            _keyboardListener.StartListening(settings.GlobalKeyCombination);

            _view.CurrentSettings = settings;
            _view.ShowMatches(new List <MatchModel> {
                new MatchModel(_matchModelMapper, Resources.InitialMatchesMessage)
            });
            _view.ShowInitializingScreen = true;

            //Initialize navigation service asynchronously, as it may require a long operation (file system parsing).
            //Clone settings to avoid any coupling
            Settings           settingsCopy = settings.Clone() as Settings;
            InitializeDelegate initialize   = Initialize;

            initialize.BeginInvoke(settingsCopy, EndInitialize, initialize);
        }
        private bool PopulateItem(TData item,
                                  int index,
                                  FilterDelegate filter,
                                  InitializeDelegate initializer,
                                  InstantiateDelegate instantiator
                                  )
        {
            if (filter != null && !filter(item))
            {
                return(false);
            }

            TComponent component;

            if (index < this.pool.Count)
            {
                component = this.pool[index];
            }
            else
            {
                component = instantiator != null
                    ? instantiator(this.prefab, this.root)
                    : Object.Instantiate(this.prefab, this.root);

                this.pool.Add(component);
            }

            component.gameObject.SetActive(true);
            initializer?.Invoke(item, component);

            return(true);
        }
Example #4
0
        public FormOrder(Blotter blotter)
        {
            // This will initialize the IDE maintained components.
            InitializeComponent();

            this.blotter = blotter;

            // This event is used to hold up the background initialization of the form until a window handle has been created.  If
            // the background thread doesn't wait for this signal, it can cause an exception when trying to pass information to the
            // foreground using the 'Invoke' commands.
            this.handleCreatedEvent = new ManualResetEvent(false);

            // Delegates for handling Windows thread actions from the background.
            this.initializeDelegate = new InitializeDelegate(InitializeDialog);
            this.postEndDelegate    = new PostEndDelegate(PostEnd);

#if DEBUG
            // This will prevent the background initialization thread from running in the designer (background threads kill the designer.
            if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
            {
#endif

            // The remaining part of the initialization must be done from a background thread.
            ThreadPool.QueueUserWorkItem(new WaitCallback(InitializationThread));

#if DEBUG
        }
#endif
        }
Example #5
0
        internal PRemoteComponent(object wrapped)
        {
            this.wrapped = wrapped ?? throw new ArgumentNullException(nameof(wrapped));
            if (!PPatchTools.TryGetPropertyValue(wrapped, nameof(Version), out Version
                                                 version))
            {
                throw new ArgumentException("Remote component missing Version property");
            }
            this.version = version;
            // Initialize
            var type = wrapped.GetType();

            doInitialize = type.CreateDelegate <InitializeDelegate>(nameof(PForwardedComponent.
                                                                           Initialize), wrapped, typeof(Harmony));
            if (doInitialize == null)
            {
                throw new ArgumentException("Remote component missing Initialize");
            }
            // Bootstrap
            doBootstrap = type.CreateDelegate <InitializeDelegate>(nameof(PForwardedComponent.
                                                                          Bootstrap), wrapped, typeof(Harmony));
            doPostInitialize = type.CreateDelegate <InitializeDelegate>(nameof(
                                                                            PForwardedComponent.PostInitialize), wrapped, typeof(Harmony));
            getData = type.CreateGetDelegate <object>(nameof(InstanceData), wrapped);
            setData = type.CreateSetDelegate <object>(nameof(InstanceData), wrapped);
            process = type.CreateDelegate <ProcessDelegate>(nameof(PForwardedComponent.
                                                                   Process), wrapped, typeof(uint), typeof(object));
        }
Example #6
0
 /// <summary>
 /// The default Constructor.
 /// </summary>
 public InitializeProcess(InitializeDelegate initializeDelegate, string processDescription,
                          TimeSpan timeToWaitBeforeRunningProcess, CheckCompleteDelegate checkCompleteCallback)
 {
     _initializeDelegate             = initializeDelegate;
     _processDescription             = processDescription;
     _timeToWaitBeforeRunningProcess = timeToWaitBeforeRunningProcess;
     _checkCompleteCallback          = checkCompleteCallback;
 }
Example #7
0
        private void ProcessData(string jsonString, InitializeDelegate callback)
        {
            Debug.Log("GMC2Service : " + jsonString);
            JsonData jsonData = JsonMapper.ToObject(jsonString);

            int resCode = (int)jsonData["resCode"];

            if (resCode == 0)
            {
                string countryCode = (string)jsonData["geoLocation"];
                if (countryCode != null)
                {
                    NMGPlayerPrefs.SetCountryCode(countryCode);
                }

                string clientIp = (string)jsonData["clientIp"];
                if (clientIp != null)
                {
                    NMGPlayerPrefs.SetIPAddress(clientIp);
                }

                constantDic = new Dictionary <string, string>();
                for (int i = 0; i < jsonData["result"].Count; i++)
                {
                    string keyStr   = jsonData["result"][i]["key"].ToString();
                    string valueStr = jsonData["result"][i]["value"].ToString();

                    constantDic.Add(keyStr, valueStr);
                }

                if (callback != null && callback is InitializeDelegate)
                {
                    Result result = new Result(Result.NETMARBLES_DOMAIN, Result.SUCCESS, "Success");
                    Log.Debug("[NMGPlayMode.GMC2Service] Initialize OK (" + result + ")");

                    InitTalkKit();

                    callback(result);
                }
            }
            else
            {
                if (callback != null && callback is InitializeDelegate)
                {
                    Result result = new Result(Result.NETMARBLES_DOMAIN, Result.SERVICE, jsonString);
                    Log.Debug("[NMGPlayMode.GMC2Service] Initialize Fail (" + result + ")");
                    callback(result);
                }
            }
        }
Example #8
0
        private static bool GetProcs()
        {
            // Check if this is a 32 bit application
            if (IntPtr.Size != 4)
            {
#if DEBUG
                Console.WriteLine("Only 32 bit applications are supported.");
#endif

                return(false);
            }

            // Check if the nvapi.dll is available
            if (LoadLibrary("nvapi.dll") == IntPtr.Zero)
            {
#if DEBUG
                Console.WriteLine("The nvapi.dll could not be found.");
#endif

                return(false);
            }

            try
            {
                CreateApplication = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x4347A9DE), typeof(CreateApplicationDelegate)) as CreateApplicationDelegate;
                CreateProfile     = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xCC176068), typeof(CreateProfileDelegate)) as CreateProfileDelegate;
                CreateSession     = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x0694D52E), typeof(CreateSessionDelegate)) as CreateSessionDelegate;
                DeleteProfile     = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x17093206), typeof(DeleteProfileDelegate)) as DeleteProfileDelegate;
                DestroySession    = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xDAD9CFF8), typeof(DestroySessionDelegate)) as DestroySessionDelegate;
                EnumApplications  = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x7FA2173A), typeof(EnumApplicationsDelegate)) as EnumApplicationsDelegate;
                FindProfileByName = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x7E4A9A0B), typeof(FindProfileByNameDelegate)) as FindProfileByNameDelegate;
                GetProfileInfo    = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x61CD6FD6), typeof(GetProfileInfoDelegate)) as GetProfileInfoDelegate;
                Initialize        = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x0150E828), typeof(InitializeDelegate)) as InitializeDelegate;
                LoadSettings      = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x375DBD6B), typeof(LoadSettingsDelegate)) as LoadSettingsDelegate;
                SaveSettings      = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xFCBC7E14), typeof(SaveSettingsDelegate)) as SaveSettingsDelegate;
                SetSetting        = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x577DD202), typeof(SetSettingDelegate)) as SetSettingDelegate;
            }
            catch (Exception)
            {
#if DEBUG
                Console.WriteLine("The procs of nvapi.dll could not be retrieved.");
#endif

                return(false);
            }

            return(true);
        }
Example #9
0
        private IEnumerator WaitForInitialize(WWW www, InitializeDelegate callback)
        {
            yield return(www);

            if (www.error == null)
            {
                ProcessData(www.text, callback);
            }
            else
            {
                if (callback != null && callback is InitializeDelegate)
                {
                    Result result = new Result(Result.NETMARBLES_DOMAIN, Result.SERVICE, www.error);
                    Log.Debug("[NMGPlayMode.GMC2Service] Initialize Fail (" + result + ")");
                    callback(result);
                }
            }
        }
        private void EndInitialize(IAsyncResult asyncResult)
        {
            InitializeDelegate initializeDelegate  = (InitializeDelegate)asyncResult.AsyncState;
            INavigationService navigationAssistant = initializeDelegate.EndInvoke(asyncResult);

            lock (_syncObject)
            {
                if (_disposed)
                {
                    navigationAssistant.Dispose();
                    return;
                }

                _navigationAssistant = navigationAssistant;
                _navigationServiceBuilder.UpdateNavigationSettings(_navigationAssistant, _view.CurrentSettings);

                _view.ShowInitializingScreen = false;
                _view.TextChanged           += HandleTextChanged;
                _view.FolderSelected        += HandleFolderSelected;
            }
        }
        public void Refresh(
            IEnumerable <TData> source,
            FilterDelegate filter            = null,
            InitializeDelegate initializer   = null,
            InstantiateDelegate instantiator = null
            )
        {
            var index = 0;

            if (source is IReadOnlyList <TData> sourceList)
            {
                for (var i = 0; i < sourceList.Count; i += 1)
                {
                    if (this.PopulateItem(sourceList[i], index, filter, initializer, instantiator))
                    {
                        index += 1;
                    }
                }
            }
            else
            {
                foreach (var item in source)
                {
                    if (this.PopulateItem(item, index, filter, initializer, instantiator))
                    {
                        index += 1;
                    }
                }
            }

            while (index < this.pool.Count)
            {
                this.pool[index].gameObject.SetActive(false);
                index += 1;
            }
        }
Example #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="game"></param>
 public PostProcess(XnaGame game, InitializeDelegate initializer)
 {
     this._game       = game;
     this.Initializer = initializer;
 }
Example #13
0
 public static void SetInitializeDelegate(InitializeDelegate initializeDelegate)
 {
     Yodo1U3dMasCallback.SetInitializeDelegate(initializeDelegate);
 }
Example #14
0
 /// <summary>
 /// The default Constructor.
 /// </summary>
 public InitializeProcess(InitializeDelegate initializeDelegate, string processDescription)
     : this(initializeDelegate, processDescription, TimeSpan.Zero, null)
 {
 }
Example #15
0
 /// <summary>
 /// The default Constructor.
 /// </summary>
 public InitializeProcess(InitializeDelegate initializeDelegate, string processDescription,
                          TimeSpan timeToWaitBeforeRunningProcess)
     : this(initializeDelegate, processDescription, timeToWaitBeforeRunningProcess, null)
 {
 }
 public static LanguageServerOptions OnInitialize(this LanguageServerOptions options, InitializeDelegate @delegate)
 {
     options.InitializeDelegates.Add(@delegate);
     return(options);
 }
Example #17
0
        public void RetrieveInitializedDelegate(BaseState in_state)
        {
            in_state.OnInitializeDelegate += OnInitializeDelegate;

            OnInitializeDelegate = null;
        }
 public LanguageServer OnInitialize(InitializeDelegate @delegate)
 {
     _initializeDelegates.Add(@delegate);
     return(this);
 }
Example #19
0
        /// <summary>
        /// Binds the class instance methods to the dll functions.
        /// </summary>
        /// <param name="hDll">A dll to bind to.</param>
        private void BindToDll(IntPtr hDll)
        {
            IntPtr pProcPtr = GetProcAddress(hDll, "Initialize");
            _initialize =
                (InitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(InitializeDelegate));

            pProcPtr = GetProcAddress(hDll, "StartPlay");
            _startPlayDelegate =
                (StartPlayDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartPlayDelegate));

            pProcPtr = GetProcAddress(hDll, "StartPlayPiP");
            _startPlayPiPDelegate =
                (StartPlayPiPDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartPlayPiPDelegate));

            pProcPtr = GetProcAddress(hDll, "GetCurrentFrame");
            _getCurrentFrame =
                (GetCurrentFrameDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(GetCurrentFrameDelegate));

            pProcPtr = GetProcAddress(hDll, "GetFrameSize");
            _getFrameSize =
                (GetFrameSizeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(GetFrameSizeDelegate));

            pProcPtr = GetProcAddress(hDll, "SetupPiP");
            _setupPiP =
                (SetupPiPDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(SetupPiPDelegate));

            pProcPtr = GetProcAddress(hDll, "SetupZoom");
            _setupZoom =
                (SetupZoomDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(SetupZoomDelegate));

            pProcPtr = GetProcAddress(hDll, "SetupCross");
            _setupCross =
                (SetupCrossDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(SetupCrossDelegate));

            pProcPtr = GetProcAddress(hDll, "Stop");
            _stop =
                (StopDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StopDelegate));

            pProcPtr = GetProcAddress(hDll, "Uninitialize");
            _uninitialize = (UninitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(UninitializeDelegate));
        }
Example #20
0
        /// <summary>
        /// Binds the class instance methods to the dll functions.
        /// </summary>
        /// <param name="hDll">A dll to bind to.</param>
        private void BindToDll(IntPtr hDll)
        {
            IntPtr pProcPtr = GetProcAddress(hDll, "Initialize");
            _initialize =
                (InitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(InitializeDelegate));

            //pProcPtr = GetProcAddress(hDll, "Open");
            //_open =
            //    (OpenDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(OpenDelegate));

            pProcPtr = GetProcAddress(hDll, "StartPlay");
            _startPlayDelegate =
                (StartPlayDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartPlayDelegate));

            pProcPtr = GetProcAddress(hDll, "GetCurrentFrame");
            _getCurrentFrame =
                (GetCurrentFrameDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(GetCurrentFrameDelegate));

            pProcPtr = GetProcAddress(hDll, "GetFrameSize");
            _getFrameSize =
                (GetFrameSizeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr,
                typeof(GetFrameSizeDelegate));

            pProcPtr = GetProcAddress(hDll, "Stop");
            _stop =
                (StopDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StopDelegate));

            pProcPtr = GetProcAddress(hDll, "Uninitialize");
            _uninitialize = (UninitializeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(UninitializeDelegate));
        }
Example #21
0
 public TestHelperExtension(InitializeDelegate initialize)
 {
     this.initialize = initialize;
 }
        /// <summary>
        /// Important method that wires and connects all the classes and interfaces together to run the application.
        /// If object A (this) has a private field of an interface, and object B implements the interface, then wire them together. Returns this for fluent style programming.
        /// ------------------------------------------------------------------------------------------------------------------
        /// WireTo methods five important keys:
        /// 1. wires match interfaces, A (calls interface) and B (implements)
        /// 2. interfaces must be all private for matching to happen
        /// 3. can wire multiple matching interfaces
        /// 4. wires in order form top to bottom of not yet wired
        /// 5. can ovveride order by specifying port names as second parameter
        /// 6. looks for list as well (be careful of blocking other interfaces from wiring)
        /// ------------------------------------------------------------------------------------------------------------------
        /// </summary>
        /// <param name="A">
        /// The object on which the method is called is the object being wired from
        /// </param>
        /// <param name="B">The object being wired to (must implement the interface)</param>
        /// <returns></returns>
        /// <remarks>
        /// If A has two private fields of the same interface, the first compatible B object wired goes to the first one and the second compatible B object wired goes to the second.
        /// If A has multiple private interfaces of different types, only the first matching interface that B implements will be wired.
        /// In other words, by default, only one interface is wired between A and B
        /// To override this behaviour you can get give multiple interfaces in A a prefix "Pn_" where n is 0..9:
        /// Then a single wiring operation will wire all fieldnames with a consistent port prefix to the same B.
        /// These remarks apply only to single fields, not Lists.
        /// e.g.
        /// private IOneable client1Onabale;
        /// private ITwoable client1Twoable;
        /// private IThreeable client2;
        /// Clearly we want to wire two different clients. But if the first client wired implements all three interfaces, it will be wired to all three fields.
        /// So name the field like this:
        /// private IOneable P1_clientOnabale;
        /// private ITwoable P1_clientTwoable;
        /// private IThreeable P2_client;
        /// </remarks>
        public static T WireTo <T>(this T A, object B, string APortName = null, bool reverse = false)
        {
            string multiportExceptionMessage = $"The following wiring failed because the two instances are already wired together by another port.";

            multiportExceptionMessage += "\nPlease use a new WireTo with this additional port name specified:";

            if (A == null)
            {
                throw new ArgumentException("A cannot be null");
            }
            if (B == null)
            {
                throw new ArgumentException("B cannot be null");
            }

            // achieve the following via reflection
            // A.field = (<type of interface>)B;
            // A.list.Add( (<type of interface>)B );

            // Get the two instance name first for the Debug Output WriteLines
            var AinstanceName = A.GetType().GetProperties().FirstOrDefault(f => f.Name == "instanceName")?.GetValue(A);

            if (AinstanceName == null)
            {
                AinstanceName = A.GetType().GetFields().FirstOrDefault(f => f.Name == "instanceName")?.GetValue(A);
            }
            var BinstanceName = B.GetType().GetProperties().FirstOrDefault(f => f.Name == "instanceName")?.GetValue(B);

            if (BinstanceName == null)
            {
                BinstanceName = B.GetType().GetFields().FirstOrDefault(f => f.Name == "instanceName")?.GetValue(B);
            }


            var BType       = B.GetType();
            var AfieldInfos = A.GetType().GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
                              .Where(f => (APortName == null || f.Name == APortName) && (!reverse ^ EndsIn_B(f.Name))).ToList(); // find the fields that the name meets all criteria
                                                                                                                                 // TODO: when not reverse ports ending in _B should be excluded

            //if (A.GetType().Name=="DragDrop" && AinstanceName=="Initial Tag")
            //{ // for breakpoint
            //}
            var wiredSomething = false;

            firstPortName = null;
            foreach (var BimplementedInterface in BType.GetInterfaces())                                                         // consider every interface implemented by B
            {
                var AfieldInfo = AfieldInfos.FirstOrDefault(f => f.FieldType == BimplementedInterface && f.GetValue(A) == null); // find the first field in A that matches the interface type of B
                                                                                                                                 // TODO: the list case below should have the SamePort constraint as well

                // look for normal private fields first
                if (AfieldInfo != null)  // there is a match
                {
                    if (SamePort(AfieldInfo.Name))
                    {
                        if (wiredSomething)
                        {
                            throw new Exception(multiportExceptionMessage);
                        }

                        AfieldInfo.SetValue(A, B);  // do the wiring
                        wiredSomething = true;
                    }
                    continue;  // could be more than one interface to wire
                }

                // do the same as above for private fields that are a list of the interface of the matching type
                foreach (var AlistFieldInfo in AfieldInfos)
                {
                    if (!AlistFieldInfo.FieldType.IsGenericType) //not matching interface
                    {
                        continue;
                    }
                    var AListFieldValue = AlistFieldInfo.GetValue(A);

                    var AListGenericArguments = AlistFieldInfo.FieldType.GetGenericArguments();
                    if (AListGenericArguments.Length != 1)
                    {
                        continue;                                                         // A list should only have one type anyway
                    }
                    if (AListGenericArguments[0].IsAssignableFrom(BimplementedInterface)) // JRS: There was some case where == didn't work, maybe in the gamescoring application
                    {
                        if (AListGenericArguments[0] != BimplementedInterface)
                        {
                            var g = AListGenericArguments[0];
                            //if (g != typeof(object)) throw new Exception($"Different types {g} {AListGenericArguments[0]} {typeof(object)}");
                            continue;
                        }
                        if (AListFieldValue == null)
                        {
                            var    listType  = typeof(List <>);
                            Type[] listParam = { BimplementedInterface };
                            AListFieldValue = Activator.CreateInstance(listType.MakeGenericType(listParam));
                            if (wiredSomething)
                            {
                                throw new Exception(multiportExceptionMessage);
                            }

                            AlistFieldInfo.SetValue(A, AListFieldValue);
                        }

                        AListFieldValue.GetType().GetMethod("Add").Invoke(AListFieldValue, new[] { B });
                        wiredSomething = true;
                        break;
                    }
                }
            }

            if (!reverse && !wiredSomething)
            {
                if (APortName != null)
                {
                    // a specific port was specified so see if the port was already wired
                    var AfieldInfo = AfieldInfos.FirstOrDefault();
                    if (AfieldInfo?.GetValue(A) != null)
                    {
                        throw new Exception($"Port already wired {A.GetType().Name}[{AinstanceName}].{APortName} to {BType.Name}[{BinstanceName}]");
                    }
                }
                //throw new Exception($"Failed to wire {A.GetType().Name}[{AinstanceName}].{APortName} to {BType.Name}[{BinstanceName}]");
            }

            var method = A.GetType().GetMethod("PostWiringInitialize", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            if (method != null)
            {
                InitializeDelegate handler = (InitializeDelegate)Delegate.CreateDelegate(typeof(InitializeDelegate), A, method);
                Initialize -= handler;  // instances can be wired to/from more than once, so only register their PostWiringInitialize once
                Initialize += handler;
            }

            /*
             * method = B.GetType().GetMethod("PostWiringInitialize", System.Reflection.BindingFlags.NonPublic);
             * if (method != null)
             * {
             *  InitializeDelegate handler = (InitializeDelegate)Delegate.CreateDelegate(typeof(InitializeDelegate), B, method);
             *  Initialize += handler;
             * }
             */
            return(A);
        }
Example #23
0
File: SOP.cs Project: callym/drip3d
        private static bool GetProcs()
        {
            // Check if this is a 32 bit application
            if (IntPtr.Size != 4)
            {
            #if DEBUG
                Console.WriteLine("Only 32 bit applications are supported.");
            #endif

                return false;
            }

            // Check if the nvapi.dll is available
            if (LoadLibrary("nvapi.dll") == IntPtr.Zero)
            {
            #if DEBUG
                Console.WriteLine("The nvapi.dll could not be found.");
            #endif

                return false;
            }

            try
            {
                CreateApplication = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x4347A9DE), typeof(CreateApplicationDelegate)) as CreateApplicationDelegate;
                CreateProfile = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xCC176068), typeof(CreateProfileDelegate)) as CreateProfileDelegate;
                CreateSession = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x0694D52E), typeof(CreateSessionDelegate)) as CreateSessionDelegate;
                DeleteProfile = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x17093206), typeof(DeleteProfileDelegate)) as DeleteProfileDelegate;
                DestroySession = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xDAD9CFF8), typeof(DestroySessionDelegate)) as DestroySessionDelegate;
                EnumApplications = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x7FA2173A), typeof(EnumApplicationsDelegate)) as EnumApplicationsDelegate;
                FindProfileByName = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x7E4A9A0B), typeof(FindProfileByNameDelegate)) as FindProfileByNameDelegate;
                GetProfileInfo = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x61CD6FD6), typeof(GetProfileInfoDelegate)) as GetProfileInfoDelegate;
                Initialize = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x0150E828), typeof(InitializeDelegate)) as InitializeDelegate;
                LoadSettings = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x375DBD6B), typeof(LoadSettingsDelegate)) as LoadSettingsDelegate;
                SaveSettings = Marshal.GetDelegateForFunctionPointer(QueryInterface(0xFCBC7E14), typeof(SaveSettingsDelegate)) as SaveSettingsDelegate;
                SetSetting = Marshal.GetDelegateForFunctionPointer(QueryInterface(0x577DD202), typeof(SetSettingDelegate)) as SetSettingDelegate;
            }
            catch (Exception)
            {
            #if DEBUG
                Console.WriteLine("The procs of nvapi.dll could not be retrieved.");
            #endif

                return false;
            }

            return true;
        }