public ProvidedAssociationAttribute(string associationName,string providedPropertyName, RelationType relationType,
                                     string attributesFactory) {
     _associationName = associationName;
     _relationType = relationType;
     _attributesFactoryProperty = attributesFactory;
     _providedPropertyName = providedPropertyName;
 }
示例#2
0
	//Constructor
	public Person(RelationType theirRelation, MoodType theirMood,
	              string aName, int theirAffection, int theirTrust)
	{
		acquaintances = new List<int>();

		relation = theirRelation;			curMood = theirMood;		name = aName;
		playerAffection = theirAffection;	playerTrust = theirTrust;
	}
示例#3
0
		public Relationship DefineRelationshipTo(Faction otherFaction, RelationType currentRelation)
		{
			var newRelationship = new Relationship(this, otherFaction, currentRelation);

			relationships.Add(otherFaction, newRelationship);

			return newRelationship;
		}
示例#4
0
        /// <summary>
        /// Constructor de clase
        /// </summary>
        /// <param name="relationType"><see cref="RelationType"/></param>
        /// <param name="targetEntity">Entidad destino de la relación</param>
        public RelationAttribute( RelationType relationType, Type targetEntity )
        {
            Verify.ArgumentNotNull(relationType, "relationType");
            Verify.ArgumentNotNull(targetEntity, "relationType");

            Type = relationType;
            TargetEntity = targetEntity;
        }
示例#5
0
	public Player(RelationType theirRelation, MoodType theirMood,
	              string aName, int theirAffection, int theirTrust)
		   : base(theirRelation, theirMood, aName, theirAffection, theirTrust)
	{
		energy = 0;
		happiness = 0;

		GameManager.People.OnChangeStatus += People_OnChangeStatus;
	}
示例#6
0
        public Relation(Type left_model, Type right_model, 
			RelationType relation_type, string left_identifier,
										string right_identifier)
        {
            this.left_model = left_model;
            this.right_model = right_model;
            this.relation_type = relation_type;
            this.left_identifier = left_identifier;
            this.right_identifier = right_identifier;
        }
示例#7
0
		public Relationship(Faction fromFaction, Faction toFaction, RelationType currentRelation)
		{
			this.fromFaction = fromFaction;
			this.toFaction = toFaction;

			fromFactionName = fromFaction.name;
			toFactionName = toFaction.name;

			this.currentRelation = currentRelation;
		}
示例#8
0
                public bool is_online; //是否在线

                public void FromBin(NetSocket.ByteArray bin)
                {
                    bin.Get_(out char_idx);
                    char_name = bin.GetStringData((int)twp.app.unit.EUnitLimit.LIMIT_NAME_STR_LENGTH+1);
                    byte v;
                    bin.Get_(out v);
                    relation_type = (RelationType)v;
                    bin.Get_(out battle_integral);
                    sbyte isonline;
                    bin.Get_(out isonline);
                    is_online = (isonline == 0)? false : true;
                }
示例#9
0
        /// <summary>
        /// creates a new relation between two nodes
        /// </summary>
        /// <param name="start">classifier where the relation starts</param>
        /// <param name="end">classifier where the relation ends</param>
        /// <param name="startName">optional name of the start node of the relation</param>
        /// <param name="endName">optional name of the end node of the relation</param>
        /// <param name="relation">type of the relation</param>
        public Relation(
            Classifier start,
            Classifier end,
            RelationType relation = RelationType.Association,
            string startName = "",
            string endName = "")
        {
            Requires(start != null);
            Requires(end != null);

            Start = new StartNode(start,startName);
            End = new EndNode(end, endName);
            Type = relation;
            IsVisible = true;
        }
示例#10
0
		public Relation(int Id)
		{
			using (SqlDataReader dr = Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(GlobalSettings.DbDSN, CommandType.Text, "select * from umbracoRelation where id = @id", new SqlParameter("@id", Id)))
			{
				if(dr.Read())
				{
					this._id = int.Parse(dr["id"].ToString());
					this._parentNode = new CMSNode(int.Parse(dr["parentId"].ToString()));
					this._childNode = new CMSNode(int.Parse(dr["childId"].ToString()));
					this._relType = RelationType.GetById(int.Parse(dr["relType"].ToString()));
					this._comment = dr["comment"].ToString();
					this._datetime = DateTime.Parse(dr["datetime"].ToString());
				}
			}
		}
        public RelationDescription(String fromPropertyName, RelationType relationType, String toEntityName,
                                   String mappedByPropertyName, IIdMapper idMapper,
                                   IPropertyMapper fakeBidirectionalRelationMapper,
                                   IPropertyMapper fakeBidirectionalRelationIndexMapper, bool insertable) {
            this.FromPropertyName = fromPropertyName;
            this.RelationType = relationType;
            this.ToEntityName = toEntityName;
            this.MappedByPropertyName = mappedByPropertyName;
            this.IdMapper = idMapper;
            this.FakeBidirectionalRelationMapper = fakeBidirectionalRelationMapper;
            this.FakeBidirectionalRelationIndexMapper = fakeBidirectionalRelationIndexMapper;
            this.Insertable = insertable;

            this.Bidirectional = false;
        }
