Exemple #1
0
        public JsonResult SaveEvent(Event e)
        {
            var status = false;

            using (Model5 dc = new Model5())
            {
                if (e.EventID > 0)
                {
                    //Update the event
                    var v = dc.Events.Where(a => a.EventID == e.EventID).FirstOrDefault();
                    if (v != null)
                    {
                        v.Subject     = e.Subject;
                        v.Start       = e.Start;
                        v.End         = e.End;
                        v.Description = e.Description;
                        v.IsFullDay   = e.IsFullDay;
                        v.ThemeColor  = e.ThemeColor;
                    }
                }
                else
                {
                    dc.Events.Add(e);
                }

                dc.SaveChanges();
                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Exemple #2
0
        public void FinderulesInStaticMethods()
        {
            var model    = new Model5();
            var property = model.GetType().GetProperty(nameof(model.Text));
            var rules    = this.sut.GetRulesForProperty(model.GetType(), property, RuleType.Default);

            Assert.IsNotNull(rules);
            Assert.IsTrue(rules.Any());
        }
Exemple #3
0
 public JsonResult GetEvents()
 {
     using (Model5 dc = new Model5())
     {
         var events = dc.Events.ToList();
         return(new JsonResult {
             Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet
         });
     }
 }
Exemple #4
0
        public void SingleModel_WithReadonlyAndNonReadWriteProperties_ShouldReturnCorrectValue()
        {
            //arrange
            var modelContainerTarget = Target.The("Model container").LocatedBy(By.ClassName("model1"));
            var question             = UIModel.Of <Model5>(modelContainerTarget).WithCulture(CultureInfo.GetCultureInfo("en-US"));
            //act
            var actual = Answer(question);
            //assert
            var expected = new Model5(1)
            {
                Boolean = true,
                Title   = "The title"
            };

            actual.Should().BeEquivalentTo(expected);
        }
Exemple #5
0
        public JsonResult DeleteEvent(int eventID)
        {
            var status = false;

            using (Model5 dc = new Model5())
            {
                var v = dc.Events.Where(a => a.EventID == eventID).FirstOrDefault();
                if (v != null)
                {
                    dc.Events.Remove(v);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Exemple #6
0
        public void ShouldMapNullableValueList()
        {
            var data = new Model5
            {
                InnerList = new List <int> {
                    1, 2, 3
                }
            };
            var mapper = new ObjectMapper <Model5, Dto5>();

            mapper.AppendCollection(p => p.InnerList, p => p.InnerList.Select(item => (int?)item).AsQueryable());

            var target = data.Map(mapper);

            target.Should().BeEquivalentTo(new Dto5()
            {
                InnerList = new int?[] { 1, 2, 3 }
            });
        }
        public async Task RetryWaitForAcknowledge()
        {
            Registrar   registrar = new Registrar();
            TestHorseMq server    = new TestHorseMq();

            server.SendAcknowledgeFromMQ = false;
            await server.Initialize();

            int port = server.Start(300, 300);

            HmqStickyConnector producer = new HmqAbsoluteConnector(TimeSpan.FromSeconds(10));

            producer.AddHost("hmq://localhost:" + port);
            producer.Run();

            HmqStickyConnector consumer = new HmqAbsoluteConnector(TimeSpan.FromSeconds(10));

            consumer.AddHost("hmq://localhost:" + port);
            registrar.Register(consumer);
            consumer.Run();

            await Task.Delay(500);

            Assert.True(producer.IsConnected);
            Assert.True(consumer.IsConnected);

            Model5 model = new Model5();

            Stopwatch sw = new Stopwatch();

            sw.Start();
            HorseResult push = await producer.Bus.Queue.PushJson(model, true);

            sw.Stop();

            Assert.Equal(HorseResultCode.Failed, push.Code);
            Assert.Equal(5, QueueConsumer5.Instance.Count);

            //5 times with 50 ms delay between them (5 tries, 4 delays)
            Assert.True(sw.ElapsedMilliseconds > 190);
        }
Exemple #8
0
        private static void Main()
        {
            var model = new Model5
            {
                Name  = "Hello",
                Child = new Model6
                {
                    Name  = "World",
                    Child = new Model7()
                },
                Children = new[]
                {
                    new Model8()
                }
            };

            var validator = new DryvValidator();
            var errors    = validator.Validate(model);

            foreach (var error in errors)
            {
                Console.WriteLine(error);
            }
        }
Exemple #9
0
 public OurChefDao()
 {
     db = new Model5();
 }
        public void TestCopyValue()
        {
            var m1 = new Model1
            {
                P1 = "P1",
                P2 = "P2",
                P3 = "P3",
                P4 = "P4",
                P5 = "P5",
                P6 = 6,
                PP = "P7",
                P8 = new Model3
                {
                    P1 = "P3-P1"
                },
                P9 = new List <Model4> {
                    new Model4 {
                        P1 = "1-P4-P1"
                    },
                    new Model4 {
                        P1 = "2-P4-P1"
                    }
                },
                P10 = 10
            };

            // Verifies that pass a null object
            Assert.Throws <ArgumentNullException>(() =>
            {
                m1.CopyValueTo(null);
            });

            // Verifies that set value between different type
            var m2 = new Model2
            {
                P1 = -10
            };

            Assert.Throws <InvalidTypeConvertedException>(() =>
            {
                m1.CopyValueTo(m2);
            });

            // Verifies that successful
            var m3 = new Model3
            {
                p5 = "-p5"
            };

            m1.CopyValueTo(m3);
            Assert.Equal("P1", m3.P1);
            Assert.Equal("P2", m3.P2);
            Assert.Equal("P3", m3.P3);
            Assert.Equal("-p5", m3.p5);
            Assert.Equal(6, m3.P6);
            Assert.Null(m3.P7);

            // Verifies that ignore case
            m1.CopyValueTo(target: m3, stringComparison: StringComparison.CurrentCultureIgnoreCase);
            Assert.Equal("P5", m3.p5);

            // Verifies that ignore property
            m3 = new Model3();
            m1.CopyValueTo(target: m3, ignorePropertyNames: new string[] { "P1", "P2" });
            Assert.Null(m3.P1);
            Assert.Null(m3.P2);

            // Verifies that ignore property
            m3 = new Model3();
            var map = new Dictionary <string, string>();

            map.Add("PP", "P7");
            m1.CopyValueTo(target: m3, propertyMap: map);
            Assert.Equal("P7", m3.P7);

            // Verifies that throw MultipleResultException if ignore case
            var m4 = new Model4();

            Assert.Throws <MultipleResultException>(() =>
            {
                m1.CopyValueTo(target: m4, stringComparison: StringComparison.CurrentCultureIgnoreCase);
            });

            // Verifies that copy value type and ref type
            var m5 = new Model5();

            m1.CopyValueTo(m5, ignoreRefType: false);
            Assert.True(m1.P8 == m5.P8);
            Assert.True(m1.P9 == m5.P9);
            Assert.True(m1.P10.ToString() == m5.P10.ToString());

            // Verifies that ignore ref type
            m5 = new Model5();
            m1.CopyValueTo(m5);
            Assert.Null(m5.P8);
            Assert.Null(m5.P9);
            Assert.Equal(0, m5.P10);

            // Verifies that force property names
            m5 = new Model5();
            m1.CopyValueTo(m5, forcePropertyNames: new string[] { "P10" });
            Assert.Null(m5.P8);
            Assert.Null(m5.P9);
            Assert.Equal(10, m5.P10);
        }
Exemple #11
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="idrule"></param>
        /// <param name="body"> (optional)</param>
        /// <returns>Task of ApiResponse (string)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <string> > PostExecuteV1RuleIdruleAsyncWithHttpInfo(string idrule, Model5 body = null)
        {
            // verify the required parameter 'idrule' is set
            if (idrule == null)
            {
                throw new ApiException(400, "Missing required parameter 'idrule' when calling ExecuteApi->PostExecuteV1RuleIdrule");
            }

            var    localVarPath         = "/execute/v1/rule/{idrule}";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
            };
            String localVarHttpContentType    = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
            };
            String localVarHttpHeaderAccept    = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (idrule != null)
            {
                localVarPathParams.Add("idrule", this.Configuration.ApiClient.ParameterToString(idrule));                 // path parameter
            }
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("PostExecuteV1RuleIdrule", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <string>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                            (string)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(string))));
        }
Exemple #12
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="idrule"></param>
        /// <param name="body"> (optional)</param>
        /// <returns>Task of string</returns>
        public async System.Threading.Tasks.Task <string> PostExecuteV1RuleIdruleAsync(string idrule, Model5 body = null)
        {
            ApiResponse <string> localVarResponse = await PostExecuteV1RuleIdruleAsyncWithHttpInfo(idrule, body);

            return(localVarResponse.Data);
        }
Exemple #13
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="idrule"></param>
        /// <param name="body"> (optional)</param>
        /// <returns>string</returns>
        public string PostExecuteV1RuleIdrule(string idrule, Model5 body = null)
        {
            ApiResponse <string> localVarResponse = PostExecuteV1RuleIdruleWithHttpInfo(idrule, body);

            return(localVarResponse.Data);
        }
Exemple #14
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="domain"></param>
        /// <param name="key"></param>
        /// <param name="body"> (optional)</param>
        /// <returns>Task of string</returns>
        public async System.Threading.Tasks.Task <string> PostExecuteV1LocalDomainKeyAsync(string domain, string key, Model5 body = null)
        {
            ApiResponse <string> localVarResponse = await PostExecuteV1LocalDomainKeyAsyncWithHttpInfo(domain, key, body);

            return(localVarResponse.Data);
        }
Exemple #15
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="domain"></param>
        /// <param name="key"></param>
        /// <param name="body"> (optional)</param>
        /// <returns>ApiResponse of string</returns>
        public ApiResponse <string> PostExecuteV1LocalDomainKeyWithHttpInfo(string domain, string key, Model5 body = null)
        {
            // verify the required parameter 'domain' is set
            if (domain == null)
            {
                throw new ApiException(400, "Missing required parameter 'domain' when calling ExecuteApi->PostExecuteV1LocalDomainKey");
            }
            // verify the required parameter 'key' is set
            if (key == null)
            {
                throw new ApiException(400, "Missing required parameter 'key' when calling ExecuteApi->PostExecuteV1LocalDomainKey");
            }

            var    localVarPath         = "/execute/v1/local/{domain}/{key}";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
            };
            String localVarHttpContentType    = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
            };
            String localVarHttpHeaderAccept    = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (domain != null)
            {
                localVarPathParams.Add("domain", this.Configuration.ApiClient.ParameterToString(domain));                 // path parameter
            }
            if (key != null)
            {
                localVarPathParams.Add("key", this.Configuration.ApiClient.ParameterToString(key));              // path parameter
            }
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)this.Configuration.ApiClient.CallApi(localVarPath,
                                                                                                 Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                 localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("PostExecuteV1LocalDomainKey", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <string>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                            (string)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(string))));
        }
