示例#1
0
        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);
                }
            });
        }
        public ActionResult <CarWashVisitDataModel> GetDetails()
        {
            CarWashVisitDatabase  carWashVisitDatabase  = new CarWashVisitDatabase(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CarWashVisit_DatabaseNew.db3"));
            CarWashVisitDataModel carWashVisitDataModel = new CarWashVisitDataModel();

            carWashVisitDataModel.Code                = 200;
            carWashVisitDataModel.Message             = "successfully exicuted";
            carWashVisitDataModel.Success             = true;
            carWashVisitDataModel.CarwashVisitDetails = new ObservableCollection <CarwashVisitDetails>();

            ObservableCollection <Models.CarwashVisitDetails> ListOfCarwashVisitDetails = carWashVisitDatabase.GetCarwashVisitDetailsAsync();

            foreach (var item in ListOfCarwashVisitDetails)
            {
                CarwashVisitDetails carwashVisitDetails = ClassConverter.CastCarwashVisitDetails <CarwashVisitDetails>(item);
                //carwashVisitDetails.Tasks = new ObservableCollection<TaskDetails>();
                ObservableCollection <Models.TaskDetails> ListOfCarwashTaskDetails = carWashVisitDatabase.GetTaskDetailsAsync();
                foreach (var taskDetails in ListOfCarwashTaskDetails)
                {
                    TaskDetails carwashTaskDetails = ClassConverter.CastTaskDetails <TaskDetails>(taskDetails);
                    if (item.VisitId.ToString() == taskDetails.VisitTaskId)
                    {
                        carwashVisitDetails.Tasks.Add(carwashTaskDetails);
                    }
                }

                carWashVisitDataModel.CarwashVisitDetails.Add(carwashVisitDetails);
            }

            return(carWashVisitDataModel);
        }
示例#3
0
 public DecompteurN(int N, int nbr)
     : base(1, nbr, 0, "M 0,0 L 30,0 L 30,30 L 0,30 z", "frequencyDivider")
 {
     _nbroutputs   = nbr;
     outputs_tab   = ClassConverter.ConvertToBinary(N, _nbroutputs);
     _val          = N;
     oldClockValue = false;
 }
        public void ConvertAbstractClass()
        {
            var result = new ClassConverter().ConvertType(typeof(AbstractClass), new LocalContext(new ConvertConfiguration(), null, typeof(AbstractClass)));

            result.Should().BeLike(@"
export abstract class AbstractClass {
    constructor() {
    }
}");
        }
        public static List <T2> MapColletion <T1, T2>(this List <T1> inList, ClassConverter <T1, T2> classConverter)
        {
            List <T2> convertedList = new List <T2>();

            foreach (var element in inList)
            {
                var convertedElement = classConverter(element);
                convertedList.Add(convertedElement);
            }
            return(convertedList);
        }
示例#6
0
        /// <summary>
        /// Converts the specified object to an object of another class.
        /// </summary>
        /// <typeparam name="T">The type of the target to convert to.</typeparam>
        /// <param name="target">The target object to convert to.</param>
        /// <param name="source">The object to convert.</param>
        public static T Pack <T>(T target, object source)
            where T : new()
        {
            // allow null
            if (source == null)
            {
                return(target);
            }

            return(ClassConverter.SetClass(target, source));
        }
        public void ConvertSimpleClass_Arguments()
        {
            var result = new ClassConverter().ConvertType(typeof(SimpleClass), new LocalContext(new ConvertConfiguration(), null, typeof(SimpleClass)));

            result.Should().BeLike(@"
export class SimpleClass {
    constructor(
        public propertyArray?: Array<string>,
        public stringProperty?: string) {
    }
}");
        }
        public void ConvertGenericClass()
        {
            var result = new ClassConverter().ConvertType(typeof(GenericClass <,>), new LocalContext(new ConvertConfiguration(), null, typeof(GenericClass <,>)));

            result.Should().BeLike(@"
export class GenericClass<T1, T2> {
    constructor(
        public prop1?: T1,
        public prop2?: T2) {
    }
}");
        }
示例#9
0
        /// <summary>
        /// Converts the specified object to an object of another class.
        /// </summary>
        /// <typeparam name="T">The type of the target to convert to.</typeparam>
        /// <param name="source">The object to convert.</param>
        public static T Pack <T>(object source)
            where T : new()
        {
            // allow null
            if (source == null)
            {
                return(default(T));
            }

            var target = new T();

            ClassConverter.SetClass(target, source);
            return(target);
        }
        public void InheritanceTest()
        {
            var ctx    = new ConvertContext();
            var result = new ClassConverter().ConvertType(typeof(InheritanceSample), new LocalContext(ctx.Configuration, ctx, typeof(InheritanceSample)));

            result.Should().BeLike(@"
export class InheritanceSample extends SimpleClass {
    constructor(
        propertyArray?: Array<string>,
        stringProperty?: string,
        public isAwesome?: boolean) {
        super(propertyArray, stringProperty);
    }
}");

            ctx.GeneratedResults.Should().HaveCount(1);
        }
示例#11
0
        public override void Run()
        {
            update_input();
            bool newClockValue = (bool)inputs_tab[0];

            if (newClockValue == true && oldClockValue == false)
            {
                int number = ClassConverter.ConvertToInt(outputs_tab);
                number++;
                if (number == (_val))
                {
                    number = 0;
                }
                outputs_tab = ClassConverter.ConvertToBinary(number, _nbroutputs);
            }
            oldClockValue = newClockValue;
            update_output();
        }
示例#12
0
        /// <summary>
        /// Copy data from the source object into the row.
        /// </summary>
        /// <typeparam name="T">The type of the row.</typeparam>
        /// <param name="target">The target row object.</param>
        /// <param name="source">The source object.</param>
        public static T Pack <T>(this T target, object source)
            where T : DbRow
        {
            if (target == null)
            {
                throw new QueryTalkException("extensions.Pack<T>", QueryTalkExceptionType.ArgumentNull, "target = null", Text.Method.Pack);
            }
            if (source == null)
            {
                throw new QueryTalkException("extensions.Pack<T>", QueryTalkExceptionType.ArgumentNull, "source = null", Text.Method.Pack);
            }

            if (source != null)
            {
                return(ClassConverter.SetClass <T>(target, source));
            }

            return(target);
        }
        public void InheritanceDiscriminatorTest()
        {
            var ctx = new ConvertContext();

            ctx.Configuration.ClassConfiguration.InheritanceConfig
            .Add <BaseClassWithDiscriminator>(x => x.Discriminator,
                                              typeof(InheritanceDiscriminatorSample));

            var result = new ClassConverter().ConvertType(typeof(InheritanceDiscriminatorSample), new LocalContext(ctx.Configuration, ctx, typeof(InheritanceSample)));

            result.Should().BeLike(@"
export class InheritanceDiscriminatorSample extends BaseClassWithDiscriminator {
    constructor() {
        super();
    }
    public discriminator: string = 'inherit';
}");

            ctx.GeneratedResults.Should().HaveCount(2);
        }
示例#14
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
            });
        }
        public void ConvertSimpleClass_Initializer()
        {
            var result = new ClassConverter().ConvertType(typeof(SimpleClass), new LocalContext(new ConvertConfiguration
            {
                ClassConfiguration = { GenerateConstructorType = GenerateConstructorType.ObjectInitializer }
            }, null, typeof(SimpleClass)));

            result.Should().BeLike(@"
export class SimpleClass {
    constructor(init?: {
        propertyArray?: Array<string>,
        stringProperty?: string
    }) {
        if (init) {
            this.propertyArray = init.propertyArray;
            this.stringProperty = init.stringProperty;
        }
    }
    public propertyArray: Array<string>;
    public stringProperty: string;
}");
        }
示例#16
0
    public void PopulateMenuAsync()
    {
        ColorController.ColoreSfondi   = hexToColor(menuSS.ColorTheme);
        ColorController.ColoreRiquadri = hexToColor(menuSS.ColorFrame);
        NomeLocaleLong = menuSS.Denominazione;
        if (menuSS.LogoBase64Img.Length > 10)
        {
            string b64_string = menuSS.LogoBase64Img;
            b64_string = Regex.Replace(b64_string, @"^data:image\/[a-zA-Z]+;base64,", string.Empty);
            byte[] b64_bytes = System.Convert.FromBase64String(b64_string);

            var tex = new Texture2D(1, 1);
            tex.LoadImage(b64_bytes);
            if (tex != null)
            {
                var rec = new Rect(0, 0, tex.width, tex.height);
                cellImage.sprite         = Sprite.Create(tex, rec, new Vector2(0, 1), 100);
                cellImage.preserveAspect = true;
            }
        }
        DataService ds = new DataService("DatiCliente.db");

        fidelity = ds.GetFidelity(Restaurant);
        if (fidelity == null)
        {
            fidelity = "";
        }
        if (fidelity.Length > 12)
        {
            fidelity.Remove(fidelity.Length - 1);
            QREncodeTest.QR.Encode(fidelity);
        }
        Locale locale = ClassConverter.localifromSS(menuSS);

        welcome.text = locale.s_Landing;
        if (locale.s_Landing.Length < 3 || locale.s_Landing == null)
        {
            WelcomePanel.gameObject.SetActive(false);
        }
        Key = locale.s_CID;
        if (locale.s_pinPag.Length > 3)
        {
            PinPagOn = true;
        }
        secret = locale.s_SKE;
        //Key = "AaK1Dsz3z2xqhYs2JaHOXQpxUxxdO3ZYihg0IuebKVxUwU2xh4vS0BThdSz4rG4uSi-QU6gMXFy_QsNE";// locale.s_CID;
        //secret = "EBjXni131N_Ci2795OXE2qc11ndEncytbujnbHTK2Ez4o9HszD0ra2Rw8F_O03pluGxYWiZ46jwwsYiY"; // locale.s_SKE;
        consInt = locale.s_consegnaInterna;
        pagaConsegnaAbilitata = locale.s_EnablePagaCons;
        Tky          = locale.s_TakeAway;
        Dlv          = locale.s_Delivery;
        Base         = locale.s_Base;
        limitePezzi  = locale.s_LimitPZ;
        limiteValore = locale.s_LimitVAL;
        minimoValore = locale.s_LimitMinVAL;
        PinPag       = locale.s_pinPag;
        registrazioneObbligatoria = locale.s_RichiediDatiAccesso;
        bool MD = locale.s_EnableMD;

        SelectionBtnRoot.transform.GetChild(0).gameObject.SetActive(MD);
        SelectionBtnRoot.transform.GetChild(1).gameObject.SetActive(Base); //Base
        SelectionBtnRoot.transform.GetChild(2).gameObject.SetActive(Tky);
        SelectionBtnRoot.transform.GetChild(3).gameObject.SetActive(Dlv);
        SelectionBtnRoot.transform.GetChild(4).gameObject.SetActive(consInt);
        SelectionBtnRoot.transform.GetChild(5).gameObject.SetActive(fidelity.Length >= 12);


        if (locale.s_RichiediDatiAccesso)
        {
            if (!ClienteRegMin || !ClienteRegistrato || fidelity.Length <= 11)
            {
                registrazioneObbligatoria = (true);
                PannelloRegistrazione.SetActive(true);
            }
        }
        SelectionPanel.SetActive(true);
        string menuSs = ClassConverter.menufromSS(menuSS);

        menu = Menu_Ristorante.LoadMenu(menuSs, Db);

        ColorController.CController.CambiaColori();
        Loader.gameObject.SetActive(false);
        if (!loadFromCache)
        {
            AggiungiLocale();
        }
    }
示例#17
0
 /// <summary>
 /// Converts the specified objects to objects of another class.
 /// </summary>
 /// <typeparam name="T">The type of the target to convert to.</typeparam>
 /// <param name="source">The source objects to convert.</param>
 public static IEnumerable <T> PackRows <T>(IEnumerable source)
     where T : new()
 {
     return(ClassConverter.PackRows <T>(source));
 }
示例#18
0
 public ClassBusiness(IClassRepository classRepository)
 {
     _classRepository = classRepository;
     _classConverter  = new ClassConverter();
 }