示例#12
0
 public void Add(GObject target, RelationType relationType, bool usePercent)
 {
     foreach (RelationItem item in _items)
     {
         if (item.target == target)
         {
             item.Add(relationType, usePercent);
             return;
         }
     }
     RelationItem newItem = new RelationItem(_owner);
     newItem.target = target;
     newItem.Add(relationType, usePercent);
     _items.Add(newItem);
 }
        public RelatedEntityInfo(RelationType relationType, string relationName, CodeProperty relationProperty, CodeType relatedEntityType, string relatedEntityPrimaryKeyName, CodeProperty lazyLoadingProperty)
        {
            if (string.IsNullOrEmpty(relationName)) throw new ArgumentException("'relationName' cannot be null or empty.");
            if (relationProperty == null) throw new ArgumentNullException("relationProperty");
            if (relatedEntityType == null) throw new ArgumentNullException("relatedEntityType");
            if ((relationType == RelationType.Parent) && string.IsNullOrEmpty(relatedEntityPrimaryKeyName)) throw new ArgumentException("'relatedEntityPrimaryKeyName' cannot be null or empty for parent entities.");

            RelationType = relationType;
            RelationName = relationName;
            RelationNamePlural = Pluralize(relationName);
            RelationProperty = relationProperty;
            RelatedEntityType = relatedEntityType;
            RelatedEntityTypeNamePlural = Pluralize(relatedEntityType.Name);
            RelatedEntityPrimaryKeyName = relatedEntityPrimaryKeyName;
            LazyLoadingProperty = lazyLoadingProperty;
        }
        public ProfileData(
            string id, string name = null, string iconImageUrl = null, AccountStatus? status = null,
            string firstName = null, string lastName = null, string introduction = null, string braggingRights = null,
            string occupation = null, string greetingText = null, string nickName = null, RelationType? relationship = null,
            GenderType? genderType = null, LookingFor lookingFor = null, EmploymentInfo[] employments = null,
            EducationInfo[] educations = null, ContactInfo[] contactsInHome = null, ContactInfo[] contactsInWork = null,
            UrlInfo[] otherProfileUrls = null, UrlInfo[] contributeUrls = null, UrlInfo[] recommendedUrls = null,
            string[] placesLived = null, string[] otherNames = null,
            ProfileUpdateApiFlag loadedApiTypes = ProfileUpdateApiFlag.Unloaded,
            DateTime? lastUpdateLookupProfile = null, DateTime? lastUpdateProfileGet = null)
        {
            if (id == null)
                throw new ArgumentNullException("ProfileDataの引数idをnullにする事はできません。");
            //idが数字になるならばProfileIdとして正しい。違うならばG+を始めていないアカウントのEMailAddressと見なす
            //また、スタブモード時は先頭に"Id"の2文字が入るため、テストコード用に先頭2文字を省いてParse()する。
            double tmp;
            if (status == AccountStatus.Active && double.TryParse(id.Substring(2), out tmp) == false)
                throw new ArgumentException("ProfileDataの引数idがメアド状態で引数statusをActiveにする事はできません。");

            LoadedApiTypes = loadedApiTypes;
            Status = status;
            Id = id;
            Name = name;
            FirstName = firstName;
            LastName = lastName;
            Introduction = introduction;
            BraggingRights = braggingRights;
            Occupation = occupation;
            GreetingText = greetingText;
            NickName = nickName;
            IconImageUrl = iconImageUrl;
            Relationship = relationship;
            Gender = genderType;
            LookingFor = lookingFor;
            Employments = employments;
            Educations = educations;
            ContactsInHome = contactsInHome;
            ContactsInWork = contactsInWork;
            OtherProfileUrls = otherProfileUrls;
            ContributeUrls = contributeUrls;
            RecommendedUrls = recommendedUrls;
            PlacesLived = placesLived;
            OtherNames = otherNames;

            LastUpdateLookupProfile = lastUpdateLookupProfile ?? DateTime.MinValue;
            LastUpdateProfileGet = lastUpdateProfileGet ?? DateTime.MinValue;
        }
示例#15
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="target"></param>
 /// <param name="relationType"></param>
 /// <param name="usePercent"></param>
 public void Add(GObject target, RelationType relationType, bool usePercent)
 {
     int cnt = _items.Count;
     for (int i = 0; i < cnt; i++)
     {
         RelationItem item = _items[i];
         if (item.target == target)
         {
             item.Add(relationType, usePercent);
             return;
         }
     }
     RelationItem newItem = new RelationItem(_owner);
     newItem.target = target;
     newItem.Add(relationType, usePercent);
     _items.Add(newItem);
 }
示例#16
0
        public RelationModel(EntityModel entity1, EntityModel entity2, RelationType type, string role)
        {
            var isLeft = entity1.Name.ToLower().CompareTo(entity2.Name.ToLower()) < 0;
            Left = isLeft ? entity1 : entity2;
            Right = isLeft ? entity2 : entity1;
            if (!isLeft)
            {
                if (type == RelationType.OneToMany)
                    type = RelationType.ManyToOne;
                else if (type == RelationType.ManyToOne)
                    type = RelationType.OneToMany;
            }

            Type = type;
            Role = role;

            Name = string.Format("{0}_{1}_{2}", Left.Name, Right.Name, Role);
        }
示例#17
0
        public void Add(RelationType relationType, bool usePercent)
        {
            if (relationType == RelationType.Size)
            {
                Add(RelationType.Width, usePercent);
                Add(RelationType.Height, usePercent);
                return;
            }

            int dc = _defs.Count;
            for (int k = 0; k < dc; k++)
            {
                if (_defs[k].type == relationType)
                    return;
            }

            InternalAdd(relationType, usePercent);
        }
示例#18
0
        public void Add(RelationType relationType, bool usePercent)
        {
            if (relationType == RelationType.Size)
            {
                Add(RelationType.Width, usePercent);
                Add(RelationType.Height, usePercent);
                return;
            }
            foreach (RelationDef def in _defs)
            {
                if (def.type == relationType)
                    return;
            }

            RelationDef info = new RelationDef();
            info.affectBySelfSizeChanged = relationType >= RelationType.Center_Center && relationType <= RelationType.Right_Right
                || relationType >= RelationType.Middle_Middle && relationType <= RelationType.Bottom_Bottom;
            info.percent = usePercent;
            info.type = relationType;
            _defs.Add(info);
        }
示例#19
0
        /// <summary>
        /// Creates or updates resources based on the natural key values of the supplied resource. The POST operation can be used to create or update resources. In database terms, this is often referred to as an &quot;upsert&quot; operation (insert + update).  Clients should NOT include the resource &quot;id&quot; in the JSON body because it will result in an error (you must use a PUT operation to update a resource by &quot;id&quot;). The web service will identify whether the resource already exists based on the natural key values provided, and update or create the resource appropriately.
        /// </summary>
        /// <param name="body">The JSON representation of the &quot;relationType&quot; resource to be created or updated.</param>
        /// <returns>A RestSharp <see cref="IRestResponse"/> instance containing the API response details.</returns>
        public IRestResponse PostRelationTypes(RelationType body)
        {
            var request = new RestRequest("/relationTypes", Method.POST);

            request.RequestFormat = DataFormat.Json;

            // verify required params are set
            if (body == null)
            {
                throw new ArgumentException("API method call is missing required parameters");
            }
            request.AddBody(body);
            var response = client.Execute(request);

            var location = response.Headers.FirstOrDefault(x => x.Name == "Location");

            if (location != null && !string.IsNullOrWhiteSpace(location.Value.ToString()))
            {
                body.id = location.Value.ToString().Split('/').Last();
            }
            return(response);
        }
        public void CreateTestData()
        {
            var relateContent = new RelationType(Constants.ObjectTypes.Document, new Guid("C66BA18E-EAF3-4CFF-8A22-41B16D66A972"), "relateContentOnCopy")
            {
                IsBidirectional = true, Name = "Relate Content on Copy"
            };
            var relateContentType = new RelationType(Constants.ObjectTypes.DocumentType, new Guid("A2CB7800-F571-4787-9638-BC48539A0EFB"), "relateContentTypeOnCopy")
            {
                IsBidirectional = true, Name = "Relate ContentType on Copy"
            };

            var provider = TestObjects.GetScopeProvider(Logger);

            using (var scope = ScopeProvider.CreateScope())
            {
                var repository = new RelationTypeRepository((IScopeAccessor)provider, CacheHelper.Disabled, Mock.Of <ILogger>());

                repository.Save(relateContent);     //Id 2
                repository.Save(relateContentType); //Id 3
                scope.Complete();
            }
        }
