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


C# User.GetType方法代码示例

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


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

示例1: SetAuthCookie

 public static void SetAuthCookie(IEngineContext context, User user)
 {
     var username = user.GetType().FullName + "_" + user.Id;
     FormsAuthentication.SetAuthCookie(username, true);
     context.CurrentUser = user;
     Thread.CurrentPrincipal = user;
 }
开发者ID:rlucassen,项目名称:RobtaPayment,代码行数:7,代码来源:AuthenticationHelper.cs

示例2: Gebruiker

 public static User Gebruiker(string gebruikersNaam)
 {
     User user = new User();
     //gebruikersnaam zetten via reflectie
     FieldInfo info = user.GetType().BaseType.GetField("userName", BindingFlags.Instance | BindingFlags.NonPublic);
     info.SetValue(user, gebruikersNaam);
     return Persist(user);
 }
开发者ID:auxilium,项目名称:JelloScrum,代码行数:8,代码来源:GebruikerCreation.cs

示例3: UserModel

        public UserModel(User user, bool isUserAuthenticated = false)
        {
            this.UserId = user.Id;
            this.Type = user.Type;
            this.PhoneNumber = user.PhoneNumber;
            this.PhoneNumberConfirmed = user.PhoneNumberConfirmed;
            this.Email = user.Email;
            this.EmailConfirmed = user.EmailConfirmed;
            this.Profile = user.GetType() == typeof(User) ? user.Profile : null;
            this.UserName = user.UserName;

            this.IsUserAuthenticated = isUserAuthenticated;
        }
开发者ID:NerdCats,项目名称:TaskCat,代码行数:13,代码来源:UserModel.cs

示例4: btnLogin_Click

        private void btnLogin_Click(object sender, EventArgs e)
        {
            string empId = txtUserName.Text;
            string password = txtUserPwd.Text;

            User aUser = new User(empId, password);
            bool login = aUser.CheckUser(aUser);
            if (login)
            {
                typeNumber = aUser.GetType(aUser);
                FormMain aForm = new GUI.Main.FormMain(typeNumber);
                aForm.Show();
                this.Hide();
            }
        }
开发者ID:mrmontreal,项目名称:works,代码行数:15,代码来源:fmLogin.cs

示例5: SerializeUser

 public static void SerializeUser(User kaytt)
 {
     XmlSerializer xs = new XmlSerializer(kaytt.GetType());
     TextWriter tw = new StreamWriter(HttpContext.Current.Server.MapPath("~/App_Data/käyttäjät.xml"));
     try
     {
         xs.Serialize(tw, kaytt);
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         tw.Close();
     }
 }
开发者ID:Raedot,项目名称:IIO13200-OHJELMOINTIKOE,代码行数:17,代码来源:MySerializer.cs

