예제 #1
0
 private void ResolveFiles_1(string[] searchPaths)
 {
     if (_assemblyReferences != null)
     {
         foreach (AssemblyReference a in _assemblyReferences)
         {
             if (!a.IsPrerequisite || a.AssemblyIdentity == null)
             {
                 if (!ResolveAssembly(a, searchPaths))
                 {
                     if (_treatUnfoundNativeAssembliesAsPrerequisites && a.ReferenceType == AssemblyReferenceType.NativeAssembly)
                     {
                         a.IsPrerequisite = true;
                     }
                     else
                     {
                         // When we're only reading a manifest (i.e. from ResolveNativeReference task), it's
                         // very useful to report what manifest has the unresolvable reference. However, when
                         // we're generating a new manifest (i.e. from GenerateApplicationManifest task)
                         // reporting the manifest is awkward and sometimes looks like a bug.
                         // So we use the ReadOnly flag to tell the difference between the two cases...
                         if (_readOnly)
                         {
                             OutputMessages.AddErrorMessage("GenerateManifest.ResolveFailedInReadOnlyMode", a.ToString(), this.ToString());
                         }
                         else
                         {
                             OutputMessages.AddErrorMessage("GenerateManifest.ResolveFailedInReadWriteMode", a.ToString());
                         }
                     }
                 }
             }
         }
     }
 }
예제 #2
0
        private void ValidateConfig()
        {
            if (String.IsNullOrEmpty(ConfigFile))
            {
                return;
            }
            FileReference configFile = FileReferences.FindTargetPath(ConfigFile);

            if (configFile == null)
            {
                return;
            }

            if (!TrustInfo.IsFullTrust)
            {
                XmlDocument document = new XmlDocument();

                XmlReaderSettings xrs = new XmlReaderSettings();
                xrs.DtdProcessing = DtdProcessing.Ignore;

                using (XmlReader xr = XmlReader.Create(configFile.ResolvedPath, xrs))
                {
                    document.Load(xr);
                }
                XmlNamespaceManager nsmgr = XmlNamespaces.GetNamespaceManager(document.NameTable);
                XmlNodeList         nodes = document.SelectNodes(XPaths.configBindingRedirect, nsmgr);
                if (nodes.Count > 0)
                {
                    OutputMessages.AddWarningMessage("GenerateManifest.ConfigBindingRedirectsWithPartialTrust");
                }
            }
        }
예제 #3
0
 private void ResolveFiles_2(string[] searchPaths)
 {
     if (_fileReferences != null)
     {
         foreach (FileReference f in _fileReferences)
         {
             if (!ResolveFile(f, searchPaths))
             {
                 // When we're only reading a manifest (i.e. from ResolveNativeReference task), it's
                 // very useful to report what manifest has the unresolvable reference. However, when
                 // we're generating a new manifest (i.e. from GenerateApplicationManifest task)
                 // reporting the manifest is awkward and sometimes looks like a bug.
                 // So we use the ReadOnly flag to tell the difference between the two cases...
                 if (_readOnly)
                 {
                     OutputMessages.AddErrorMessage("GenerateManifest.ResolveFailedInReadOnlyMode", f.ToString(), this.ToString());
                 }
                 else
                 {
                     OutputMessages.AddErrorMessage("GenerateManifest.ResolveFailedInReadWriteMode", f.ToString());
                 }
             }
         }
     }
 }
예제 #4
0
        private async void GetReactionsCommand()
        {
            ReactionList.Clear();
            List <ReactionInfo> tmp = new List <ReactionInfo>();

            if (Mode == "my")
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Loading " + CurrentUser + "'s reaction(s)...", Level = ""
                });
                _logService.Write(this, "Loading " + CurrentUser + "'s reaction(s)...", "debug");
                tmp = await _dbService.GetReactions(Person);
            }
            else
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Loading all reaction(s)...", Level = ""
                });
                _logService.Write(this, "Loading all reaction(s)...", "debug");
                tmp = await _dbService.GetReactions();
            }
            OutputMessages.Add(new OutputMessage {
                Message = tmp.Count + " reaction(s) loaded!", Level = ""
            });
            _logService.Write(this, tmp.Count + " reaction(s) loaded", "debug");
            foreach (var item in tmp)
            {
                ReactionList.Add(item);
            }
        }