示例#21
0
        /** 搜索单位列表 */
        public UnitCtl SearchUnit_MinDistance(Vector3 point, float radius, int unitType, int casterLegionId, int relation, float around = 0f)
        {
            UnitCtl minUnit     = null;
            float   minDistance = 999999;

            foreach (KeyValuePair <int, UnitCtl> kvp in unitDict)
            {
                UnitCtl unitCtl = kvp.Value;
                if (unitCtl.unitData == null || unitCtl.death || unitCtl.unitData.isTurretHit)
                {
                    continue;
                }
                if (unitType.UValue(unitCtl.unitData.unitType) == false)
                {
                    continue;
                }

                RelationType relationType = unitCtl.unitData.GetRelation(casterLegionId);
                if (relation.RValue(relationType) == false)
                {
                    continue;
                }

                float distance = Vector3.Distance(point, unitCtl.transform.position);

                if (distance <= radius && distance < minDistance)
                {
                    minUnit     = unitCtl;
                    minDistance = distance;
                }

                if (distance <= around && minUnit != null)
                {
                    return(minUnit);
                }
            }

            return(minUnit);
        }
示例#22
0
        void createRelations()
        {
            try
            {

                var relationService = Current.Services.RelationService;

                if (relationService.GetRelationTypeByAlias("DocumentToDocument") == null && relationService.GetRelationTypeByAlias("DocumentToMedia") == null)
                { 
                    var relationTypeDocumentToMedia = new RelationType(UmbracoObjectTypes.Media.GetGuid(),UmbracoObjectTypes.Document.GetGuid(), "DocumentToMedia", "Document To Media") { IsBidirectional = true };
                    var relationTypeDocumentToDocument = new RelationType(UmbracoObjectTypes.Document.GetGuid(), UmbracoObjectTypes.Document.GetGuid(), "DocumentToDocument", "Document To Document") { IsBidirectional = true };
                    relationService.Save(relationTypeDocumentToMedia);
                    relationService.Save(relationTypeDocumentToDocument);
                    Current.Logger.Info(this.GetType(),"Created relations DocumentToMedia and DocumentToDocument");
                }
            }
            catch (Exception msg)
            {
                Current.Logger.Debug(this.GetType(), "An  error occurred while creating the new relations for Related content app");
                Current.Logger.Error(this.GetType(), msg);
            }
        }
示例#23
0
        public SqlDataReader GetValues(RelationType relation)
        {
            SqlCommand cmd = new SqlCommand("net_taxonomyValue_get", ConnectionManager.GetConnection());

            cmd.Transaction = ConnectionManager.GetTransaction();
            cmd.CommandType = CommandType.StoredProcedure;

            //
            // Add parameters and set values
            //
            SqlParameterAccessor populator = new SqlParameterAccessor(cmd.Parameters);

            cmd.Parameters.Add("@tModelKey", SqlDbType.UniqueIdentifier);
            cmd.Parameters.Add("@keyValue", SqlDbType.NVarChar, UDDI.Constants.Lengths.KeyValue);
            cmd.Parameters.Add("@relation", SqlDbType.Int);

            populator.SetGuidFromKey("@tModelKey", TModelKey);
            populator.SetString("@keyValue", KeyValue);
            populator.SetInt("@relation", (int)relation);

            return(cmd.ExecuteReader());
        }
示例#24
0
        public void GetReadOnlyIngoingAndOutgoing()
        {
            Node  node1, node2;
            Verge verge1, verge2;

            using (var unitOfWork = UnitOfWorkFactory.Create()) {
                var notionType = new NotionType("type");
                GetRepository <NotionType>().AddOrUpdate(notionType);

                var nodeRepo = GetRepository <Node>();
                node1 = new Node("notion1", notionType);
                nodeRepo.AddOrUpdate(node1);

                node2 = new Node("notion2", notionType);
                nodeRepo.AddOrUpdate(node2);

                var relationType = new RelationType("type");
                GetRepository <RelationType>().AddOrUpdate(relationType);

                var vergeRepo = GetRepository <Verge>();
                verge1 = new Verge(node1, node2, relationType, 20);
                vergeRepo.AddOrUpdate(verge1);

                verge2 = new Verge(node2, node1, relationType, 20);
                vergeRepo.AddOrUpdate(verge2);

                unitOfWork.Commit();
            }

            using (UnitOfWorkFactory.Create()) {
                node1 = GetRepository <Node>().GetById(node1.Id);
                node2 = GetRepository <Node>().GetById(node2.Id);

                node1.IngoingVerges.Select(x => x.Id).Should().BeEquivalentTo(new[] { verge2.Id });
                node1.OutgoingVerges.Select(x => x.Id).Should().BeEquivalentTo(new[] { verge1.Id });
                node2.IngoingVerges.Select(x => x.Id).Should().BeEquivalentTo(new[] { verge1.Id });
                node2.OutgoingVerges.Select(x => x.Id).Should().BeEquivalentTo(new[] { verge2.Id });
            }
        }
示例#25
0
        public static bool HasStorage(this Relation rel, RelationEndRole role)
        {
            if (rel == null)
            {
                throw new ArgumentNullException("rel");
            }

            if (rel.Storage == StorageType.Replicate)
            {
                throw new NotImplementedException();
            }

            RelationType type = rel.GetRelationType();

            // n:m has no storage on A or B
            return
                ((type == RelationType.one_n && rel.Storage == StorageType.MergeIntoA && role == RelationEndRole.A) ||
                 (type == RelationType.one_n && rel.Storage == StorageType.MergeIntoB && role == RelationEndRole.B) ||
                 (type == RelationType.one_one && rel.Storage == StorageType.Replicate) ||
                 (type == RelationType.one_one && rel.Storage == StorageType.MergeIntoA && role == RelationEndRole.A) ||
                 (type == RelationType.one_one && rel.Storage == StorageType.MergeIntoB && role == RelationEndRole.B));
        }
        private static void MediaService_Trashed(IMediaService sender, MoveEventArgs <IMedia> e)
        {
            var          relationService   = Current.Services.RelationService;
            var          entityService     = Current.Services.EntityService;
            var          textService       = Current.Services.TextService;
            const string relationTypeAlias = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteAlias;
            var          relationType      = relationService.GetRelationTypeByAlias(relationTypeAlias);

            // check that the relation-type exists, if not, then recreate it
            if (relationType == null)
            {
                var          documentObjectType = Constants.ObjectTypes.Document;
                const string relationTypeName   = Constants.Conventions.RelationTypes.RelateParentMediaFolderOnDeleteName;
                relationType = new RelationType(relationTypeName, relationTypeAlias, false, documentObjectType, documentObjectType);
                relationService.Save(relationType);
            }
            foreach (var item in e.MoveInfoCollection)
            {
                var originalPath     = item.OriginalPath.ToDelimitedList();
                var originalParentId = originalPath.Count > 2
                    ? int.Parse(originalPath[originalPath.Count - 2])
                    : Constants.System.Root;
                //before we can create this relation, we need to ensure that the original parent still exists which
                //may not be the case if the encompassing transaction also deleted it when this item was moved to the bin
                if (entityService.Exists(originalParentId))
                {
                    // Add a relation for the item being deleted, so that we can know the original parent for if we need to restore later
                    var relation = new Relation(originalParentId, item.Entity.Id, relationType);
                    relationService.Save(relation);
                    Current.Services.AuditService.Add(AuditType.Delete,
                                                      item.Entity.CreatorId,
                                                      item.Entity.Id,
                                                      ObjectTypes.GetName(UmbracoObjectTypes.Media),
                                                      string.Format(textService.Localize(
                                                                        "recycleBin/mediaTrashed"),
                                                                    item.Entity.Id, originalParentId));
                }
            }
        }
