static void Main(string[] args)
        {
            var isBatch = args[0] == "-batch";

            if (!(args.Length == 1 && File.Exists(args[0]) || args.Length == 3 && args[1] == "-out" && File.Exists(args[0]) || args.Length == 2 && isBatch && File.Exists(args[1])))
            {
                Console.WriteLine("Usage: RhinoMocksToMoqConsole <filepath> [-out file]");
                Console.WriteLine("Usage: RhinoMocksToMoqConsole -batch filepath-containing-list-of-files]");
                Environment.Exit(1);
            }

            var outFilename    = !isBatch ? args [2] : null;
            var writeToConsole = args.Length == 1;
            var paths          = args[0] == "-batch" ? File.ReadAllLines(args[1]).Where(x => !string.IsNullOrWhiteSpace(x) && x [0] != '#').ToList() : new List <string> {
                args[0]
            };

            paths.ForEach(filename =>
            {
                var sourceCode    = File.ReadAllText(filename);
                var newSourceCode = ClassConverter.Convert(sourceCode);

                if (writeToConsole)
                {
                    Console.WriteLine(newSourceCode);
                }
                else
                {
                    Console.WriteLine(filename);
                    var resultFilename = outFilename ?? filename;
                    File.WriteAllText(resultFilename, newSourceCode);
                }
            });
        }
Exemple #2
0
        public static async Task <dynamic> MakeEntityApiCall(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, ILogger log)
        {
            /* Create the function execution's context through the request */
            var context = await FunctionContext <dynamic> .Create(req);

            var args = context.FunctionArgument;

            var entityProfile = context.CallerEntityProfile;

            var setObjectRequest = new SetObjectsRequest
            {
                Entity  = ClassConverter <ProfilesModels.EntityKey, DataModels.EntityKey> .Convert(entityProfile.Entity),
                Objects = new List <SetObject>
                {
                    new SetObject
                    {
                        ObjectName = "obj1",
                        DataObject = new
                        {
                            foo   = "some server computed value",
                            prop1 = args["prop1"]
                        }
                    }
                }
            };

            /* Use the ApiSettings and AuthenticationContext provided to the function as context for making API calls. */
            var dataApi = new PlayFabDataInstanceAPI(context.ApiSettings, context.AuthenticationContext);
            /* Execute the entity API request */
            var setObjectsResponse = await dataApi.SetObjectsAsync(setObjectRequest);

            var setObjectsResult = setObjectsResponse.Result.SetResults[0].SetResult;

            return(new
            {
                profile = entityProfile,
                setResult = setObjectsResult
            });
        }