예제 #5
0
 public void Alive()
 {
     if (!this.IsAlive)
     {
         throw new InvalidOperationException(OutputMessages.DeadCharacter());
     }
 }
예제 #6
0
 internal static void ValidateCharacter(Character character, string name)
 {
     if (character == null)
     {
         throw new ArgumentException(string.Format(OutputMessages.CharacterNotFound(), name));
     }
 }
예제 #7
0
 internal static void CanHeal(Character character)
 {
     if (character.GetType().Name != "Cleric")
     {
         throw new ArgumentException(string.Format(OutputMessages.CantHeal(), character.Name));
     }
 }
예제 #8
0
 internal static void CanAttack(Character character)
 {
     if (character.GetType().Name != "Warrior")
     {
         throw new ArgumentException(string.Format(OutputMessages.CantAttack(), character.Name));
     }
 }
예제 #9
0
 private void ValidateDeploymentProvider()
 {
     if (!String.IsNullOrEmpty(_deploymentUrl) && PathUtil.IsLocalPath(_deploymentUrl))
     {
         OutputMessages.AddWarningMessage("GenerateManifest.InvalidDeploymentProvider");
     }
 }
예제 #10
0
        private async void GetProjectsCommand()
        {
            ProjectList.Clear();
            List <Project> tmp = new List <Project>();

            if (Mode == "my")
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Loading " + CurrentUser + "'s project(s)...", Level = "debug"
                });
                _logService.Write(this, "Loading " + CurrentUser + "'s project(s)...", "debug");
                tmp = await _dbService.GetProjects(Person);
            }
            else
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Loading all project(s)...", Level = "debug"
                });
                _logService.Write(this, "Loading all project(s)...", "debug");
                tmp = await _dbService.GetProjects();
            }
            OutputMessages.Add(new OutputMessage {
                Message = tmp.Count + " project(s) loaded!", Level = "debug"
            });
            _logService.Write(this, tmp.Count + " project(s) loaded", "debug");
            foreach (var item in tmp)
            {
                ProjectList.Add(item);
            }
        }
예제 #11
0
 private void SaveProjectCommand()
 {
     _dbService.UpdateProject(_project.ProjectID, ProjectName, Leader, Goal, Description, NewProjectPlan);
     _logService.Write(this, "Project modified", "debug");
     OutputMessages.Add(new OutputMessage {
         Message = "Project modified!", Level = ""
     });
 }
예제 #12
0
        /// <summary>
        /// Creates a request object from the command line arguments.
        /// </summary>
        /// <param name="pOptions">The parser options.</param>
        /// <param name="pArgs">The command line arguments.</param>
        /// <param name="pDescs">Argument descriptions.</param>
        /// <param name="pOutput">Factory for handling output.</param>
        /// <returns></returns>
        public static Request Create(CliOptions pOptions, IEnumerable <string> pArgs, IEnumerable <Description> pDescs,
                                     iOutputFactory pOutput)
        {
            iOutputStream  outputStream   = pOutput.Create();
            OutputMessages outputMessages = new OutputMessages(pOptions, outputStream);
            Validator      validator      = new Validator(outputMessages);

            return(Create(pOptions, validator, pArgs, pDescs.ToList()));
        }
예제 #13
0
 private static string getError(OutputMessages pMessages, Description pDescription, eERROR pError)
 {
     using (StringWriter sw = new StringWriter())
     {
         Console.SetError(sw);
         pMessages.Error(pDescription, pError);
         return(sw.ToString().Trim());
     }
 }
예제 #14
0
        public string AddItemToPool(string[] args)
        {
            string itemName = args[0];
            var    item     = ItemFactory.CreateItem(itemName);

            itemPool.Push(item);

            return(string.Format(OutputMessages.ItemAddedToPool(), itemName));
        }
예제 #15
0
파일: Node.cs 프로젝트: beno11224/SNNLib
        public override void Spike(int time, double val = 1)
        {
            if (CurrentlyTraining)
            {
                OutputMessages.Add(new OutputMessage(time, new SynapseObject(this, null), val));
            }

            messageHandler.addMessage(new OutputMessage(time + Delay, new SynapseObject(this, null), val));
        }