示例#27
0
        public static IRelationType BuildEntity(RelationTypeDto dto)
        {
            var entity = new RelationType(dto.ChildObjectType, dto.ParentObjectType, dto.Alias);

            try
            {
                entity.DisableChangeTracking();

                entity.Id              = dto.Id;
                entity.Key             = dto.UniqueId;
                entity.IsBidirectional = dto.Dual;
                entity.Name            = dto.Name;

                // reset dirty initial properties (U4-1946)
                entity.ResetDirtyProperties(false);
                return(entity);
            }
            finally
            {
                entity.EnableChangeTracking();
            }
        }
        internal void SyncFromMeta(RelationType relationType)
        {
            this.id = relationType.Id;

            this.isIndexed = null;
            if (!relationType.IsIsIndexedDefault)
            {
                this.isIndexed = XmlConvert.ToString(relationType.IsIndexed);
            }

            this.isDerived = null;
            if (!relationType.IsIsDerivedDefault)
            {
                this.isDerived = XmlConvert.ToString(relationType.IsDerived);
            }

            this.associationType = new AssociationTypeXml();
            this.associationType.SyncFromMeta(relationType.AssociationType);

            this.roleType = new RoleTypeXml();
            this.roleType.SyncFromMeta(relationType.RoleType);
        }
        /// <summary>
        /// Creates a new relation type.
        /// </summary>
        /// <param name="relationType">The relation type to create.</param>
        /// <returns>A <see cref="HttpResponseMessage"/> containing the persisted relation type's ID.</returns>
        public ActionResult <int> PostCreate(RelationTypeSave relationType)
        {
            var relationTypePersisted = new RelationType(
                relationType.Name,
                relationType.Name.ToSafeAlias(_shortStringHelper, true),
                relationType.IsBidirectional,
                relationType.ParentObjectType,
                relationType.ChildObjectType,
                relationType.IsDependency);

            try
            {
                _relationService.Save(relationTypePersisted);

                return(relationTypePersisted.Id);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error creating relation type with {Name}", relationType.Name);
                return(ValidationProblem("Error creating relation type."));
            }
        }
        public void Can_Perform_Add_On_RelationTypeRepository()
        {
            // Arrange
            var provider   = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            var repository = new RelationTypeRepository(unitOfWork);

            // Act
            var relateMemberToContent = new RelationType(new Guid(Constants.ObjectTypes.Member),
                                                         new Guid(Constants.ObjectTypes.Document),
                                                         "relateMemberToContent")
            {
                IsBidirectional = true, Name = "Relate Member to Content"
            };

            repository.AddOrUpdate(relateMemberToContent);
            unitOfWork.Commit();

            // Assert
            Assert.That(relateMemberToContent.HasIdentity, Is.True);
            Assert.That(repository.Exists(relateMemberToContent.Id), Is.True);
        }
        public IEnumerable <RelationById> PerformGetChildRelations(HiveId parentId, RelationType relationType = null)
        {
            if (parentId.Value.Type != HiveIdValueTypes.Guid)
            {
                return(Enumerable.Empty <RelationById>());
            }

            using (NhProfilerLogging.Start(NhSession, "PerformGetChildRelations",
                                           new OdbcParameter("parentId", parentId),
                                           new OdbcParameter("relationType", relationType)))
            {
                var value = (Guid)parentId.Value;
                // Reference the value here because otherwise it gets lost in NH's query cache

                var query = NhSession.QueryOver <NodeRelation>()
                            .Where(x => x.StartNode.Id == value)
                            .Fetch(x => x.StartNode).Lazy
                            .Fetch(x => x.EndNode).Lazy
                            .Fetch(x => x.NodeRelationTags).Eager
                            .Fetch(x => x.NodeRelationType).Eager;

                if (relationType != null)
                {
                    var relationName = relationType.RelationName;
                    var listWithType = query.JoinQueryOver <NodeRelationType>(x => x.NodeRelationType)
                                       .Where(x => x.Alias == relationName)
                                       .Cacheable()
                                       .List();
                    return(listWithType.Select(MapNodeRelation));
                }

                var list = query
                           .Cacheable()
                           .List();

                return(list.Select(MapNodeRelation));
            }
        }
示例#32
0
        public static RelationType GetCounterRelationType(RelationType type)
        {
            switch (type)
            {
            case RelationType.FatherMother:
                return(RelationType.SonDaughter);

            case RelationType.SonDaughter:
                return(RelationType.FatherMother);

            case RelationType.StepFatherMother:
                return(RelationType.StepSonDaughter);

            case RelationType.StepSonDaughter:
                return(RelationType.StepFatherMother);

            case RelationType.GrandFatherMother:
                return(RelationType.GrandSonDaughter);

            case RelationType.GrandSonDaughter:
                return(RelationType.GrandFatherMother);

            case RelationType.UncleAunt:
                return(RelationType.NephewNiece);

            case RelationType.NephewNiece:
                return(RelationType.UncleAunt);

            case RelationType.InLawFatherMother:
                return(RelationType.InLawSonDaughter);

            case RelationType.InLawSonDaughter:
                return(RelationType.InLawFatherMother);

            default:
                return(type);
            }
        }
