Exemplo n.º 1
0
        /// <summary>
        /// Generate Token
        /// </summary>
        /// <param name="data">should contains  UserID , FirstName , LastName
        /// </param>
        /// <returns></returns>
        public static TServiceResult <Token> CreateToken(this IActions <Token> repo, UserVM u, string key)
        {
            var t      = new Token();
            var claims = new[]
            {
                new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString("N")),
                new Claim(JwtRegisteredClaimNames.UniqueName, u.Id),
                new Claim(JwtRegisteredClaimNames.GivenName, u.FirstName),
                new Claim(JwtRegisteredClaimNames.FamilyName, u.LastName)
            };

            var credentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(key)),
                                                     SecurityAlgorithms.HmacSha256Signature);

            var secToken = new JwtSecurityToken(
                issuer: "localhost",
                audience: "localhost",
                claims: claims,
                signingCredentials: credentials,
                notBefore: null,
                expires: DateTime.Now.AddDays(5));

            t.Hash       = new JwtSecurityTokenHandler().WriteToken(secToken);
            t.ExpireDate = secToken.ValidTo;
            repo.Insert(t);
            repo.SaveChanges();
            return(new TServiceResult <Token>(t));
        }
 public TestApiController(
     ILogger <TestApiController> logger,
     IActions iActions)
 {
     _iActions = iActions;
     _logger   = logger;
 }
Exemplo n.º 3
0
        public Fenetre(IActions model)
        {
            // initialisation IHM
            InitializeComponent();

            // initialisation de la grille
            grille = new Button[largeur_grille, hauteur_grille];

            // initialisation des tuiles
            for (int i = 0; i < largeur_grille; i++)
            {
                for (int j = 0; j < hauteur_grille; j++)
                {
                    // creation d'une tuile
                    grille[i, j]      = new Button();
                    grille[i, j].Size = new Size(taille_tuile, taille_tuile);
                    grille[i, j].Font = new Font("Arial", 9, FontStyle.Bold);

                    // positionnement
                    grille[i, j].Location = new Point(i * taille_tuile, j * taille_tuile);
                    this.GridPanel.Controls.Add(grille[i, j]);

                    // gestionnaire des clics
                    grille[i, j].MouseUp += new MouseEventHandler(this.CellButton_Click);
                }
            }

            // connection
            jeu     = model;
            jeu.vue = this;
            jeu.CommencerPartie(largeur_grille, hauteur_grille, numero_mines);
            MineLabel.Text = "Mines : " + numero_mines;
        }
Exemplo n.º 4
0
        public Plugin LoadMethods()
        {
            int idPlugin = 1;

            actions = new List <IActions>();

            itemPlugin = new Plugin()
            {
                Id           = idPlugin,
                Name         = Path.GetFileName(dllFile),
                LocationFile = dllFile
            };

            Assembly myDll = Assembly.LoadFrom(dllFile);

            foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type t in a.GetTypes())
                {
                    if (t.GetInterface("IActions") != null)
                    {
                        IActions obj = Activator.CreateInstance(t) as IActions;
                        if (obj != null)
                        {
                            actions.Add(obj);
                            itemPlugin.Action = obj;
                        }
                    }
                }
            }

            GetMenuItems();
            return(itemPlugin);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Hunter h1 = new Hunter();

            Console.WriteLine(h1.ToString());
            Shaman s1 = new Shaman();

            Console.WriteLine(s1.ToString());

            IActions[] actionsArr = new IActions[4];
            actionsArr[0] = h1;
            actionsArr[1] = s1;
            actionsArr[2] = new Fighter();
            actionsArr[3] = new Marksman();
            Printer p1 = new Printer();

            foreach (IActions i in actionsArr)
            {
                p1.IAmPrinting(i);
            }

            IActions ref1 = h1 as IActions;

            Console.WriteLine(h1 is IActions);
            Console.WriteLine(ref1 is IActions);
            Console.WriteLine((ref1 != null));
            Test     test1 = new Test();
            IActions ref2  = test1 as IActions;

            Console.WriteLine((ref2 != null));
            A a = new A(); B b = new B(); b.m(3, 4);
        }
 public ODataTypedRepository(
     ILogger logger,
     IExchanger exchanger,
     IActions actions,
     ITimeOutPolicy <T> policy)
     : base(logger, exchanger, actions, policy)
 {
 }