예제 #16
0
 protected void ValidatePlatform()
 {
     foreach (AssemblyReference assembly in AssemblyReferences)
     {
         if (IsMismatchedPlatform(assembly))
         {
             OutputMessages.AddWarningMessage("GenerateManifest.PlatformMismatch", assembly.ToString());
         }
     }
 }
예제 #17
0
 private void ValidateReferencesForNativeApplication()
 {
     foreach (AssemblyReference assembly in AssemblyReferences)
     {
         // Check that the assembly identity matches the filename for all local dependencies...
         if (!assembly.IsPrerequisite && !String.Equals(assembly.AssemblyIdentity.Name, Path.GetFileNameWithoutExtension(assembly.TargetPath), StringComparison.OrdinalIgnoreCase))
         {
             OutputMessages.AddErrorMessage("GenerateManifest.IdentityFileNameMismatch", assembly.ToString(), assembly.AssemblyIdentity.Name, assembly.AssemblyIdentity.Name + Path.GetExtension(assembly.TargetPath));
         }
     }
 }
예제 #18
0
 private void ValidateEntryPoint()
 {
     if (_entryPoint != null)
     {
         bool isCorrectFileType = !String.IsNullOrEmpty(_entryPoint.TargetPath) && _entryPoint.TargetPath.EndsWith(".exe", StringComparison.OrdinalIgnoreCase);
         if (!isCorrectFileType)
         {
             OutputMessages.AddErrorMessage("GenerateManifest.InvalidEntryPoint", _entryPoint.ToString());
         }
     }
 }
예제 #19
0
        private void ConfirmUserChangeCommand()
        {
            CurrentUser = SelectedUser;
            var myMessage = new NotificationMessage(SelectedUser);

            Messenger.Default.Send(myMessage);
            OutputMessages.Add(new OutputMessage {
                Message = "Current user set to: " + CurrentUser, Level = "debug"
            });
            _loggerService.Write(this, "Current user set to: " + CurrentUser, "debug");
        }
예제 #20
0
        internal static Faction ValidateFaction(string faction)
        {
            bool result = Enum.TryParse(typeof(Faction), faction, out object factionObj);

            if (!result)
            {
                throw new ArgumentException(string.Format(OutputMessages.InvalidWeatherType(), faction));
            }

            return((Faction)factionObj);
        }
예제 #21
0
 private void AddProjectCommand()
 {
     if (Validate())
     {
         _dbService.AddProject(_ProjectInfo);
         OutputMessages.Add(new OutputMessage {
             Message = ProjectName + " added!", Level = "debug"
         });
         _logService.Write(this, ProjectName + " added", "debug");
     }
 }
예제 #22
0
        public string JoinParty(string[] args)
        {
            string faction       = args[0];
            string characterType = args[1];
            string name          = args[2];

            var character = CharacterFactory.CreateCharacter(faction, characterType, name);

            party.Add(character);
            return(string.Format(OutputMessages.JoinedParty(), name));
        }
예제 #23
0
        private void SelectObservationImgCommand()
        {
            var resu = _openFileDialogService.ShowOpenFileDialog();

            ObservationImgsFilePaths.Add(resu);
            OutputMessages.Add(new OutputMessage()
            {
                Message = resu + " added as Observation Img", Level = "debug"
            });
            _logService.Write(this, resu + " added as Observation Img", "debug");
        }
예제 #24
0
        public void Heal(Character character)
        {
            this.Alive();
            character.Alive();

            if (this.Faction != character.Faction)
            {
                throw new InvalidOperationException(OutputMessages.DifferentFaction());
            }

            character.HealCharacter(this.AbilityPoints);
        }
예제 #25
0
 private void ValidateMinimumRequiredVersion()
 {
     if (!String.IsNullOrEmpty(_minimumRequiredVersion))
     {
         Version v1 = new Version(_minimumRequiredVersion);
         Version v2 = new Version(AssemblyIdentity.Version);
         if (v1 > v2)
         {
             OutputMessages.AddErrorMessage("GenerateManifest.GreaterMinimumRequiredVersion");
         }
     }
 }