示例#33
0
        public override string ToString()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder(50);

            if (ParentObjectID.HasValue)
            {
                sb.AppendFormat("PO{0}", ParentObjectID.Value);
            }

            if (ParentObjectType.HasValue)
            {
                sb.AppendFormat("PT{0}", ParentObjectType.Value);
            }

            if (ChildObjectID.HasValue)
            {
                sb.AppendFormat("CO{0}", ChildObjectID.Value);
            }

            if (ChildObjectType.HasValue)
            {
                sb.AppendFormat("CT{0}", ChildObjectType.Value);
            }

            if (!string.IsNullOrEmpty(RelationType))
            {
                sb.AppendFormat("RT{0}", RelationType.ToLower());
            }

            if (ExcludeSystemObjects)
            {
                sb.Append("ESO");
            }

            sb.AppendFormat("ST{0}", (int)SortType);

            return(sb.ToString());
        }
示例#34
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="target"></param>
 /// <param name="relationType"></param>
 public void Remove(GObject target, RelationType relationType)
 {
     int cnt = _items.Count;
     int i = 0;
     while (i < cnt)
     {
         RelationItem item = _items[i];
         if (item.target == target)
         {
             item.Remove(relationType);
             if (item.isEmpty)
             {
                 item.Dispose();
                 _items.RemoveAt(i);
                 cnt--;
                 continue;
             }
             else
                 i++;
         }
         i++;
     }
 }
示例#35
0
        public void Populate(JMMServerBinary.Contract_AniDB_Anime_Relation details)
        {
            this.AniDB_Anime_RelationID = details.AniDB_Anime_RelationID;
            this.AnimeID        = details.AnimeID;
            this.RelationType   = details.RelationType;
            this.RelatedAnimeID = details.RelatedAnimeID;

            AniDB_SiteURL = string.Format(Constants.URLS.AniDB_Series, RelatedAnimeID);

            SortPriority = int.MaxValue;
            if (RelationType.Equals("Prequel", StringComparison.InvariantCultureIgnoreCase))
            {
                SortPriority = 1;
            }
            if (RelationType.Equals("Sequel", StringComparison.InvariantCultureIgnoreCase))
            {
                SortPriority = 2;
            }


            PopulateAnime(details.AniDB_Anime);
            PopulateSeries(details.AnimeSeries);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                RelationType relationType = db.RelationTypes.Find(id);
                db.RelationTypes.Remove(relationType);
                db.SaveChanges();
                ViewBag.MessageType = "success";
                ViewBag.Message     = "Record has been removed successfully.";
            }
            catch (DbUpdateException ex)
            {
                ViewBag.MessageType = "error";
                ViewBag.Message     = ex.Message;
                ModelState.AddModelError(string.Empty, ex.Message);
            }
            model.RelationTypes        = db.RelationTypes.OrderByDescending(a => a.RelationTypeID).ToList();
            model.SelectedRelationType = null;
            model.DisplayMode          = "WriteOnly";
            ViewBag.IsActive           = new SelectList(db.Options, "OptionDesc", "OptionDesc");

            return(View("Index", model));
        }
示例#37
0
        public bool CanAddRelation(Edge e, RelationType r)
        {
            List <Relation> list = GetVertexRelations(e.A, relations);

            list.AddRange(GetVertexRelations(e.B, relations));
            foreach (Relation rel in list)
            {
                if (rel.ContainVertex(e.A) && rel.ContainVertex(e.B))
                {
                    return(false);
                }
                if (r == RelationType.Horizontal && rel is HorizontalRelation)
                {
                    return(false);
                }
                else if (r == RelationType.Vertical && rel is VerticalRelation)
                {
                    return(false);
                }
            }

            return(true);
        }
        public IRelationType BuildEntity(RelationTypeDto dto)
        {
            var entity = new RelationType(dto.ChildObjectType, dto.ParentObjectType, dto.Alias);

            try
            {
                entity.DisableChangeTracking();

                entity.Id              = dto.Id;
                entity.Key             = dto.UniqueId;
                entity.IsBidirectional = dto.Dual;
                entity.Name            = dto.Name;

                //on initial construction we don't want to have dirty properties tracked
                // http://issues.umbraco.org/issue/U4-1946
                entity.ResetDirtyProperties(false);
                return(entity);
            }
            finally
            {
                entity.EnableChangeTracking();
            }
        }
示例#39
0
        public RelationModel(EntityModel entity1, EntityModel entity2, RelationType type, string role)
        {
            var isLeft = entity1.Name.ToLower().CompareTo(entity2.Name.ToLower()) < 0;

            Left  = isLeft ? entity1 : entity2;
            Right = isLeft ? entity2 : entity1;
            if (!isLeft)
            {
                if (type == RelationType.OneToMany)
                {
                    type = RelationType.ManyToOne;
                }
                else if (type == RelationType.ManyToOne)
                {
                    type = RelationType.OneToMany;
                }
            }

            Type = type;
            Role = role;

            Name = string.Format("{0}_{1}_{2}", Left.Name, Right.Name, Role);
        }
示例#40
0
 public BootstrapperCommand(
     LaunchAction action,
     Display display,
     Restart restart,
     string commandLine,
     int cmdShow,
     ResumeType resume,
     IntPtr splashScreen,
     RelationType relation,
     bool passthrough,
     string layoutDirectory)
 {
     this.Action          = action;
     this.Display         = display;
     this.Restart         = restart;
     this.commandLine     = commandLine;
     this.CmdShow         = cmdShow;
     this.Resume          = resume;
     this.SplashScreen    = splashScreen;
     this.Relation        = relation;
     this.Passthrough     = passthrough;
     this.LayoutDirectory = layoutDirectory;
 }
示例#41
0
        public void InternalAdd(RelationType relationType, bool usePercent)
        {
            if (relationType == RelationType.Size)
            {
                InternalAdd(RelationType.Width, usePercent);
                InternalAdd(RelationType.Height, usePercent);
                return;
            }

            RelationDef info = new RelationDef();

            info.percent = usePercent;
            info.type    = relationType;
            _defs.Add(info);

            //当使用中线关联时,因为需要除以2,很容易因为奇数宽度/高度造成小数点坐标;当使用百分比时,也会造成小数坐标;
            //所以设置了这类关联的对象,自动启用pixelSnapping
            if (usePercent || relationType == RelationType.Left_Center || relationType == RelationType.Center_Center || relationType == RelationType.Right_Center ||
                relationType == RelationType.Top_Middle || relationType == RelationType.Middle_Middle || relationType == RelationType.Bottom_Middle)
            {
                _owner.pixelSnapping = true;
            }
        }
        public void Relation_Relate_Docs_And_Delete_Parent()
        {
            var dt     = DocumentType.GetAllAsList().First();
            var parent = Document.MakeNew(Guid.NewGuid().ToString("N"), dt, m_User, -1);
            var child  = Document.MakeNew(Guid.NewGuid().ToString("N"), dt, m_User, -1);
            var rt     = RelationType.GetAll().First();

            //make the relation
            var r = Relation.MakeNew(parent.Id, child.Id, rt, Guid.NewGuid().ToString("N"));

            Assert.IsTrue(r.Id > 0);
            Assert.IsInstanceOf <Relation>(r);

            //deletes the parent
            parent.delete(true);

            //make sure it's gone by looking up both parent & children
            Assert.AreEqual(0, Relation.GetRelations(parent.Id).Count());
            Assert.AreEqual(0, Relation.GetRelations(child.Id).Count());

            //now remove the documents
            child.delete(true);
        }