Exemplo n.º 7
0
 public ActionMoveUnit2D(IUnit2D unit2D, FloatPoint2D destanationPoint, float speedPerSecond, IActions nextAction = null)
 {
     MovingUnit       = unit2D;
     DestanationPoint = destanationPoint;
     SpeedPerSecond   = speedPerSecond;
     NextAction       = nextAction;
     LastStepTime     = default;
 }
Exemplo n.º 8
0
 public TwoConditionEvent(IConditions condition1, IConditions condition2, IActions action1, IActions action2, IActions action3)
 {
     Condition1 = condition1;
     Condition2 = condition2;
     Action1    = action1;
     Action2    = action2;
     Action3    = action3;
 }
Exemplo n.º 9
0
        /////////////////////////////////////////////////////////////////////////////////

        private IGraph ImportModels(List<String> ecoreFilenames, String grgFilename, IBackend backend, out IActions actions)
        {
            foreach(String ecoreFilename in ecoreFilenames)
            {
                String modelText = ParseModel(ecoreFilename);

                String modelfilename = ecoreFilename.Substring(0, ecoreFilename.LastIndexOf('.')) + "__ecore.gm";

                // Do we have to update the model file (.gm)?
                if(!File.Exists(modelfilename) || File.GetLastWriteTime(ecoreFilename) > File.GetLastWriteTime(modelfilename))
                {
                    Console.WriteLine("Writing model file \"" + modelfilename + "\"...");
                    using(StreamWriter writer = new StreamWriter(modelfilename))
                        writer.Write(modelText);
                }
            }

            if(grgFilename == null)
            {
                grgFilename = "";
                foreach(String ecoreFilename in ecoreFilenames)
                    grgFilename += ecoreFilename.Substring(0, ecoreFilename.LastIndexOf('.')) + "_";
                grgFilename += "_ecore.grg";

                StringBuilder sb = new StringBuilder();
                sb.Append("// Automatically generated\n// Do not change, changes will be lost!\n\nusing ");

                DateTime grgTime;
                if(!File.Exists(grgFilename)) grgTime = DateTime.MinValue;
                else grgTime = File.GetLastWriteTime(grgFilename);

                bool mustWriteGrg = false;

                bool first = true;
                foreach(String ecore in ecoreFilenames)
                {
                    if(first) first = false;
                    else sb.Append(", ");
                    sb.Append(ecore.Substring(0, ecore.LastIndexOf('.')) + "__ecore");

                    if(File.GetLastWriteTime(ecore) > grgTime)
                        mustWriteGrg = true;
                }

                if(mustWriteGrg)
                {
                    sb.Append(";\n");
                    using(StreamWriter writer = new StreamWriter(grgFilename))
                        writer.Write(sb.ToString());
                }
            }

            IGraph graph;
            backend.CreateFromSpec(grgFilename, "defaultname", null,
                ProcessSpecFlags.UseNoExistingFiles, new List<String>(), 
                out graph, out actions);
            return graph;
        }
Exemplo n.º 10
0
        public Store Register(IActions Value, string Key = Constraints.DefaultKey)
        {
            if (!_Actions.ContainsKey(Key))
            {
                _Actions.Add(Key, Value);
            }

            return(this);
        }
        public override void Prepare(ActionsViewModelNavigationParams parameter)
        {
            DashCamActions = parameter?.DashCamActions;

            if (DashCamActions != null)
            {
                PrimaryData.AddRange(DashCamActions.Actions);
            }
        }
Exemplo n.º 12
0
 public TypedRepository(
     ILogger logger,
     IExchanger exchanger,
     IActions actions,
     ITimeOutPolicy <T> policy)
     : base(logger, exchanger, actions)
 {
     Policy = policy;
 }