예제 #26
0
        public void Error_1()
        {
            MockOutput     mock   = new MockOutput();
            OutputMessages output = new OutputMessages(CliOptions.WindowsStyle, mock);

            Description desc = new Description("width", "The rectangle width", eROLE.NAMED, new ParamString(),
                                               eSCOPE.REQUIRED,
                                               eMULTIPLICITY.ONCE);

            const eERROR unsupported = (eERROR)(-1);

            output.Error(desc, unsupported);
        }
예제 #27
0
        private void ExplicitModifyCommand()
        {
            double tmp;

            if (Double.TryParse(ModifyAmount, out tmp))
            {
                if (tmp < 0)
                {
                    OutputMessages.Add(new OutputMessage {
                        Message = "Amount cannot be negative!", Level = "error"
                    });
                    _logService.Write(this, "Amount cannot be negative!", "error");
                }
                else
                {
                    if (Selected.mAvailable.HasValue)
                    {
                        Selected.mAvailable = tmp;
                        RaisePropertyChanged(nameof(Selected));
                        _logService.Write(this, "Update inventory with: " + Selected.CAS + " " + Selected.Location + " " + tmp + " " + null, "debug");

                        _dbService.ModifyMoleculeAvailable(Selected.CAS, Selected.Location, tmp, null);
                        OutputMessages.Add(new OutputMessage {
                            Message = "Inventory updated!", Level = ""
                        });
                        _logService.Write(this, "Inventory updated!", "debug");
                    }
                    else
                    {
                        Selected.VAvailable = tmp;
                        RaisePropertyChanged(nameof(Selected));
                        _logService.Write(this, "Update inventory with: " + Selected.CAS + " " + Selected.Location + " " + null + " " + tmp, "debug");

                        _dbService.ModifyMoleculeAvailable(Selected.CAS, Selected.Location, null, tmp);
                        OutputMessages.Add(new OutputMessage {
                            Message = "Inventory updated!", Level = ""
                        });
                        _logService.Write(this, "Inventory updated!", "debug");
                    }
                }
            }
            else
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Cannot convert given value to number", Level = "error"
                });
                _logService.Write(this, "Cannot convert given value to number", "error");
            }
        }
예제 #28
0
        public void Attack(Character character)
        {
            this.Alive();
            character.Alive();
            if (character == this)
            {
                throw new InvalidOperationException(OutputMessages.CantAttackSelf());
            }
            if (character.Faction == this.Faction)
            {
                throw new ArgumentException(string.Format(OutputMessages.SameFaction(), this.Faction));
            }

            character.TakeDamage(this.AbilityPoints);
        }
예제 #29
0
        private async void SaveReactionCommandAsync()
        {
            OutputMessages.Add(new OutputMessage()
            {
                Message = "Saving to database", Level = "debug"
            });
            _logService.Write(this, "Saving to database", "debug");
            await _dbService.FinishSketchReaction(_reactionId, ClosureDate, Procedure, Observation, Yield, ObservationImgsFilePaths.ToList());

            OutputMessages.Add(new OutputMessage()
            {
                Message = "Finished!", Level = "debug"
            });
            _logService.Write(this, "Finished", "debug");
        }
예제 #30
0
        public string UseItem(string[] args)
        {
            string characterName = args[0];
            string itemName      = args[1];

            var character = party.FirstOrDefault(x => x.Name == characterName);

            Validate.ValidateCharacter(character, characterName);

            Item item = character.Bag.GetItem(itemName);

            character.UseItem(item);

            return(string.Format(OutputMessages.ItemUsed(), character.Name, itemName));
        }
