/* * Copyright (c) 2018 iTAC Software AG, Germany. All Rights Reserved. * * This software is protected by copyright. Under no circumstances may any part of this file in any form be copied, * printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language * without the written permission of iTAC Software AG. */ // created 06.11.2018 11:07:38 using System; using System.Collections.Generic; namespace com.itac.oib.siplacesetupcenter.contracts.data { // source: assembly 5.1.0.84 // source: assembly ASM.AS.OIB.SIPLACESetupCenter.Contracts public class ActiveSetupAndRecipeMapper { // used for itac->asm: True // used for asm->itac: True // maps iTAC namespace conform type to ASM namespace type public static Asm.As.Oib.SiplaceSetupCenter.Contracts.Data.ActiveSetupAndRecipe get(ActiveSetupAndRecipe itacActiveSetupAndRecipe) { if (itacActiveSetupAndRecipe == null) { return null; } Asm.As.Oib.SiplaceSetupCenter.Contracts.Data.ActiveSetupAndRecipe asmActiveSetupAndRecipe = new Asm.As.Oib.SiplaceSetupCenter.Contracts.Data.ActiveSetupAndRecipe(); mapItac2Asm(asmActiveSetupAndRecipe, itacActiveSetupAndRecipe); return asmActiveSetupAndRecipe; } public static void mapItac2Asm(Asm.As.Oib.SiplaceSetupCenter.Contracts.Data.ActiveSetupAndRecipe asmActiveSetupAndRecipe, ActiveSetupAndRecipe itacActiveSetupAndRecipe) { // complex property ActiveSetup, isArray:False, isGeneric:False asmActiveSetupAndRecipe.ActiveSetup = com.itac.oib.siplacesetupcenter.contracts.data.ActiveSetupMapper.get( itacActiveSetupAndRecipe.ActiveSetup); // complex property ConveyorLanes, isArray:False, isGeneric:True // map Dictionary asmActiveSetupAndRecipe.ConveyorLanes = getDictionary(itacActiveSetupAndRecipe.ConveyorLanes); asmActiveSetupAndRecipe.MachineId = itacActiveSetupAndRecipe.MachineId; } // maps iTAC namespace conform array to ASM namespace array public static Asm.As.Oib.SiplaceSetupCenter.Contracts.Data.ActiveSetupAndRecipe[] get(ActiveSetupAndRecipe[] itacActiveSetupAndRecipe) { if (itacActiveSetupAndRecipe == null) { return null; } Asm.As.Oib.SiplaceSetupCenter.Contracts.Data.ActiveSetupAndRecipe[] asmActiveSetupAndRecipe = new Asm.As.Oib.SiplaceSetupCenter.Contracts.Data.ActiveSetupAndRecipe[itacActiveSetupAndRecipe.Length]; for (int i = 0; i < itacActiveSetupAndRecipe.Length; i++) { // to itac array asmActiveSetupAndRecipe[i] = ActiveSetupAndRecipeMapper.get(itacActiveSetupAndRecipe[i]); } return asmActiveSetupAndRecipe; } // maps iTAC namespace conform array to ASM namespace list public static List getList(ActiveSetupAndRecipe[] asmActiveSetupAndRecipe) { if (asmActiveSetupAndRecipe == null) { return null; } List itacActiveSetupAndRecipe = new List(); for (int i = 0; i < asmActiveSetupAndRecipe.Length; i++) { itacActiveSetupAndRecipe.Add(ActiveSetupAndRecipeMapper.get(asmActiveSetupAndRecipe[i])); } return itacActiveSetupAndRecipe; } // map type from ASM namespace to iTAC namespace public static ActiveSetupAndRecipe get(Asm.As.Oib.SiplaceSetupCenter.Contracts.Data.ActiveSetupAndRecipe asmActiveSetupAndRecipe) { if (asmActiveSetupAndRecipe == null) { return null; } ActiveSetupAndRecipe itacActiveSetupAndRecipe = new ActiveSetupAndRecipe(); mapAsm2Itac(asmActiveSetupAndRecipe, itacActiveSetupAndRecipe); return itacActiveSetupAndRecipe; } public static void mapAsm2Itac(Asm.As.Oib.SiplaceSetupCenter.Contracts.Data.ActiveSetupAndRecipe asmActiveSetupAndRecipe, ActiveSetupAndRecipe itacActiveSetupAndRecipe) { itacActiveSetupAndRecipe.ActiveSetup = com.itac.oib.siplacesetupcenter.contracts.data.ActiveSetupMapper.get(asmActiveSetupAndRecipe.ActiveSetup); // complex asm property ActiveSetup // assign Dictionary(): maps ASM Dictionary 2 iTAC dictionary itacActiveSetupAndRecipe.ConveyorLanes = getConveyorLanesDictionary( asmActiveSetupAndRecipe.ConveyorLanes); itacActiveSetupAndRecipe.MachineId = asmActiveSetupAndRecipe.MachineId; } // maps ASM namespace conform list to iTAC namespace array public static ActiveSetupAndRecipe[] getArray(IList asmActiveSetupAndRecipe) { if (asmActiveSetupAndRecipe == null) { return null; } ActiveSetupAndRecipe[] itacActiveSetupAndRecipe = new ActiveSetupAndRecipe[asmActiveSetupAndRecipe.Count]; for (int i = 0; i < asmActiveSetupAndRecipe.Count; i++) { itacActiveSetupAndRecipe[i] = ActiveSetupAndRecipeMapper.get(asmActiveSetupAndRecipe[i]); } return itacActiveSetupAndRecipe; } // maps ASM namespace conform array to iTAC namespace array public static ActiveSetupAndRecipe[] getArray(Asm.As.Oib.SiplaceSetupCenter.Contracts.Data.ActiveSetupAndRecipe[] asmActiveSetupAndRecipe) { if (asmActiveSetupAndRecipe == null) { return null; } ActiveSetupAndRecipe[] itacActiveSetupAndRecipe = new ActiveSetupAndRecipe[asmActiveSetupAndRecipe.Length]; for (int i = 0; i < asmActiveSetupAndRecipe.Length; i++) { itacActiveSetupAndRecipe[i] = ActiveSetupAndRecipeMapper.get(asmActiveSetupAndRecipe[i]); } return itacActiveSetupAndRecipe; } // maps c# dictionary with ASM types to c# dictionary with java types public static Dictionary getDictionary(Dictionary dictionary) { Dictionary result = new Dictionary(); foreach (Int32 key in dictionary.Keys) { result.Add(key, ConveyorLaneMapper.get(dictionary[key])); } return result; } // original declaration: System.Collections.Generic.Dictionary`2[System.Int32,Asm.As.Oib.SiplaceSetupCenter.Contracts.Data.ConveyorLane] // generate key / value array for dictionary // generated dictionary mapper private static Dictionary getConveyorLanesDictionary(IDictionary conveyorLanes) { Dictionary result = new Dictionary(); foreach (Int32 key in conveyorLanes.Keys) { result.Add(key, com.itac.oib.siplacesetupcenter.contracts.data.ConveyorLaneMapper.get(conveyorLanes[key])); } return result; } } }