Exemplo n.º 13
0
        public void CreateFromSpec(string grgFilename, string graphName, String statisticsPath, ProcessSpecFlags flags, List <String> externalAssemblies,
                                   out IGraph newGraph, out IActions newActions)
        {
            LGSPGraph   graph;
            LGSPActions actions;

            CreateFromSpec(grgFilename, graphName, statisticsPath, flags, externalAssemblies, false, 0, out graph, out actions);
            newGraph   = graph;
            newActions = actions;
        }
Exemplo n.º 14
0
 public GameItem(ItemCategory category, int itemTypeID, string name, int price,
                 bool isUnique = false, IActions action = null)
 {
     Category   = category;
     ItemTypeID = itemTypeID;
     Name       = name;
     Price      = price;
     IsUnique   = isUnique;
     Action     = action;
 }
Exemplo n.º 15
0
    internal void SetBehabiour(IMoventOnSurface onMoventSurface, IMoventOnAir onAirMovent, IActions action)
    {
        _onMoventSurface = onMoventSurface;
        _onAirMovent     = onAirMovent;
        _actions         = action;

        _onAirMovent.Active();
        _onMoventSurface.Active();
        _actions.Active();
    }
Exemplo n.º 16
0
 /// <summary>
 /// Creates a new graph from the given ECore metamodels.
 /// If a grg file is given, the graph will use the graph model declared in it and the according
 /// actions object will be associated to the graph.
 /// If a xmi file is given, the model instance will be imported into the graph.
 /// Any errors will be reported by exception.
 /// </summary>
 /// <param name="backend">The backend to use to create the graph.</param>
 /// <param name="ecoreFilenames">A list of ECore model specification files. It must at least contain one element.</param>
 /// <param name="grgFilename">A grg file to be used to create the graph, or null.</param>
 /// <param name="xmiFilename">The filename of the model instance to be imported, or null.</param>
 /// <param name="noPackageNamePrefix">Prefix the types with the name of the package? Can only be used if names from the packages are disjoint.</param>
 /// <param name="actions">Receives the actions object in case a .grg model is given.</param>
 public static IGraph Import(IBackend backend, List<String> ecoreFilenames, String grgFilename, String xmiFilename, bool noPackageNamePrefix, out IActions actions)
 {
     ECoreImport imported = new ECoreImport();
     imported.graph = imported.ImportModels(ecoreFilenames, grgFilename, backend, out actions);
     if(xmiFilename != null)
     {
         Console.WriteLine("Importing graph...");
         imported.ImportGraph(xmiFilename);
     }
     return imported.graph;
 }
Exemplo n.º 17
0
        public static async Task <TServiceResult <Token> > SignUpAsync(this IActions <Token> repo, UserVM data, IAuthActions <Token> dataManager)
        {
            var u      = data.MapProp <UserVM, AppUser>(new AppUser());
            var result = await dataManager.GetUserManager().CreateAsync(u, data.Password);

            if (result.Succeeded)
            {
                return(CreateToken(repo, data, dataManager.GetSecurityKey()));
            }
            return(new TServiceResult <Token>(null, "", false));
        }
Exemplo n.º 18
0
    IEnumerator wait(float sec, IActions action)
    {
        yield return(new WaitForSeconds(sec));

        action.InvokeAction();
        if (!currentRobot.GetComponent <Robot> ().GetCollision())
        {
            audioSource.clip = sound;
            audioSource.Play();
        }
    }
Exemplo n.º 19
0
        public void CreateNamedFromSpec(string grgFilename, string graphName, String statisticsPath,
                                        ProcessSpecFlags flags, List <String> externalAssemblies, int capacity,
                                        out INamedGraph newGraph, out IActions newActions)
        {
            LGSPGraph   graph;
            LGSPActions actions;

            CreateFromSpec(grgFilename, graphName, statisticsPath, flags, externalAssemblies, true, capacity, out graph, out actions);
            newGraph   = (LGSPNamedGraph)graph;
            newActions = actions;
        }
