当前位置: 首页>>代码示例>>C#>>正文


C# Role.GetType方法代码示例

本文整理汇总了C#中Role.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Role.GetType方法的具体用法?C# Role.GetType怎么用?C# Role.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Role的用法示例。


在下文中一共展示了Role.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Run

        public static void Run()
        {
            var model = new Role();
            var properties = model.GetType().GetProperties().ToList();
            var dbtypes = properties.Select(pro => SqlServerExtentions.GetMatchedSqlType(pro.GetType())).ToList();


            var cnString = ConfigurationSettings.AppSettings["Connection"];
            var connection = new SqlConnection(cnString);

            var sql = @"
select * from Roles where RoleName = @roleName
select * from Departments where DepartmentName = @departName
";

            var tuples = connection.ExQuery<Role, Depart>(sql, new { roleName = "Root", departName = "HR" }.ExToDictionary());
            foreach (var role in tuples.Item1)
            {
                Console.WriteLine(role);
            }
            foreach (var depart in tuples.Item2)
            {
                Console.WriteLine(depart);
            }

            /*
            bool PlaceOrder(int userId, int productId, int count)
            {
                //Old use
                var user = connection.FindOne<User>("select * from Users where UserId = @id", new{ id = userId });
                if(user == null) return false;
                var project = connection.FindOne<Project>("select * from Products where ProductId = @id", new { id = projectId} );
                if(project == null) return false;
                var warehouse = connection.FindOne<Warehouse>("select * from Warehouses where ProjectId = @id" , new { id = projectId });
                if(warehouse.Count < count) return false;

                
                //New use
                var sql = @"
                    select * from Users where UserId = @userId
                    select * from Products where ProductId = @productId
                    select * from Warehouse where ProductId = @productId
                ";
                var items = connection.ExQuery<User, Project, Warehouse>(sql, new { userId, productId });
                if(items.Item1.Count <= 0 || items.Item2.Count <= 0 || items.Item3.Count <=0 || items.Item4.Count <= count) return false;
            }
            */

        }
开发者ID:Allen-Wei,项目名称:Alan.Utils,代码行数:49,代码来源:SqlServerExmple.cs

示例2: SetupPureAsyncAction

        private void SetupPureAsyncAction(VM vm)
        {
            
            mockProxy.Setup(x => x.auth_get_subject_information_from_identifier(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(new Response<object>(new Hashtable()));
            mockProxy.Setup(x => x.auth_get_group_membership(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(new Response<string[]>(new string[] { }));
            //Config roles
            Role role = new Role() { name_label = "pool-admin", subroles = new List<XenRef<Role>>() { new XenRef<Role>("2") } };
            cache.UpdateFrom(mockConnection.Object,
                             new List<ObjectChange>() { new ObjectChange(role.GetType(), "1", role) });

            mockConnection.Setup(x => x.Cache).Returns(cache);
            mockConnection.Setup(x => x.ResolveAll(It.IsAny<IEnumerable<XenRef<Role>>>()))
                .Returns(new List<Role>() { 
                    new Role() { name_label = "vmpp.archive_now" }
                    ,new Role() { name_label = "vm.destroy" }
                    ,new Role() { name_label = "vm.clean_shutdown" }
                    , new Role() { name_label = "task.add_to_other_config/key:xencenteruuid" }
                    , new Role() { name_label = "task.add_to_other_config/key:xencentermeddlingactiontitle" }
                    ,new Role(){name_label ="task.add_to_other_config/key:applies_to" }});
            mockConnection.Setup(x => x.HostnameWithPort).Returns("");
            var sessionMock = new Mock<Session>(mockProxy.Object, mockConnection.Object);
            sessionMock.Setup(x => x.IsLocalSuperuser).Returns(false);
            UserDetails.UpdateDetails("user1", sessionMock.Object);
            sessionMock.Setup(x => x.CurrentUserDetails).Returns(UserDetails.Sid_To_UserDetails["user1"]);
            mockConnection.Setup(x => x.Session).Returns(sessionMock.Object);

            TestXenAdminConfigProvider.MockSession = vm.Connection.Session;

        }
开发者ID:agimofcarmen,项目名称:xenadmin,代码行数:31,代码来源:PureAsyncActionTests.cs

示例3: SecurityUpdateRoleAsyncWithHttpInfo

        /// <summary>
        /// Add a new role or update an existing role 
        /// </summary>
        /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="role"></param>
        /// <returns>Task of ApiResponse (Role)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<Role>> SecurityUpdateRoleAsyncWithHttpInfo(Role role)
        {
            // verify the required parameter 'role' is set
            if (role == null)
                throw new ApiException(400, "Missing required parameter 'role' when calling VirtoCommercePlatformApi->SecurityUpdateRole");

            var localVarPath = "/api/platform/security/roles";
            var localVarPathParams = new Dictionary<string, string>();
            var localVarQueryParams = new Dictionary<string, string>();
            var localVarHeaderParams = new Dictionary<string, string>(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[] {
                "application/json", 
                "text/json", 
                "application/xml", 
                "text/xml", 
                "application/x-www-form-urlencoded"
            };
            string localVarHttpContentType = ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            string[] localVarHttpHeaderAccepts = new string[] {
                "application/json", 
                "text/json", 
                "application/xml", 
                "text/xml"
            };
            string localVarHttpHeaderAccept = ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
            if (localVarHttpHeaderAccept != null)
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (role.GetType() != typeof(byte[]))
            {
                localVarPostBody = ApiClient.Serialize(role); // http body (model) parameter
            }
            else
            {
                localVarPostBody = role; // byte array
            }


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

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (localVarStatusCode >= 400 && (localVarStatusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404))
                throw new ApiException(localVarStatusCode, "Error calling SecurityUpdateRole: " + localVarResponse.Content, localVarResponse.Content);
            else if (localVarStatusCode == 0)
                throw new ApiException(localVarStatusCode, "Error calling SecurityUpdateRole: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);

            return new ApiResponse<Role>(localVarStatusCode,
                localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (Role)ApiClient.Deserialize(localVarResponse, typeof(Role)));
            
        }
开发者ID:DaleCam,项目名称:vc-community,代码行数:71,代码来源:VirtoCommercePlatformApi.cs


注:本文中的Role.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。