示例#43
0
        public void syncCapacity()
        {
            int max      = this.Capacity;
            int signedUp = this.SignedUp;
            int waiting  = this.OnWaitingList;

            //2 scenarios, either the room is now smaller or bigger
            if (max >= signedUp)
            {
                Log.Add(LogTypes.Debug, n.Id, "bigger cap");

                //get people on the waitinglist and promote them to coming to event
                int          diff   = max - signedUp;
                RelationType coming = RelationType.GetByAlias("event");
                foreach (Relation r in Relations.EventRelation.GetPeopleWaiting(n.Id, diff))
                {
                    Log.Add(LogTypes.Debug, n.Id, "R:" + r.Id.ToString());
                    r.RelType = coming;
                    r.Save();
                }
            }
            else
            {
                Log.Add(LogTypes.Debug, n.Id, "smaller cap");

                //get people on the signedup list and put the people who signed up last on the waiting list.
                //remember to preserve the original sign-up date
                int          diff        = signedUp - max;
                RelationType waitinglist = RelationType.GetByAlias("waitinglist");
                foreach (Relation r in Relations.EventRelation.GetPeopleSignedUpLast(n.Id, diff))
                {
                    Log.Add(LogTypes.Debug, n.Id, "R:" + r.Id.ToString());
                    r.RelType = waitinglist;
                    r.Save();
                }
            }
        }
示例#44
0
        public void TestAddSession()
        {
            using (var unitOfWork = UnitOfWorkFactory.Create()) {
                var notionType = new NotionType("type");
                GetRepository <NotionType>().AddOrUpdate(notionType);

                var node1 = new Node("notion1", notionType);
                GetRepository <Node>().AddOrUpdate(node1);

                var node2 = new Node("notion2", notionType);
                GetRepository <Node>().AddOrUpdate(node2);

                var relationType = new RelationType("type");
                GetRepository <RelationType>().AddOrUpdate(relationType);

                var verge = new Verge(node1, node2, relationType, 20);
                GetRepository <Verge>().AddOrUpdate(verge);

                unitOfWork.Commit();
            }

            using (var unitOfWork = UnitOfWorkFactory.Create()) {
                var session = new SessionOfExperts("baseNotion");
                GetRepository <SessionOfExperts>().AddOrUpdate(session);

                var verge = LinqProvider.Query <Verge>().Single();
                verge.UpdateWeightFromSession(20, session);

                unitOfWork.Commit();
            }

            using (UnitOfWorkFactory.Create()) {
                var verge = LinqProvider.Query <Verge>().Single();

                verge.SessionWeightSlices.Count.Should().Be(1);
            }
        }
示例#45
0
        public void AddNewPersonWithRelation(Person person, Person child, RelationType relationType)
        {
            using (var context = new DataContext())
            {
                if (Persons.FirstOrDefault(p => p == child) == null)
                {
                    Persons.Add(child);
                    var dalPerson = child.ConvertToDalPerson();
                    context.AddPerson(dalPerson);
                    child.Id = dalPerson.Id;
                }

                var personToChild = new Relation
                {
                    SourcePerson      = person,
                    DestinationPerson = child,
                    RelationType      = relationType
                };
                var childToPerson = personToChild.GetReverseRelation();

                if (Relations.FirstOrDefault(r => r == personToChild) == null)
                {
                    Relations.Add(personToChild);
                    var dalRelation = personToChild.ConvertToDalRelation();
                    context.AddRelation(dalRelation);
                    personToChild.RelationId = dalRelation.RelationId;
                }

                if (Relations.FirstOrDefault(r => r == childToPerson) == null)
                {
                    Relations.Add(childToPerson);
                    var dalRelation = childToPerson.ConvertToDalRelation();
                    context.AddRelation(dalRelation);
                    childToPerson.RelationId = dalRelation.RelationId;
                }
            }
        }
示例#46
0
        public ActionResult AddToQueue(JsonSong song)
        {
            object json = new { message = "ok" };

            if (User != null && User is FacebookPrincipal && (User as FacebookPrincipal).IsInRole("Triphulcas"))
            {
                bool       found = false;
                Document[] temas = GetTemasInGramola();
                foreach (var tema in temas)
                {
                    if (tema.getProperty("songID").Value.ToString() == song.SongID)
                    {
                        found = true;
                        json  = new { message = "already in queue" };
                        break;
                    }
                }
                if (!found)
                {
                    var currentUser = User as FacebookPrincipal;
                    var memberId    = currentUser.GetMember().Id;

                    RelationType type    = RelationType.GetByAlias("userSongs");
                    DocumentType docType = DocumentType.GetByAlias("Tema");
                    var          doc     = Document.MakeNew(String.Format("{0}_tema_{1}_{2}", currentUser.UniqueLink, song.SongName, song.ArtistName), docType, umbraco.BusinessLogic.User.GetUser(1), 1210);//user "triphulca", parent: Gramola page
                    doc.getProperty("songID").Value     = song.SongID;
                    doc.getProperty("songName").Value   = song.SongName;
                    doc.getProperty("artistName").Value = song.ArtistName;

                    Relation.MakeNew(memberId, doc.Id, type, "new song");
                    doc.Publish(umbraco.BusinessLogic.User.GetUser(1));//user "triphulca"
                    umbraco.library.UpdateDocumentCache(doc.Id);
                }
            }

            return(Json(json, JsonRequestBehavior.DenyGet));
        }
        public void Can_Perform_Add_On_RelationTypeRepository()
        {
            // Arrange
            var provider = TestObjects.GetScopeProvider(Logger);

            using (var scope = ScopeProvider.CreateScope())
            {
                var repository = CreateRepository(provider);

                // Act
                var relateMemberToContent = new RelationType(Constants.ObjectTypes.Member,
                                                             Constants.ObjectTypes.Document,
                                                             "relateMemberToContent")
                {
                    IsBidirectional = true, Name = "Relate Member to Content"
                };

                repository.Save(relateMemberToContent);

                // Assert
                Assert.That(relateMemberToContent.HasIdentity, Is.True);
                Assert.That(repository.Exists(relateMemberToContent.Id), Is.True);
            }
        }
        public PullUpRelationTypeWizard(Repository repository, RelationType relationType)
        {
            this.InitializeComponent();

            this.repository   = repository;
            this.relationType = relationType;

            this.relationTypeTextBox.Text = relationType.ToString();

            foreach (var superDomain in this.repository.Domain.DirectSuperDomains)
            {
                if (!superDomain.IsAllorsUnitDomain)
                {
                    this.pullUpToComboBox.Items.Add(superDomain);
                }
            }

            if (this.pullUpToComboBox.Items.Count == 1)
            {
                this.pullUpToComboBox.SelectedIndex = 0;
            }

            this.CreatePullUp();
        }
 public bool SaveProfileInfo(string firstName = null, string lastName = null, string maidenName = null, Sex? sex = null,
     RelationType? relation = null, long? relationPartnerId = null, DateTime? birthDate = null, BirthdayVisibility? birthDateVisibility = null,
     string homeTown = null, long? countryId = null, long? cityId = null)
 {
     ChangeNameRequest request;
     var parameters = new AccountSaveProfileInfoParams
     {
         FirstName = firstName,
         LastName = lastName,
         MaidenName = maidenName,
         Sex = sex.Value,
         Relation = relation.Value,
         RelationPartner = relationPartnerId.HasValue ? new User { Id = relationPartnerId.Value } : null,
         BirthDate = birthDate?.ToShortDateString(),
         BirthdayVisibility = birthDateVisibility.Value,
         HomeTown = homeTown,
         Country = new Country { Id = countryId },
         City = new City
         {
             Id = cityId
         }
     };
     return SaveProfileInfo(out request, parameters);
 }