Exemplo n.º 20
0
 public void StartAction(IActions action)
 {
     if (currentAction == action)
     {
         return;
     }
     if (currentAction != null)
     {
         currentAction.Cancel();
     }
     currentAction = action;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Returns type object for type name string
        /// </summary>
        /// <param name="typeName">Name of the type we want some type object for</param>
        /// <param name="procEnv">Graph processing environment to search the types in</param>
        /// <returns>The type object corresponding to the given string, null if type was not found</returns>
        public static Type GetType(String typeName, IGraphProcessingEnvironment procEnv)
        {
            if (typeName == null)
            {
                return(null);
            }

            if (procEnv == null)
            {
                return(null);
            }

            Type typeFromModel = GetType(typeName, procEnv.Graph.Model);

            if (typeFromModel != null)
            {
                return(typeFromModel);
            }

            IActions actions = procEnv.Actions;

            Assembly assembly = Assembly.GetAssembly(actions.GetType());

            typeName = typeName.Substring(6);                      // remove "match<"
            typeName = typeName.Substring(0, typeName.Length - 1); // remove ">"
            if (typeName.StartsWith("class "))
            {
                typeName = typeName.Substring(6); // remove "class "
            }
            foreach (IAction action in actions.Actions)
            {
                if (action.PackagePrefixedName == typeName)
                {
                    Type type = Type.GetType(action.RulePattern.MatchInterfaceName + "," + assembly.FullName); // search actions assembly
                    return(type);
                }
            }

            foreach (MatchClassFilterer matchClassFilterer in actions.MatchClasses)
            {
                MatchClassInfo info = matchClassFilterer.info;
                if (info.PackagePrefixedName == typeName)
                {
                    Type type = Type.GetType(info.matchInterfaceName + "," + assembly.FullName); // search actions assembly
                    return(type);
                }
            }

            return(null);
        }
Exemplo n.º 22
0
        public static IActions GetTheStrongest(Army obj)
        {
            int      s    = 0;
            IActions temp = obj.data[0];

            foreach (IActions i in obj.data)
            {
                if (i.GetAttack() > s)
                {
                    s    = i.GetAttack();
                    temp = i;
                }
            }
            return(temp);
        }
Exemplo n.º 23
0
        public int CompareTo(object obj)
        {
            IActions i = obj as IActions;

            if (GetAttack() > i.GetAttack())
            {
                return(1);
            }
            if (GetAttack() == i.GetAttack())
            {
                return(0);
            }
            else
            {
                return(-1);
            }
        }
Exemplo n.º 24
0
 public override IActions Progress()
 {
     if (TimerStep != null)
     {
         TimerStep = TimerStep.Progress();
     }
     else
     {
         ThisAction = ThisAction.Progress();
         if (IsComplete())
         {
             return(NextAction?.Start());
         }
         TimerStep = new ActionWaitForTime(MillisecondStepLength).Start();
     }
     return(this);
 }
Exemplo n.º 25
0
 public FlowManager(ScreenData screenData,
                    IAppLogger appLogger,
                    DirectorFactory directorFactory,
                    FlowDataCache flowDataCache,
                    IActions actions,
                    IDialogFunctions dialogFunctions,
                    FlowActivityFactory flowActivityFactory,
                    IMapper mapper)
 {
     this.screenData      = screenData;
     this.appLogger       = appLogger;
     this.Director        = directorFactory.Create(this);
     this.FlowDataCache   = flowDataCache;
     this.Actions         = actions;
     this.DialogFunctions = dialogFunctions;
     this.FlowActivity    = flowActivityFactory.Create(this);
     this.Mapper          = mapper;
 }
Exemplo n.º 26
0
 public IActions Delete(int num)
 {
     if ((data.Length > 0) && (num < data.Length) && (num >= 0))
     {
         IActions temp = data[num];
         for (int i = num; i < data.Length - 1; i++)
         {
             data[i] = data[i + 1];
         }
         Array.Resize(ref data, data.Length - 1);
         return(temp);
     }
     else
     {
         //Console.WriteLine("Ошибка удаления элемента");
         throw new IndexOutOfRangeException("Ошибка удаления элемента номер " + num.ToString());
         //return null;
     }
 }
Exemplo n.º 27
0
        private string GetActionName(IActions action)
        {
            if (action != null)
            {
                switch (action.GetActionType())
                {
                case ActionType.Action_Type.GoToPage:
                    return(Strings.ResStrings.GoToPage);

                case ActionType.Action_Type.OpenWeb:
                    return(Strings.ResStrings.OpenLink);

                case ActionType.Action_Type.ClosePresentation:
                    return(Strings.ResStrings.ClosePresentation);

                case ActionType.Action_Type.OpenApplication:
                    return(Strings.ResStrings.OpenApplication);

                case ActionType.Action_Type.ShowMessageBox:
                    return(Strings.ResStrings.ShowMessageBox);

                case ActionType.Action_Type.Sound:
                    return(Strings.ResStrings.Sound);

                case ActionType.Action_Type.LoadPresentation:
                    return(Strings.ResStrings.LoadPresentation);

                case ActionType.Action_Type.SetVisibility:
                    return(Strings.ResStrings.Visibility);

                case ActionType.Action_Type.DoAnimation:
                    return(Strings.ResStrings.DoAnimation);

                case ActionType.Action_Type.Position:
                    return(Strings.ResStrings.Position);

                case ActionType.Action_Type.NoAction:
                    return("-");
                }
            }
            return("-");
        }
Exemplo n.º 28
0
        public static async Task <TServiceResult <Token> > LoginAsync(this IActions <Token> repo, UserVM data, IAuthActions <Token> dataManager)
        {
            Token t    = new Token();
            var   user = data.MapProp <UserVM, AppUser>(new AppUser());
            var   res  = await dataManager.GetSigningManager().PasswordSignInAsync(user.UserName, data.Password, true, true);

            if (!res.Succeeded)
            {
                return(new TServiceResult <Token>(null, "not found", false));
            }
            user = await dataManager.GetUserManager().FindByNameAsync(user.UserName);

            if (!await dataManager.GetUserManager().IsInRoleAsync(user, "User"))
            {
                /*
                 * add memeber to roll
                 */
            }
            return(CreateToken(repo, data, dataManager.GetSecurityKey()));
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            Student s1 = new Student();

            s1.displayStudent();

            Console.WriteLine("**********************");
            Teacher t1 = new Teacher();

            t1.sleep();
            //t1.eat();             //de ce nu merge? din moment ce nu merge de ce nu primesc eroare ca nu ii implementata
            //metoda in clasa Teacher din moment ce implementeaza IAction

            IActions action = t1; // ce obiect este action? teacher?

            action.eat();

            Console.WriteLine("**********************");
            Console.WriteLine(t1.pushups());
        }
Exemplo n.º 30
0
        private Actions(Resolution resolution, IActions buttons, Layer layer)
        {
            if (resolution == null)
            {
                throw new ArgumentNullException(nameof(resolution));
            }
            if (buttons == null)
            {
                throw new ArgumentNullException(nameof(buttons));
            }
            if (layer == null)
            {
                throw new ArgumentNullException(nameof(layer));
            }

            /*
             *
             *
             *
             * Up = new Events(resolution, buttons.Up, layer);
             * Down = new Events(resolution, buttons.Down, layer);
             * Left = new Events(resolution, buttons.Left, layer);
             * Right = new Events(resolution, buttons.Right, layer);
             * Cancel = new Events(resolution, buttons.Cancel, layer);
             * Button1 = new Events(resolution, buttons.Button1, layer);
             *
             * layer.CanvasElement.OnMouseDown = (e) =>
             * {
             *      InputMouseDown(e);
             * };
             * layer.CanvasElement.OnMouseUp = (e) =>
             * {
             *      InputMouseUp(e);
             * };
             * layer.CanvasElement.OnMouseMove = (e) =>
             * {
             *      InputMouseMove(e);
             * };
             */
        }
Exemplo n.º 31
0
 /// <summary>
 /// Imports the given graph from a file with the given filename.
 /// Any errors will be reported by exception.
 /// </summary>
 /// <param name="importFilename">The filename of the file to be imported.</param>
 /// <param name="backend">The backend to use to create the graph.</param>
 /// <param name="graphModel">The graph model to be used.</param>
 /// <param name="actions">Receives the actions object in case a .grg model is given.</param>
 /// <returns>The imported graph. 
 /// An INamedGraph is returned. If you don't need it: create an LGSPGraph from it and throw the named graph away.
 /// (the naming requires about the same amount of memory the raw graph behind it requires).</returns>		
 public static INamedGraph Import(String importFilename, IBackend backend, IGraphModel graphModel, out IActions actions)
 {
     FileInfo fi = new FileInfo(importFilename);
     long fileSize = fi.Length;
     return Import(new StreamReader(importFilename), fileSize, backend, graphModel, out actions);
 }
Exemplo n.º 32
0
 /// <summary>
 /// Imports a graph from the given file.
 /// The format is determined by the file extension.
 /// Any errors will be reported by exception.
 /// </summary>
 /// <param name="importFilename">The filename of the file to be imported, 
 ///     the model specification part will be ignored.</param>
 /// <param name="backend">The backend to use to create the graph.</param>
 /// <param name="graphModel">The graph model to be used, 
 ///     it must be conformant to the model used in the file to be imported.</param>
 /// <param name="actions">Receives the actions object in case a .grg model is given.</param>
 /// <returns>The imported graph. 
 /// The .grs/.grsi importer returns an INamedGraph. If you don't need it: create an LGSPGraph from it and throw the named graph away.
 /// (the naming requires about the same amount of memory the raw graph behind it requires).</returns>
 public static IGraph Import(String importFilename, IBackend backend, IGraphModel graphModel, out IActions actions)
 {
     if(importFilename.EndsWith(".gxl", StringComparison.InvariantCultureIgnoreCase))
         return GXLImport.Import(importFilename, backend, graphModel, out actions);
     else if (importFilename.EndsWith(".grs", StringComparison.InvariantCultureIgnoreCase)
                 || importFilename.EndsWith(".grsi", StringComparison.InvariantCultureIgnoreCase))
         return GRSImport.Import(importFilename, backend, graphModel, out actions);
     else
         throw new NotSupportedException("File format not supported");
 }
Exemplo n.º 33
0
        void EventSubscription(IActions menu_actions)
        {
            menu_actions.NewElement += NewElement;

            menu_actions.DeleteElements += DeleteElements;
        }
Exemplo n.º 34
0
 /// <summary>
 /// Imports the given graph from the given text reader input stream.
 /// Any errors will be reported by exception.
 /// </summary>
 /// <param name="reader">The text reader input stream import source.</param>
 /// <param name="fileSize">The size of the input file.</param>
 /// <param name="backend">The backend to use to create the graph.</param>
 /// <param name="graphModel">The graph model to be used.</param>
 /// <param name="actions">Receives the actions object in case a .grg model is given.</param>
 /// <returns>The imported graph. 
 /// An INamedGraph is returned. If you don't need it: create an LGSPGraph from it and throw the named graph away.
 /// (the naming requires about the same amount of memory the raw graph behind it requires).</returns>		
 public static INamedGraph Import(TextReader reader, long fileSize, IBackend backend, IGraphModel graphModel, out IActions actions)
 {
     GRSImport importer = new GRSImport(reader, fileSize);
     importer.backend = backend;
     importer.modelOverride = null;
     importer.model = graphModel;
     importer.ParseGraphBuildingScript();
     actions = importer.actions;
     return importer.graph;
 }
Exemplo n.º 35
0
 IEnumerator wait(float sec, IActions action)
 {
     yield return new WaitForSeconds (sec);
     action.InvokeAction ();
     if (!currentRobot.GetComponent<Robot> ().GetCollision()) {
         audioSource.clip = sound;
         audioSource.Play ();
     }
 }
Exemplo n.º 36
0
 /// <summary>
 /// Adds the action to panel.
 /// </summary>
 /// <param name="action">Action.</param>
 public void AddActionToPanel(IActions action)
 {
     //TODO
 }
Exemplo n.º 37
0
 /// <summary>
 /// Adds the action to the action list.
 /// </summary>
 /// <param name="addedAction">Added action.</param>
 public void AddAction(IActions addedAction)
 {
     actions.Add (addedAction);
 }
Exemplo n.º 38
0
        /////////////////////////////////////////////////////////////////////////////////

        private IGraph ImportModels(List <String> ecoreFilenames, String grgFilename, IBackend backend, out IActions actions)
        {
            foreach (String ecoreFilename in ecoreFilenames)
            {
                String modelText = ParseModel(ecoreFilename);

                String modelfilename = ecoreFilename.Substring(0, ecoreFilename.LastIndexOf('.')) + "__ecore.gm";

                // Do we have to update the model file (.gm)?
                if (!File.Exists(modelfilename) || File.GetLastWriteTime(ecoreFilename) > File.GetLastWriteTime(modelfilename))
                {
                    Console.WriteLine("Writing model file \"" + modelfilename + "\"...");
                    using (StreamWriter writer = new StreamWriter(modelfilename))
                        writer.Write(modelText);
                }
            }

            if (grgFilename == null)
            {
                grgFilename = "";
                foreach (String ecoreFilename in ecoreFilenames)
                {
                    grgFilename += ecoreFilename.Substring(0, ecoreFilename.LastIndexOf('.')) + "_";
                }
                grgFilename += "_ecore.grg";

                StringBuilder sb = new StringBuilder();
                sb.Append("// Automatically generated\n// Do not change, changes will be lost!\n\nusing ");

                DateTime grgTime;
                if (!File.Exists(grgFilename))
                {
                    grgTime = DateTime.MinValue;
                }
                else
                {
                    grgTime = File.GetLastWriteTime(grgFilename);
                }

                bool mustWriteGrg = false;

                bool first = true;
                foreach (String ecore in ecoreFilenames)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        sb.Append(", ");
                    }
                    sb.Append(ecore.Substring(0, ecore.LastIndexOf('.')) + "__ecore");

                    if (File.GetLastWriteTime(ecore) > grgTime)
                    {
                        mustWriteGrg = true;
                    }
                }

                if (mustWriteGrg)
                {
                    sb.Append(";\n");
                    using (StreamWriter writer = new StreamWriter(grgFilename))
                        writer.Write(sb.ToString());
                }
            }

            IGraph graph;

            backend.CreateFromSpec(grgFilename, "defaultname", null,
                                   ProcessSpecFlags.UseNoExistingFiles, new List <String>(),
                                   out graph, out actions);
            return(graph);
        }
