Exemplo n.º 1
0
        /// <summary>
        /// Make a call to a private API method.
        /// </summary>
        /// <param name="method">The method to call on the Kraken API</param>
        /// <param name="request">A request, containing the POST parameters. Authentication headers
        /// will be added to this.</param>
        /// <returns>The JSON data object returned from Kraken</returns>
        private async Task <T> CallPrivate <T>(PrivateMethod method, FormUrlEncodedContent request)
            where T : JToken
        {
            string url = this.privateUrl + Enum.GetName(typeof(PrivateMethod), method);

            request.Headers.Add(this.SignHeader, GenerateSHA512Signature(request));
            request.Headers.Add(this.KeyHeader, this.PublicKey);

            try
            {
                JObject             resultJson;
                HttpResponseMessage result = await client.PostAsync(url, request);

                using (Stream jsonStream = await result.Content.ReadAsStreamAsync())
                {
                    using (StreamReader jsonStreamReader = new StreamReader(jsonStream))
                    {
                        using (JsonReader jsonReader = new JsonTextReader(jsonStreamReader))
                        {
                            JsonSerializer serializer = new JsonSerializer();

                            resultJson = serializer.Deserialize <JObject>(jsonReader);
                        }
                    }
                }

                AssertResponseIsSuccess(resultJson);

                return(resultJson.Value <T>("data"));
            }
            catch (ArgumentException e)
            {
                throw new KrakenResponseException("Could not parse response from Kraken.", e);
            }
        }
Exemplo n.º 2
0
        public static void projectWindowForTarget(Object target)
        {
            // Get a reference to the `InspectorWindow` type object
            var windowType     = typeof(UnityEditor.Editor).Assembly.GetType("UnityEditor.ProjectBrowser");
            var windowInstance = ScriptableObject.CreateInstance(windowType) as EditorWindow;

            Debug.Assert(windowInstance != null, nameof(windowInstance) + " != null");
            windowInstance.Show();
            PrivateMethod.obtain(windowType, "Init")(windowInstance);

            var getInstanceIDFromGUID = PrivateMethod.obtainStaticFn <string, int>(
                typeof(AssetDatabase), "GetInstanceIDFromGUID"
                );

            var setFolderSelection = PrivateMethod.obtain <int[], bool>(windowType, "SetFolderSelection");

            setFolderSelection(
                windowInstance,
                new[] { getInstanceIDFromGUID(
                            AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(Selection.activeObject))
                            ) },
                true
                );
            var isLockedFieldAccessor = PrivateField.accessor <bool>(windowType, "m_IsLocked");
            var isLockedField         = isLockedFieldAccessor(windowInstance);

            isLockedField.value = true;
        }
Exemplo n.º 3
0
        public void FindMethod_PrivateBase()
        {
            var obj    = new PrivateMethod();
            var method = Csla.Reflection.ServiceProviderMethodCaller.FindDataPortalMethod <ExecuteAttribute>(obj, null);

            Assert.IsNotNull(method);
            Assert.AreEqual("Execute", method.MethodInfo.Name, "Method name should match");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Make a call to a private API method.
        /// </summary>
        /// <param name="method">The method to call on the Kraken API</param>
        /// <returns>Parsed JSON returned from Kraken</returns>
        private async Task <T> CallPrivate <T>(PrivateMethod method)
            where T : JToken
        {
            FormUrlEncodedContent request = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>(PARAMETER_NONCE, this.GetNextNonce())
            });

            return(await CallPrivate <T>(method, request));
        }
Exemplo n.º 5
0
 public void LoadUiImmediate()
 {
     if (!IsUiLoaded)
     {
         IsUiLoaded = true;
         try {
             this.ImgMain.Source = PrivateMethod.GetImage(FileSrc);
         } catch { }
     }
 }
Exemplo n.º 6
0
    static void Main(string[] args)
    {
        Program myProgram = new Program();

        myProgram.iAmPrivate("private");
        myProgram.iAmPublic("public");
        PrivateMethod pm = new PrivateMethod();

        Console.WriteLine("this will now run {0}", pm.pretendMain());     //now possible !
        //Console.WriteLine("this won't run {0}", pm.myPrivateMethod);  //not possible
        Console.WriteLine("press [enter] to exit");
        Console.ReadLine();
    }
Exemplo n.º 7
0
        /// <summary>
        /// Make a call to a private API method.
        /// </summary>
        /// <param name="method">The method to call on the Kraken API</param>
        /// <returns>Parsed JSON returned from Kraken</returns>
        private async Task <T> CallPrivate <T>(PrivateMethod method, Dictionary <string, string> parameterDictionary)
            where T : JToken
        {
            List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();

            foreach (string parameterName in parameterDictionary.Keys)
            {
                parameters.Add(new KeyValuePair <string, string>(parameterName, parameterDictionary[parameterName]));
            }

            FormUrlEncodedContent request = new FormUrlEncodedContent(parameters);

            return(await CallPrivate <T>(method, request));
        }
Exemplo n.º 8
0
    public int pretendMain()
    {
        PrivateMethod x = new PrivateMethod();

        return(x.myPrivateMethod());
    }