예제 #31
0
        public override bool Validate(PatternSettings settings, OutputMessages output)
        {
            bool hasErrors = false;
            PatternInstanceElement grid = settings.PatternPart.SelectSingleElement("//Grid");
            String customrender = grid.Attributes.GetPropertyValueString(SettingsAttributes.Grid.CustomRender);

            ControlDefinition control = null;

            if (!String.IsNullOrEmpty(customrender))
            {
                control = Controls.getControl(customrender);
            }

            foreach (PatternInstanceElement gridprop in settings.PatternPart.SelectElements("//GridPropertie"))
            {
                if (control == null)
                {
                    output.Add(new OutputError("Invalid CustomRender: ", new PatternElementPosition(gridprop)));
                    hasErrors = true;
                }
                else
                {

                    String nome = gridprop.Attributes.GetPropertyValueString(SettingsAttributes.GridPropertie.Name);
                    String valor = gridprop.Attributes.GetPropertyValueString(SettingsAttributes.GridPropertie.Valor);

                    PropDefinition p = control.GetPropertiesDefinition().GetPropDefinition(nome);
                    if (p != null)
                    {
                        try
                        {
                            p.PropertyConverter.ConvertFrom(valor);
                        }
                        catch (Exception e)
                        {
                            output.Add(new OutputError("Property: " + nome + " - " + e.Message, new PatternElementPosition(gridprop)));
                            hasErrors = true;
                        }
                    }
                }
            }

            if (!hasErrors)
            {
                PatternInstanceElement saction = settings.PatternPart.SelectSingleElement("//StandardActions");
                Object oLegendObject = saction.Attributes.GetPropertyValue(SettingsAttributes.StandardActions.LegendObject);

                PatternInstanceElement actLegend = settings.PatternPart.SelectSingleElement("//StandardActions/Legend");
                Boolean oLegendEnabled = actLegend.Attributes.GetPropertyValue<Boolean>(SettingsAttributes.Action.DefaultMode);
                Boolean oLegendEnabledPrompt = actLegend.Attributes.GetPropertyValue<Boolean>(SettingsAttributes.Action.PromptMode);

                if ((oLegendEnabled || oLegendEnabledPrompt) && oLegendObject == null)
                {
                    output.Add(new OutputError("Legend Object Not Defined: ", new PatternElementPosition(saction)));
                    hasErrors = true;
                }

            }

            if (!hasErrors)
            {
                PatternInstanceElement template = settings.PatternPart.SelectSingleElement("//Template");
                String tabfunction = template.Attributes.GetPropertyValueString(SettingsAttributes.Template.TabFunction);
                tabfunction = Controls.getTabUserControl(tabfunction);

                ControlDefinition controltab = null;

                if (!String.IsNullOrEmpty(tabfunction))
                {
                    controltab = Controls.getControl(tabfunction, null);
                }

                foreach (PatternInstanceElement tabprop in settings.PatternPart.SelectElements("//TabProperty"))
                {
                    if (controltab == null)
                    {
                        output.Add(new OutputError("Invalid UserControl Property: ", new PatternElementPosition(tabprop)));
                        hasErrors = true;
                    }
                    else
                    {

                        String nome = tabprop.Attributes.GetPropertyValueString(SettingsAttributes.TabProperty.Name);
                        String valor = tabprop.Attributes.GetPropertyValueString(SettingsAttributes.TabProperty.Valor);

                        PropDefinition p = controltab.GetPropertiesDefinition().GetPropDefinition(nome);
                        if (p != null)
                        {
                            try
                            {
                                p.PropertyConverter.ConvertFrom(valor);
                            }
                            catch (Exception e)
                            {
                                output.Add(new OutputError("Property: " + nome + " - " + e.Message, new PatternElementPosition(tabprop)));
                                hasErrors = true;
                            }
                        }
                    }
                }

            }

            return !hasErrors;
        }