Exemplo n.º 39
0
 public void CreateNamedFromSpec(string grgFilename, string graphName, String statisticsPath, 
     ProcessSpecFlags flags, List<String> externalAssemblies, int capacity,
     out INamedGraph newGraph, out IActions newActions)
 {
     LGSPGraph graph;
     LGSPActions actions;
     CreateFromSpec(grgFilename, graphName, statisticsPath, flags, externalAssemblies, true, capacity, out graph, out actions);
     newGraph = (LGSPNamedGraph)graph;
     newActions = actions;
 }
Exemplo n.º 40
0
 public void CreateFromSpec(string grgFilename, string graphName, String statisticsPath, ProcessSpecFlags flags, List<String> externalAssemblies, 
     out IGraph newGraph, out IActions newActions)
 {
     LGSPGraph graph;
     LGSPActions actions;
     CreateFromSpec(grgFilename, graphName, statisticsPath, flags, externalAssemblies, false, 0, out graph, out actions);
     newGraph = graph;
     newActions = actions;
 }
Exemplo n.º 41
0
		public void Setup()
		{
			_actions = A.Fake<IActions>();
		}
Exemplo n.º 42
0
 // constructor for interpreted sequences
 public SequenceCheckingEnvironmentInterpreted(IActions actions)
 {
     this.actions = actions;
 }