Exemple #16
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="domain"></param>
        /// <param name="key"></param>
        /// <param name="body"> (optional)</param>
        /// <returns>string</returns>
        public string PostExecuteV1LocalDomainKey(string domain, string key, Model5 body = null)
        {
            ApiResponse <string> localVarResponse = PostExecuteV1LocalDomainKeyWithHttpInfo(domain, key, body);

            return(localVarResponse.Data);
        }
        public void AttachModelList(List <Object3D> objs)
        {
            for (int i = 0; i < objs.Count; ++i)
            {
                var ob        = objs[i];
                var vertColor = new Color4((float)i / objs.Count, 0, 1 - (float)i / objs.Count, 1);
                ob.Geometry.Colors = new HelixToolkit.Wpf.SharpDX.Core.Color4Collection(Enumerable.Repeat(vertColor, ob.Geometry.Positions.Count));
                ob.Geometry.UpdateOctree();
                ob.Geometry.UpdateBounds();

                context.Post((o) =>
                {
                    var scaleTransform = new Media3D.ScaleTransform3D(15, 15, 15);
                    var s = new MeshGeometryModel3D
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Transform        = scaleTransform
                    };

                    var diffuseMaterial     = new DiffuseMaterial();
                    PBRMaterial pbrMaterial = null;
                    if (ob.Material is PhongMaterialCore p)
                    {
                        var phong = p.ConvertToPhongMaterial();
                        phong.RenderEnvironmentMap   = true;
                        phong.RenderShadowMap        = true;
                        phong.RenderSpecularColorMap = false;
                        s.Material = phong;
                        diffuseMaterial.DiffuseColor = p.DiffuseColor;
                        diffuseMaterial.DiffuseMap   = p.DiffuseMap;
                        pbrMaterial = new PBRMaterial()
                        {
                            AlbedoColor          = p.DiffuseColor,
                            AlbedoMap            = p.DiffuseMap,
                            NormalMap            = p.NormalMap,
                            RMAMap               = p.SpecularColorMap,
                            RenderShadowMap      = true,
                            RenderEnvironmentMap = true,
                        };
                    }
                    //if (ob.Transform != null && ob.Transform.Count > 0)
                    //{
                    //    s.Instances = ob.Transform;
                    //}
                    this.Model1.Add(s);

                    Model2.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = NormalMaterial,
                        Transform        = scaleTransform
                    });

                    ModelNormalVector.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = NormalVectorMaterial,
                        Transform        = scaleTransform
                    });
                    Model3.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = diffuseMaterial,
                        Transform        = scaleTransform
                    });

                    Model4.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = PositionMaterial,
                        Transform        = scaleTransform
                    });

                    Model5.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = VertMaterial,
                        Transform        = scaleTransform
                    });

                    Model6.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = ColorStripeMaterial,
                        Transform        = scaleTransform
                    });

                    Model7.Add(new MeshGeometryModel3D
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Transform        = scaleTransform,
                        Material         = pbrMaterial
                    });
                }, null);
            }
        }
Exemple #18
0
 public ActionResult Example5(Model5 model) => this.View("example5.partial", model);