コード例 #1
0
        public void GrantInitializeEntityDelegate(IEntityInitializer initializer)
        {
            initializer.AcceptInitializeDelegate((Guid id, Guid revision, Guid? author, DateTime created, DateTime updated, IEnumerable <EntityFieldValue> fields) =>
            {
                this.Id       = id;
                this.Revision = revision;
                this.Author   = author;
                this.Created  = created;
                this.Updated  = updated;

                foreach (EntityFieldValue field in fields)
                {
                    if (field == null)
                    {
                        continue;
                    }
                    if (field.Property == null)
                    {
                        throw new Exception(string.Format("property is null for {0}", field.Field.Name));
                    }
                    if (field.Property.SetMethod == null)
                    {
                        throw new MissingFieldSetMethodException(this.GetType(), field.Field.Name);
                    }
                    field.Property.SetValue(this, field.Value);
                }
            });
        }