Exemplo n.º 43
0
        /// <summary>
        /// Imports a graph from the given files.
        /// If the filenames only specify a model, the graph is empty.
        /// The format is determined by the file extensions.
        /// Currently available are: .grs/.grsi or .gxl or .ecore with .xmi.
        /// Optionally suffixed by .gz; in this case they are expected to be gzipped.
        /// Any error will be reported by exception.
        /// </summary>
        /// <param name="backend">The backend to use to create the graph.</param>
        /// <param name="filenameParameters">The names of the files to be imported.</param>
        /// <param name="actions">Receives the actions object in case a .grg model is given.</param>
        /// <returns>The imported graph. 
        /// The .grs/.grsi importer returns an INamedGraph. If you don't need it: create an LGSPGraph from it and throw the named graph away.
        /// (the naming requires about the same amount of memory the raw graph behind it requires).</returns>
        public static IGraph Import(IBackend backend, List<String> filenameParameters, out IActions actions)
        {
            String first = ListGet(filenameParameters, 0);
            FileInfo fi = new FileInfo(first);
            long fileSize = fi.Length;
            StreamReader reader = null;
            if (first.EndsWith(".gz", StringComparison.InvariantCultureIgnoreCase)) {
                FileStream filereader = new FileStream(first, FileMode.Open,  FileAccess.Read);
                reader = new StreamReader(new GZipStream(filereader, CompressionMode.Decompress));
                first = first.Substring(0, first.Length - 3);
            } else {
                reader = new StreamReader(first);
            }

            using(reader)
            {
                if(first.EndsWith(".gxl", StringComparison.InvariantCultureIgnoreCase))
                    return GXLImport.Import(reader, ListGet(filenameParameters, 1), backend, out actions);
                else if(first.EndsWith(".grs", StringComparison.InvariantCultureIgnoreCase)
                            || first.EndsWith(".grsi", StringComparison.InvariantCultureIgnoreCase))
                    return GRSImport.Import(reader, fileSize, ListGet(filenameParameters, 1), backend, out actions);
                else if(first.EndsWith(".ecore", StringComparison.InvariantCultureIgnoreCase))
                {
                    List<String> ecores = new List<String>();
                    String grg = null;
                    String xmi = null;
                    bool noPackageNamePrefix = false;
                    foreach(String filename in filenameParameters)
                    {
                        if(filename.EndsWith(".ecore")) ecores.Add(filename);
                        else if(filename.EndsWith(".grg"))
                        {
                            if(grg != null)
                                throw new NotSupportedException("Only one .grg file supported");
                            grg = filename;
                        }
                        else if(filename.EndsWith(".xmi"))
                        {
                            if(xmi != null)
                                throw new NotSupportedException("Only one .xmi file supported");
                            xmi = filename;
                        }
                        else if(filename == "nopackagenameprefix")
                        {
                            noPackageNamePrefix = true;
                        }
                    }
                    return ECoreImport.Import(backend, ecores, grg, xmi, noPackageNamePrefix, out actions);
                }
                else
                    throw new NotSupportedException("File format not supported");
            }
        }
Exemplo n.º 44
0
 /// <summary>
 /// Imports the given graph from a file with the given filename.
 /// Any errors will be reported by exception.
 /// </summary>
 /// <param name="importFilename">The filename of the file to be imported.</param>
 /// <param name="backend">The backend to use to create the graph.</param>
 /// <param name="actions">Receives the actions object in case a .grg model is given.</param>
 /// <returns>The imported graph. 
 /// An INamedGraph is returned. If you don't need it: create an LGSPGraph from it and throw the named graph away.
 /// (the naming requires about the same amount of memory the raw graph behind it requires).</returns>		
 public static INamedGraph Import(String importFilename, IBackend backend, out IActions actions)
 {
     return Import(importFilename, null, backend, out actions);
 }
Exemplo n.º 45
0
		internal AutoPagedActions(IActions trelloActions, int pageSize)
			: base(pageSize)
		{
			_trelloActions = trelloActions;
		}