예제 #1
0
            public TextCell(IValueResult result)
            {
                Text = Escape(result.Value);

                if (result.VerificationStatus != ParameterVerificationStatus.NotApplicable &&
                    result.VerificationStatus != ParameterVerificationStatus.Success)
                {
                    Text += "/" + Escape(result.Expectation);
                }
            }
예제 #2
0
        public static int Main(string[] args)
        {
            // hook API logger
            Logger.SetLogSink(HandleLogEntry);

            try
            {
                string ncHostname = "JoshVM-2003";
                int    ncPort     = 80;

                using (IServerSession ncSession = CSAPI.Create().CreateServerSession(ncHostname, ncPort))
                {
                    if (!Authenticate(ncSession))
                    {
                        return(-1);
                    }

                    // read all Content objects from server
                    Console.Write("Reading content objects...");
                    using (IValueResult <IModelCollection <IContent> > readResult = ncSession.DataAccess.Brokers.Content.Read(ncSession.ModelFactory.CreateAllSelector(), null))
                    {
                        if (readResult.IsSuccess)
                        {
                            Console.WriteLine("success");
                            Console.WriteLine("Found {0} content objects", readResult.Value.Count);
                            Console.WriteLine("[");
                            foreach (IContent content in readResult.Value.Items)
                            {
                                Console.WriteLine("  {{Name=\"{0}\", Id=\"{1}\"}}", content.Name, content.Id);
                            }
                            Console.WriteLine("]");
                        }
                        else
                        {
                            Console.WriteLine("failed: " + readResult.ToString());
                            return(-2);
                        }
                    }
                }

                return(0);
            }
            finally
            {
                Console.WriteLine("Press enter to continue...");
                Console.ReadLine();

                // unhook logger
                Logger.SetLogSink(null);
            }
        }
예제 #3
0
        private static IHtmlNode GetRowValue(IValueResult value)
        {
            var tag = Html.Tag(Html5Tag.Td).Class("param value " + value.VerificationStatus.ToString().ToLowerInvariant());

            if (value.VerificationStatus == ParameterVerificationStatus.NotApplicable ||
                value.VerificationStatus == ParameterVerificationStatus.Success)
            {
                return(tag.Content(value.Value));
            }

            return(tag.Content(Html.Tag(Html5Tag.Div).Content(
                                   Html.Text(value.Value).Escape(),
                                   Html.Tag(Html5Tag.Hr),
                                   Html.Tag(Html5Tag.Span).Class("expected").Content(value.Expectation))));
        }
예제 #4
0
        public async Task Execute()
        {
            Validate();

            var source = activator.Create(sourceType);

            Func <ISource, Task <IValueResult <object> > > recieve = s => s.RecieveAsync();

            IValueResult <object> recieved = await recieve(source as ISource);

            object value = recieved.Value;

            if (value == null)
            {
                throw new Exception("Empty source!");
            }

            foreach (var stagesType in stagesTypes)
            {
                var stage = activator.Create(stagesType);
                Func <IStage, Task <IValueResult <object> > > stageFunc = s => s.Execute(value);
                IValueResult <object> stageResult = await stageFunc((IStage)stage);

                value = stageResult.Value;
            }

            //for (int i = 0; i < stagesTypes.Count; i++)
            //{
            //    var stage = (IStage)activator.Create(stagesTypes[i]);
            //    var expression = expressions[i];
            //    var lambda =  Expression.Lambda<Func<IStage, object, Task<IValueResult<object>>>>(
            //        expression);

            //    value = lambda.Compile()(stage, value);
            //}

            var destination = (IDestination)activator.Create(destinationType);

            Func <IDestination, Task <IActionResult> > send = s => s.SendAsync(value);

            var completed = await send(destination);

            Console.WriteLine("Completed!");
        }
예제 #5
0
        private static XElement ToXElement(IValueResult valueResult, int?index = null)
        {
            var objects = new List <object>();

            if (index.HasValue)
            {
                objects.Add(new XAttribute("Index", index.Value));
            }
            objects.Add(ToXAttribute(valueResult.VerificationStatus));
            if (valueResult.Value != null)
            {
                objects.Add(new XAttribute("Value", valueResult.Value));
            }
            if (valueResult.Expectation != null)
            {
                objects.Add(new XAttribute("Expectation", valueResult.Expectation));
            }
            if (!string.IsNullOrWhiteSpace(valueResult.VerificationMessage))
            {
                objects.Add(new XAttribute("Message", valueResult.VerificationMessage));
            }
            return(new XElement("Value", objects));
        }