예제 #32
0
        public override bool Validate(PatternInstance instance, OutputMessages output)
        {
            bool hasErrors = false;
            foreach (PatternInstanceElement actionElement in instance.PatternPart.SelectElements("//actions/action"))
            {
                PatternInstanceElement container = actionElement.Parent.Parent;
                Debug.Assert(container != null && (container.Type == InstanceElements.Transaction || container.Type == InstanceElements.Selection || container.Type == InstanceElements.Tab || container.Type == InstanceElements.WebPanelRoot || container.Type == InstanceElements.Prompt));

                if (container != null)
                {
                    bool cannotHaveInGrid = (container.Type == InstanceElements.Tab && container.Attributes.GetPropertyValue<string>(InstanceAttributes.Tab.Type) == TabElement.TypeValue.Tabular);
                    bool isInGrid = actionElement.Attributes.GetPropertyValue<bool>(InstanceAttributes.Action.InGrid);

                    if (isInGrid && cannotHaveInGrid)
                    {
                        output.Add(new OutputError(Messages.FormatValidationErrorActionCannotBeInGrid(actionElement.ToString()), new PatternElementPosition(actionElement)));
                        hasErrors = true;
                    }
                }
            }
            if (!hasErrors)
            {
                if (instance.Parent is Transaction)
                {
                    if (instance.PatternPart.SelectSingleElement("instance/transaction") == null)
                    {
                        output.Add(new OutputError("Não é permitido excluir o nó Transaction"));
                        hasErrors = true;
                    } else if (instance.PatternPart.SelectSingleElement("instance/webPanelRoot") != null)
                    {
                        output.Add(new OutputError("Não é permitido o nó WebPanel na Transação"));
                        hasErrors = true;
                    }
                }
            }
            if (!hasErrors)
            {
                if (instance.Parent is WebPanel)
                {
                    if (instance.PatternPart.SelectSingleElement("instance/webPanelRoot") == null)
                    {
                        output.Add(new OutputError("Não é permitido excluir o nó WebPanel"));
                        hasErrors = true;
                    }
                    else if (instance.PatternPart.SelectSingleElement("instance/transaction") != null)
                    {
                        output.Add(new OutputError("Não é permitido o nó Transaction no WebPanel"));
                        hasErrors = true;
                    }
                }
            }

            if (!hasErrors)
            {
                foreach (PatternInstanceElement tabElement in instance.PatternPart.SelectElements("tab"))
                {
                    string nome = tabElement.Attributes.GetPropertyValueString(InstanceAttributes.TabForm.Name);
                    string desc = tabElement.Attributes.GetPropertyValueString(InstanceAttributes.TabForm.Description);
                    if (!Variable.IsValidName(nome))
                    {
                        output.Add(new OutputError(String.Format("Caracter inválido no nome da Aba: '{0}', Descrição: {1} ",nome,desc)));
                        hasErrors = true;
                    }
                }
            }

            if (!hasErrors)
            {
                foreach (PatternInstanceElement gridprop in instance.PatternPart.SelectElements("//GridPropertie"))
                {
                    String nome = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridPropertie.Name);
                    String valor = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridPropertie.Valor);

                    String nomeControl = Controls.getCustomRender(gridprop);
                    ControlDefinition control = Controls.getControl(nomeControl);

                    if (control == null)
                    {
                        output.Add(new OutputError("Invalid CustomRender: ", new PatternElementPosition(gridprop)));
                        hasErrors = true;
                    }
                    else
                    {

                        PropDefinition p = control.GetPropertiesDefinition().GetPropDefinition(nome);
                        if (p != null)
                        {
                            try
                            {
                                p.PropertyConverter.ConvertFrom(valor);
                            }
                            catch (Exception e)
                            {
                                output.Add(new OutputError("Property: " + nome + " - " + e.Message, new PatternElementPosition(gridprop)));
                                hasErrors = true;
                            }
                        }
                    }
                }
            }

            if (!hasErrors)
            {

                foreach (PatternInstanceElement gridprop in instance.PatternPart.SelectElements("//GridColumnPropertie"))
                {
                    String nome = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridColumnPropertie.Name);
                    String valor = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridColumnPropertie.Valor);

                    String nomeControl = Controls.getCustomRender(gridprop);
                    ControlDefinition control = Controls.getControl(nomeControl);

                    if (control == null)
                    {

                        output.Add(new OutputError("Invalid CustomRender: ", new PatternElementPosition(gridprop)));
                        hasErrors = true;
                    }
                    else
                    {

                        PropDefinition p = control.GetColumnPropertiesDefinition().GetPropDefinition(nome);
                        if (p != null)
                        {
                            try
                            {
                                p.PropertyConverter.ConvertFrom(valor);
                            }
                            catch (Exception e)
                            {
                                output.Add(new OutputError("Column Property: " + nome + " - " + e.Message, new PatternElementPosition(gridprop)));
                                hasErrors = true;
                            }
                        }
                    }
                }
            }

            // TODO não permtir textblock no form com o nome internalname duplicado

            return !hasErrors;
        }