示例6: Add

        public virtual IMemberApp Add(User creator, string name, long appinfoId)
        {
            //创建应用
            IApp app = AppFactory.Create( appinfoId, creator, AccessStatus.Public );

            // 创建控制面板中的 程序
            IMemberApp userApp = New();
            userApp.AppInfoId = appinfoId;
            userApp.AppOid = app.Id;
            userApp.OwnerId = creator.Id;
            userApp.OwnerUrl = creator.Url;
            userApp.OwnerType = creator.GetType().FullName;
            userApp.Creator = creator;
            userApp.CreatorUrl = creator.Url;
            userApp.Name = name;
            userApp.AccessStatus = (int)AccessStatus.Public;

            Insert( userApp );

            return userApp;
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:21,代码来源:SiteAppService.cs

示例7: ErrorMessages

		public void ErrorMessages()
		{
			Thread.CurrentThread.CurrentCulture =
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			ActiveRecordStarter.Initialize(GetConfigSource(), typeof(User));

			User user = new User();
			Type type = user.GetType();
			PropertyInfo info;
			ArrayList propertyMessages;

			Assert.IsFalse(user.IsValid());
			Assert.AreEqual(5, user.ValidationErrorMessages.Length);
			Assert.AreEqual("This is a required field", user.ValidationErrorMessages[0]);
			Assert.AreEqual("This is a required field", user.ValidationErrorMessages[1]);
			Assert.AreEqual("This is a required field", user.ValidationErrorMessages[2]);
			Assert.AreEqual("This is a required field", user.ValidationErrorMessages[3]);
			Assert.AreEqual("This is a required field", user.ValidationErrorMessages[4]);

			Assert.AreEqual(5, user.PropertiesValidationErrorMessages.Count);

			info = type.GetProperty("Login");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("This is a required field", propertyMessages[0]);

			info = type.GetProperty("Name");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("This is a required field", propertyMessages[0]);

			info = type.GetProperty("Email");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("This is a required field", propertyMessages[0]);

			info = type.GetProperty("Password");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("This is a required field", propertyMessages[0]);

			info = type.GetProperty("ConfirmationPassword");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("This is a required field", propertyMessages[0]);

			user.Name = "hammett";
			user.Login = "hammett";
			user.Email = "[email protected]";
			user.Password = "123x";
			user.ConfirmationPassword = "123";

			Assert.IsFalse(user.IsValid());
			Assert.AreEqual(1, user.ValidationErrorMessages.Length);
			Assert.AreEqual("Fields do not match", user.ValidationErrorMessages[0]);

			info = type.GetProperty("Password");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("Fields do not match", propertyMessages[0]);

			user.Password = "123";

			Assert.IsTrue(user.IsValid());
			Assert.AreEqual(0, user.ValidationErrorMessages.Length);
		}
开发者ID:sheefa,项目名称:Castle.ActiveRecord,代码行数:73,代码来源:ValidationTestCase.Generic.cs

示例8: loadButton_Click

        private void loadButton_Click(object sender, EventArgs e)
        {
            try
            {
                User savedUser = new User();
                string filename = ".\\user" + ServerApp._serverPort + ".txt";
                TextReader tr = new StreamReader(filename);
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(savedUser.GetType());
                savedUser = (User)x.Deserialize(tr);
                tr.Close();

                ServerApp._user = savedUser;
                MessageBox.Show("Loaded user : " + savedUser.Username);
            }
            catch (FileNotFoundException) {
                MessageBox.Show("Couldnt load user from file");
                ServerApp._user = new User();
            }
            refreshTextBoxes();
        }
开发者ID:archie,项目名称:sesun,代码行数:20,代码来源:ServerForm.cs

示例9: CreateUserRow

 private void CreateUserRow(string userName, IDictionary<string, object> values)
 {
     using (var unit = unitOfWork.CreateExport().Value)
     {
         var users = userRepository.Where(u => u.Username == userName).Count();
         if (users > 0)
         {
             throw new MembershipCreateUserException(MembershipCreateStatus.DuplicateUserName);
         }
         var user = new User();
         user.Username = userName;
         if (values != null)
         {
             foreach (string key in values.Keys)
             {
                 if(key.Equals("UserName"))
                 {
                     continue;
                 }
                 var prop = user.GetType().GetProperty(key);
                 if(prop != null && prop.CanWrite)
                 {
                     prop.SetValue(user, values[key]);
                 }
             }
         }
         try
         {
             userRepository.Add(user);
             unit.Commit();
         }
         catch
         {
             throw new MembershipCreateUserException(MembershipCreateStatus.ProviderError);
         }
     }
 }
开发者ID:SpectralAngel,项目名称:Antem,代码行数:37,代码来源:SimpleMembershipProvider.cs

示例10: VerifyThatTransactionSafeDeleteTableWorks

        public void VerifyThatTransactionSafeDeleteTableWorks()
        {
            var fromObject = new User()
            {
                Id = Guid.NewGuid(),
                Name = "John Doe"
            };

            var toObject = new Usergroup();

            Assert.Throws<InvalidDataException>(() => DatabaseSession.Instance.Connector.DeleteTable(fromObject));

            DatabaseSession.Instance.Connector.CreateTableWithColumns(fromObject);
            DatabaseSession.Instance.Connector.CreateTableWithColumns(toObject);
            DatabaseSession.Instance.Connector.CreatePrimaryKeyConstraint(fromObject);
            DatabaseSession.Instance.Connector.CreatePrimaryKeyConstraint(toObject);

            var transaction = DatabaseSession.Instance.CreateTransaction();

            DatabaseSession.Instance.Connector.CreateForeignKeyConstraint(fromObject.GetType().GetProperty("Usergroup_Id"), fromObject, toObject.GetType().GetProperty(toObject.PrimaryKey), toObject, transaction);
            DatabaseSession.Instance.Connector.DeleteForeignKeyConstraint(fromObject.GetType().GetProperty("Usergroup_Id"), fromObject, toObject.GetType().GetProperty(toObject.PrimaryKey), toObject, transaction);
            DatabaseSession.Instance.Connector.DeleteTable(fromObject, transaction);

            Assert.IsFalse(DatabaseSession.Instance.Connector.CheckTableExists(fromObject));

            DatabaseSession.Instance.Connector.DeleteTable(toObject, transaction);

            Assert.IsFalse(DatabaseSession.Instance.Connector.CheckTableExists(toObject));

            DatabaseSession.Instance.CommitTransaction(transaction);

            Assert.IsFalse(DatabaseSession.Instance.Connector.CheckTableExists(fromObject));
            Assert.IsFalse(DatabaseSession.Instance.Connector.CheckTableExists(toObject));
        }
开发者ID:ajvorobiev,项目名称:DotNORM,代码行数:34,代码来源:MySQLDatabaseConnectorTestFixture.cs

示例11: VerifyThatTransactionSafeCreateTableWorks

        public void VerifyThatTransactionSafeCreateTableWorks()
        {
            var fromObject = new User()
            {
                Id = Guid.NewGuid(),
                Name = "John Doe"
            };

            var transaction = DatabaseSession.Instance.CreateTransaction();
            var prop = fromObject.GetType().GetProperties().First();
            DatabaseSession.Instance.Connector.CreateTableWithColumns(fromObject, transaction);
            DatabaseSession.Instance.CommitTransaction(transaction);

            DatabaseSession.Instance.Connector.DeleteTable(fromObject);

            var allTypes = new AllTypeMySqlThing();

            DatabaseSession.Instance.Connector.CreateTableWithColumns(allTypes);

            Assert.IsFalse(DatabaseSession.Instance.Connector.CheckTableExists(fromObject));

            var transaction1 = DatabaseSession.Instance.CreateTransaction();
            DatabaseSession.Instance.Connector.CreateTableWithColumns(fromObject, transaction1);
            Assert.Throws<InvalidDataException>(() => allTypes.Save(transaction: transaction1));
            DatabaseSession.Instance.CommitTransaction(transaction1);

            DatabaseSession.Instance.Connector.DeleteTable(allTypes);

            // mysql CREATE TABLE ignores transactions
            Assert.IsTrue(DatabaseSession.Instance.Connector.CheckTableExists(fromObject));
            DatabaseSession.Instance.Connector.DeleteTable(fromObject);

            Assert.IsFalse(DatabaseSession.Instance.Connector.CheckTableExists(fromObject));
        }
开发者ID:ajvorobiev,项目名称:DotNORM,代码行数:34,代码来源:MySQLDatabaseConnectorTestFixture.cs

示例12: VerifyThatOverridesAndForeignKeyConstraintsWork

        public void VerifyThatOverridesAndForeignKeyConstraintsWork()
        {
            var fromObject = new User()
            {
                Id = Guid.NewGuid(),
                Name = "John Doe"
            };

            var toObject = new Usergroup()
            {
                Iid = 1,
                Name = "Admin"
            };

            fromObject.Usergroup_Id = toObject.Iid;

            DatabaseSession.Instance.Connector.CreateTableWithColumns(toObject);
            DatabaseSession.Instance.Connector.CreateTableWithColumns(fromObject);

            Assert.Throws<InvalidDataException>(() => DatabaseSession.Instance.Connector.CreateForeignKeyConstraint(fromObject.GetType().GetProperty("Usergroup_Id"), fromObject, toObject.GetType().GetProperty(toObject.PrimaryKey), toObject));

            DatabaseSession.Instance.Connector.CreatePrimaryKeyConstraint(toObject);
            Assert.Throws<InvalidDataException>(
                () =>
                    DatabaseSession.Instance.Connector.DeleteForeignKeyConstraint(
                        fromObject.GetType().GetProperty("Usergroup_Id"), fromObject,
                        toObject.GetType().GetProperty(toObject.PrimaryKey), toObject));

            Assert.DoesNotThrow(() => DatabaseSession.Instance.Connector.CreateForeignKeyConstraint(fromObject.GetType().GetProperty("Usergroup_Id"), fromObject, toObject.GetType().GetProperty(toObject.PrimaryKey), toObject));

            Assert.Throws<InvalidDataException>(() => fromObject.Save());

            toObject.Save();

            Assert.DoesNotThrow(() => fromObject.Save());

            Assert.Throws<InvalidDataException>(() => toObject.Delete());

            DatabaseSession.Instance.Connector.DeleteForeignKeyConstraint(fromObject.GetType().GetProperty("Usergroup_Id"), fromObject, toObject.GetType().GetProperty(toObject.PrimaryKey), toObject);

            Assert.DoesNotThrow(() => toObject.Delete());
            DatabaseSession.Instance.Connector.DeleteTable(new User());
            DatabaseSession.Instance.Connector.DeleteTable(new Usergroup());
        }
开发者ID:ajvorobiev,项目名称:DotNORM,代码行数:44,代码来源:MySQLDatabaseConnectorTestFixture.cs

示例13: VerifyThatNotNullConstraintWorks

        public void VerifyThatNotNullConstraintWorks()
        {
            var fromObject = new User()
            {
                Id = Guid.NewGuid(),
                Name = "John Doe"
            };

            fromObject.Usergroup_Id = 3;

            DatabaseSession.Instance.Connector.CreateTableWithColumns(fromObject);
            DatabaseSession.Instance.Connector.CreatePrimaryKeyConstraint(fromObject);

            Assert.Throws<ArgumentNullException>(
                () => DatabaseSession.Instance.Connector.CreateNotNullConstraint(null, fromObject));

            Assert.Throws<ArgumentNullException>(
                () => DatabaseSession.Instance.Connector.DeleteNotNullConstraint(null, fromObject));

            fromObject.Name = null;
            fromObject.Save();

            Assert.Throws<InvalidDataException>(
                () => DatabaseSession.Instance.Connector.CreateNotNullConstraint(fromObject.GetType().GetProperty("Name"), fromObject));

            fromObject.Name = "somename";
            fromObject.Save();

            DatabaseSession.Instance.Connector.CreateNotNullConstraint(fromObject.GetType().GetProperty("Name"), fromObject);

            fromObject.Name = null;

            Assert.Throws<InvalidDataException>(() => fromObject.Save());

            Assert.DoesNotThrow(() => DatabaseSession.Instance.Connector.DeleteNotNullConstraint(fromObject.GetType().GetProperty("Name"), fromObject));

            fromObject.Name = null;

            Assert.DoesNotThrow(() => fromObject.Save());

            DatabaseSession.Instance.Connector.DeleteTable(new User());
        }
开发者ID:ajvorobiev,项目名称:DotNORM,代码行数:42,代码来源:MySQLDatabaseConnectorTestFixture.cs

示例14: VerifyThatDefaultWorks

        public void VerifyThatDefaultWorks()
        {
            var fromObject = new User()
            {
                Id = Guid.NewGuid(),
                Name = null
            };

            fromObject.Usergroup_Id = 3;

            var testname = "James";

            Assert.Throws<ArgumentNullException>(() => DatabaseSession.Instance.Connector.SetDefault(null, testname, fromObject));

            Assert.Throws<ArgumentNullException>(() => DatabaseSession.Instance.Connector.DeleteDefault(null, fromObject));

            DatabaseSession.Instance.Connector.CreateTableWithColumns(fromObject);

            Assert.Throws<InvalidDataException>(() => DatabaseSession.Instance.Connector.SetDefault(fromObject.GetType().GetProperty("Name"), testname, fromObject));

            // save some names
            fromObject.Save(ignoreNull: true);

            var object2 = new User()
            {
                Id = Guid.NewGuid(),
                Name = null
            };

            object2.Save(ignoreNull: true);

            Assert.AreEqual(2, User.All().ToList().Count);

            DatabaseSession.Instance.Connector.DeleteDefault(fromObject.GetType().GetProperty("Name"), fromObject);

            var object3 = new User()
            {
                Id = Guid.NewGuid(),
                Name = null
            };

            object3.Save(ignoreNull: true);

            Assert.AreEqual(3, User.All().ToList().Count);
            Assert.AreEqual(2, User.Subset(2, 1, fromObject.GetType().GetProperty("Id")).ToList().Count);

            DatabaseSession.Instance.Connector.DeleteTable(new User());
        }
开发者ID:ajvorobiev,项目名称:DotNORM,代码行数:48,代码来源:MySQLDatabaseConnectorTestFixture.cs

示例15: Main

        static void Main(string[] args)
        {
            if (args.Length == 0 || args.Length > 2)
            {
                System.Windows.Forms.MessageBox.Show("Invalid server invocation");
                return;
            }

            loadRPCServices(args);
            _serviceAvailable = true;

            try
            {
                User savedUser = new User();
                string filename = ".\\user" + _serverPort + ".txt";
                TextReader tr = new StreamReader(filename);
                System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(savedUser.GetType());
                savedUser = (User)x.Deserialize(tr);
                tr.Close();

                _user = savedUser;
            }
            catch (FileNotFoundException)
            {
                _user = new User();
                _user.SpoofAdress = _myUri;
            }

            /* load or generate pub/priv key for node */
            loadNodePublicPrivateKeys();

            _form = new ServerForm(_myUri);

            /* PKI Communication */
            RSACryptoServiceProvider rsaPki = null;
            if ((rsaPki = readRSAPKI()) == null)
            {
                MessageBox.Show("Couldn't load pubkey of PKI.");
                Application.Exit();
            }
            _pkiCommunicator = new NodePKIHelper(_rsaProvider, rsaPki, args[1]);
            _myUserEntry = new UserEntry();
            _myUserEntry.NodeId = _user.Username;
            _myUserEntry.Address = _myUri;
            _myUserEntry.PubKey = _rsaProvider.ToXmlString(false);

            if (_pkiCommunicator.Register(_myUserEntry))
            {
                Application.Run(_form);
            }
            else
            {
                Application.Exit();
            }
        }
开发者ID:archie,项目名称:sesun,代码行数:55,代码来源:ServerApp.cs


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