示例#50
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="target"></param>
 /// <param name="relationType"></param>
 public void RemoveRelation(GObject target, RelationType relationType)
 {
     relations.Remove(target, relationType);
 }
		private static RelationType GuessRelation(PropertyInfo property, RelationType type)
		{
			if (type != RelationType.Guess)
				return type;
			Type propertyType = property.PropertyType;

			if (!propertyType.IsInterface)
			{
				throw new ActiveRecordException(String.Format(
				                                	"Type of property {0}.{1} must be an interface (IList, ISet, IDictionary or their generic counter parts). You cannot use ArrayList or List<T> as the property type.",
				                                	property.DeclaringType.Name, property.Name));
			}

			if (propertyType == typeof (IList))
			{
				return RelationType.Bag;
			}
			else if (propertyType == typeof (ISet))
			{
				return RelationType.Set;
			}
			else if (propertyType == typeof (IDictionary))
			{
				return RelationType.Map;
			}
			else if (propertyType.IsGenericType)
			{
				Type genericTypeDefinition = propertyType.GetGenericTypeDefinition();
				if (genericTypeDefinition == typeof (IList<>) ||
				    genericTypeDefinition == typeof (ICollection<>))
				{
					return RelationType.Bag;
				}
				else if (genericTypeDefinition == typeof (Iesi.Collections.Generic.ISet<>))
				{
					return RelationType.Set;
				}
				else if (genericTypeDefinition == typeof (IDictionary<,>))
				{
					return RelationType.Map;
				}
			}

			throw new ActiveRecordException(String.Format(
			                                	"Could not guess relation type for property {0}.{1}  ",
			                                	property.DeclaringType.Name, property.Name));
		}
示例#52
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="target"></param>
 /// <param name="relationType"></param>
 public void AddRelation(GObject target, RelationType relationType)
 {
     AddRelation(target, relationType, false);
 }
示例#53
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="target"></param>
 /// <param name="relationType"></param>
 /// <param name="usePercent"></param>
 public void AddRelation(GObject target, RelationType relationType, bool usePercent)
 {
     relations.Add(target, relationType, usePercent);
 }
        public static void AddRelation(Entity fromEntity, PropertyType fromPropertyType, Entity toEntity, PropertyType toPropertyType, RelationType relationType)
        {
            if (fromEntity == null || toEntity == null)
                return;

            Property fromProperty = ProjectUtilities.FindByPropertyType(fromEntity, fromPropertyType);
            Property toProperty = ProjectUtilities.FindByPropertyType(toEntity, toPropertyType);

            if (fromProperty == null || toProperty == null)
                return;

            switch (relationType)
            {
                case RelationType.OneToOne:
                    fromProperty.TypeName = toEntity.ClrFullTypeName;
                    toProperty.TypeName = fromEntity.ClrFullTypeName;
                    break;
                case RelationType.OneToMany:
                    fromProperty.TypeName = toEntity.ClrFullTypeName;
                    toProperty.TypeName = fromEntity.Set.ClrFullTypeName;
                    break;
                case RelationType.ManyToOne:
                    fromProperty.TypeName = toEntity.Set.ClrFullTypeName;
                    toProperty.TypeName = fromEntity.ClrFullTypeName;
                    break;
                case RelationType.ManyToMany:
                    fromProperty.TypeName = toEntity.Set.ClrFullTypeName;
                    toProperty.TypeName = fromEntity.Set.ClrFullTypeName;
                    break;
            }

            fromProperty.SetRelation(toProperty, relationType);

            switch (relationType)
            {
                case RelationType.OneToMany:
                    toProperty.CascadeDelete = CascadeType.Before;
                    break;
                case RelationType.ManyToOne:
                    fromProperty.CascadeDelete = CascadeType.Before;
                    break;
            }
        }
 public ProvidedAssociationAttribute(RelationType relationType)
     : this(null, relationType, null)
 {
 }
示例#56
0
		private void GotoList(string title, string subTitle, IEnumerable<User> list, RelationType relation)
		{
			try
			{
				var root = new RootElement(title) {
					new Section() 					
				};
				
				foreach (User user in list)
				{
					root[0].Add(new UserElementII(user, relation));
				}
				root.UnevenRows = true;
				
				var selectedVC = AppDelegateIPhone.AIphone.GetCurrentNavControler();
				var rvc = new RelationsViewController(selectedVC, title, subTitle, root);
				selectedVC.PushViewController (rvc, false);
			}
			catch (Exception ex)
			{
				Util.LogException("GotoList : " + title, ex);
			}
		}		
示例#57
0
		public UserElementII (User user, RelationType relation) : this (user)
		{
			Relation = relation;
		}
示例#58
0
		private void WriteCollection(ManyRelationCascadeEnum cascadeEnum,
		                             Type targetType, RelationType type, string name,
		                             string accessString, string table, string schema, bool lazy,
		                             bool inverse, string orderBy, string where, string sort,
		                             string columnKey, string[] compositeKeyColumnKeys, string element, string elementType,
		                             string columnRef, string[] compositeKeyColumnRefs,
		                             IVisitable extraModel, string index, string indexType, CacheEnum cache, string cacheregion,
		                             NotFoundBehaviour notFoundBehaviour, FetchEnum fetch, int batchSize, Type collectionType)
		{
			bool extraModelVisited = false;

			String cascade = TranslateCascadeEnum(cascadeEnum);
			String notFoundMode = TranslateNotFoundBehaviourEnum(notFoundBehaviour);
			String fetchString = TranslateFetch(fetch);

			String closingTag = null;

			if (type == RelationType.Guess)
				throw new ActiveRecordException(string.Format("Failed to guess the relation for {0}", name));

			if (type == RelationType.Bag)
			{
				closingTag = "</bag>";

				AppendF("<bag{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}>",
				        MakeAtt("name", name),
				        MakeAtt("access", accessString),
				        WriteIfNonNull("table", table),
				        WriteIfNonNull("schema", schema),
				        MakeAtt("lazy", lazy),
				        WriteIfTrue("inverse", inverse),
				        WriteIfNonNull("cascade", cascade),
				        WriteIfNonNull("order-by", orderBy),
				        WriteIfNonNull("where", where),
				        WriteIfNonNull("fetch", fetchString),						
                        WriteIfNotOne("batch-size", batchSize),
						WriteIfNonNull("collection-type", MakeTypeName(collectionType)));
			}
			else if (type == RelationType.Set)
			{
				closingTag = "</set>";

				AppendF("<set{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}>",
				        MakeAtt("name", name),
				        MakeAtt("access", accessString),
				        WriteIfNonNull("table", table),
				        WriteIfNonNull("schema", schema),
				        MakeAtt("lazy", lazy),
				        WriteIfTrue("inverse", inverse),
				        WriteIfNonNull("cascade", cascade),
				        WriteIfNonNull("order-by", orderBy),
				        WriteIfNonNull("where", where),
				        WriteIfNonNull("sort", sort),
                        WriteIfNonNull("fetch", fetchString),
						WriteIfNotOne("batch-size", batchSize),
						WriteIfNonNull("collection-type", MakeTypeName(collectionType)));
			}
			else if (type == RelationType.IdBag)
			{
				closingTag = "</idbag>";

				AppendF("<idbag{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}>",
				        MakeAtt("name", name),
				        MakeAtt("access", accessString),
				        WriteIfNonNull("table", table),
				        WriteIfNonNull("schema", schema),
				        MakeAtt("lazy", lazy),
				        WriteIfNonNull("cascade", cascade),
				        WriteIfNonNull("order-by", orderBy),
				        WriteIfNonNull("where", where),
                        WriteIfNonNull("fetch", fetchString),
						WriteIfNotOne("batch-size", batchSize),
						WriteIfNonNull("collection-type", MakeTypeName(collectionType)));
				extraModelVisited = true;
				Ident();
				VisitNode(extraModel);
				Dedent();
			}
			else if (type == RelationType.Map)
			{
				closingTag = "</map>";

				AppendF("<map{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}>",
				        MakeAtt("name", name),
				        MakeAtt("access", accessString),
				        WriteIfNonNull("table", table),
				        WriteIfNonNull("schema", schema),
				        MakeAtt("lazy", lazy),
				        WriteIfTrue("inverse", inverse),
				        WriteIfNonNull("cascade", cascade),
				        WriteIfNonNull("order-by", orderBy),
				        WriteIfNonNull("where", where),
				        WriteIfNonNull("sort", sort),
                        WriteIfNonNull("fetch", fetchString),
						WriteIfNotOne("batch-size", batchSize),
						WriteIfNonNull("collection-type", MakeTypeName(collectionType)));
			}
			else if (type == RelationType.List)
			{
				closingTag = "</list>";
				AppendF("<list{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}>",
				        MakeAtt("name", name),
				        MakeAtt("access", accessString),
				        WriteIfNonNull("table", table),
				        WriteIfNonNull("schema", schema),
				        MakeAtt("lazy", lazy),
				        WriteIfTrue("inverse", inverse),
				        WriteIfNonNull("cascade", cascade),
				        WriteIfNonNull("where", where),
                        WriteIfNonNull("fetch", fetchString),
						WriteIfNotOne("batch-size", batchSize),
						WriteIfNonNull("collection-type", MakeTypeName(collectionType)));
			}


			Ident();

			WriteCache(cache, cacheregion);

			if (columnKey == null)
			{
				Append("<key>");
				Ident();
				WriteCompositeColumns(compositeKeyColumnKeys);
				Dedent();
				Append("</key>");
			}
			else
			{
				WriteKey(columnKey);
			}

			if (type == RelationType.Map || type == RelationType.List)
			{
				WriteIndex(index, indexType);
			}

			if (element != null || elementType != null)
			{
				WriteElement(element, elementType, targetType);
			}
			else if (columnRef == null && compositeKeyColumnRefs == null)
			{
				if (extraModel == null)
				{
					WriteOneToMany(targetType, notFoundMode);
				}
				else if (!extraModelVisited)
				{
					VisitNode(extraModel);
				}
			}
			else
			{
				if (columnRef != null)
				{
					WriteManyToMany(targetType, columnRef, notFoundMode);
				}
				else
				{
					WriteManyToMany(targetType, compositeKeyColumnRefs, notFoundMode);
				}
			}

			Dedent();

			Append(closingTag);
		}
示例#59
0
文件: Element.cs 项目: mono/uia2atk
		internal Relation GetRelation (RelationType type)
		{
			Relation [] relations = accessible.RelationSet;
			foreach (Relation relation in relations)
				if (relation.Type == type)
					return relation;
			return null;
		}
示例#60
0
 /// <summary>
 /// Creates a new instance of the <see cref="DetectRelatedBundleEventArgs"/> class.
 /// </summary>
 /// <param name="productCode">The identity of the related package bundle.</param>
 /// <param name="relationType">Relationship type for this related bundle.</param>
 /// <param name="bundleTag">The tag of the related package bundle.</param>
 /// <param name="perMachine">Whether the detected bundle is per machine.</param>
 /// <param name="version">The version of the related bundle detected.</param>
 /// <param name="operation">The operation that will be taken on the detected bundle.</param>
 public DetectRelatedBundleEventArgs(string productCode, RelationType relationType, string bundleTag, bool perMachine, long version, RelatedOperation operation)
 {
     this.productCode = productCode;
     this.relationType = relationType;
     this.bundleTag = bundleTag;
     this.perMachine = perMachine;
     this.version = new Version((int)(version >> 48 & 0xFFFF), (int)(version >> 32 & 0xFFFF), (int)(version >> 16 & 0xFFFF), (int)(version & 0xFFFF));
     this.operation = operation;
 }