protected BaseEntityWrapper(
     TEntity entity,
     RelationshipManager relationshipManager,
     EntitySet entitySet,
     ObjectContext context,
     MergeOption mergeOption,
     Type identityType,
     bool overridesEquals)
 {
     if (relationshipManager == null)
     {
         throw new InvalidOperationException(Strings.RelationshipManager_UnexpectedNull);
     }
     this._identityType        = identityType;
     this._relationshipManager = relationshipManager;
     if (overridesEquals)
     {
         this._flags = BaseEntityWrapper <> .WrapperFlags.OverridesEquals;
     }
     this.RelationshipManager.SetWrappedOwner((IEntityWrapper)this, (object)entity);
     if (entitySet == null)
     {
         return;
     }
     this.Context     = context;
     this.MergeOption = mergeOption;
     this.RelationshipManager.AttachContextToRelatedEnds(context, entitySet, mergeOption);
 }
Exemple #2
0
    private void GetAndSetEnemiesInArea()
    {
        NearbyColliders = Physics2D.OverlapCircleAll(transform.position, checkRadius, Utilities.bulletIgnoreLayerMask);
        bool foundOneMilitaryEnemy = false;
        bool foundOneEnemy         = false;
        bool foundOneAsteroid      = false;

        if (!gameObject.tag.Equals("Untagged"))
        {
            foreach (Collider2D collider in NearbyColliders)
            {
                if (!collider.tag.Equals("Asteroid"))
                {
                    if (RelationshipManager.AreFactionsInWar(gameObject.tag, collider.tag))
                    {
                        foundOneEnemy = true;

                        if (collider.gameObject.layer == 9)
                        {
                            foundOneMilitaryEnemy = true;
                            break;
                        }
                    }
                }
                else
                {
                    foundOneAsteroid = true;
                }
            }
        }

        EnemyNearby         = foundOneEnemy;
        EnemyMilitaryNearby = foundOneMilitaryEnemy;
        AsteroidNearby      = foundOneAsteroid;
    }
Exemple #3
0
        /// <summary>
        /// Method called by proxy interceptor delegate to provide lazy loading behavior for navigation properties.
        /// </summary>
        /// <typeparam name="TItem">property type</typeparam>
        /// <param name="propertyValue">The property value whose associated relationship is to be loaded.</param>
        /// <param name="relationshipName">String name of the relationship.</param>
        /// <param name="targetRoleName">String name of the related end to be loaded for the relationship specified by <paramref name="relationshipName"/>.</param>
        /// <param name="wrapperObject">Entity wrapper object used to retrieve RelationshipManager for the proxied entity.</param>
        /// <returns>
        /// True if the value instance was mutated and can be returned
        /// False if the class should refetch the value because the instance has changed
        /// </returns>
        private static bool LoadProperty <TItem>(TItem propertyValue, string relationshipName, string targetRoleName, bool mustBeNull, object wrapperObject) where TItem : class
        {
            // Only attempt to load collection if:
            //
            // 1. Collection is non-null.
            // 2. ObjectContext.ContextOptions.LazyLoadingEnabled is true
            // 3. A non-null RelationshipManager can be retrieved (this is asserted).
            // 4. The EntityCollection is not already loaded.

            Debug.Assert(wrapperObject == null || wrapperObject is IEntityWrapper, "wrapperObject must be an IEntityWrapper");
            IEntityWrapper wrapper = (IEntityWrapper)wrapperObject; // We want an exception if the cast fails.

            if (wrapper != null && wrapper.Context != null)
            {
                RelationshipManager relationshipManager = wrapper.RelationshipManager;
                Debug.Assert(relationshipManager != null, "relationshipManager should be non-null");
                if (relationshipManager != null && (!mustBeNull || propertyValue == null))
                {
                    RelatedEnd relatedEnd = relationshipManager.GetRelatedEndInternal(relationshipName, targetRoleName);
                    relatedEnd.DeferredLoad();
                }
            }

            return(propertyValue != null);
        }
Exemple #4
0
        private bool IsEntityRequiredForeignKeyEmpty(DbEntityEntry entityEntry, string errProp)
        {
            RelationshipManager relMgr =
                ((IObjectContextAdapter)this).ObjectContext.ObjectStateManager
                .GetRelationshipManager(entityEntry.Entity);
            IEnumerable <IRelatedEnd> relEnds = relMgr.GetAllRelatedEnds();
            IRelatedEnd relEnd = relEnds.Where(r =>
            {
                var elementType      = (EntityTypeBase)r.RelationshipSet.ElementType;
                var metadataProperty = elementType.MetadataProperties.GetValue(
                    "ReferentialConstraints", false);
                var referentialConstraints =
                    (
                        System.Data.Entity.Core.Metadata.Edm.ReadOnlyMetadataCollection
                        <ReferentialConstraint>)metadataProperty.Value;
                if (referentialConstraints.Any(constraint =>
                {
                    return
                    (constraint.ToProperties.Any(
                         t => t.Nullable == false && t.IsPrimitiveType && t.Name == errProp));
                }))
                {
                    return(true);
                }
                return(false);
            }).FirstOrDefault();
            bool isEntityRequiredForeignKeyEmpty = relEnd != null;

            return(isEntityRequiredForeignKeyEmpty);
        }
        public override void PrepareContent(HeapCellArrayWithStatistics aCells, HeapStatistics aStats)
        {
            try
            {
                HeapCell cell = aCells[0];
                System.Diagnostics.Debug.Assert(cell.Type == HeapCell.TType.EAllocated);
                System.Diagnostics.Debug.Assert(cell.Symbol != null);
                RelationshipManager relMgr = cell.RelationshipManager;
                //
                TrackingInfo info      = aStats.StatsAllocated.TrackerSymbols[cell.Symbol];
                int          instCount = info.AssociatedCellCount;
                //
                Title = instCount + " Instance(s)";
                //
                StringBuilder msg = new StringBuilder();
                //
                msg.AppendFormat("This allocated cell is an instance of {0} from {1}", cell.Symbol.NameWithoutVTablePrefix, cell.Symbol.ObjectWithoutSection);
                msg.Append(System.Environment.NewLine + System.Environment.NewLine);

                msg.AppendFormat("There {0} {1} instance{2} of this symbol, with each instance using {3} bytes of memory (plus cell header overhead).", (instCount == 0 || instCount > 1) ? "are" : "is", info.AssociatedCellCount, (instCount == 0 || instCount > 1) ? "s" : string.Empty, cell.PayloadLength);
                msg.Append(System.Environment.NewLine + System.Environment.NewLine);
                //
                msg.AppendFormat("In total, cells of this type use {0} bytes of heap memory", info.AssociatedMemory);
                msg.Append(System.Environment.NewLine + System.Environment.NewLine);
                //
                msg.AppendFormat("This cell references {0} other cell(s), and is referenced by {1} cell(s)", relMgr.EmbeddedReferencesTo.Count, relMgr.ReferencedBy.Count);
                msg.Append(System.Environment.NewLine + System.Environment.NewLine);
                //
                iLbl_Description.Text = msg.ToString();
            }
            finally
            {
                base.PrepareContent(aCells, aStats);
            }
        }
        public async Task <IHttpActionResult> Unsubscribe(int id)
        {
            try
            {
                using (NoticeBoardManager db = new NoticeBoardManager())
                {
                    var board = await db.GetAsync(id);

                    RelationshipManager rm = new RelationshipManager();
                    int result             = await rm.DeleteAsync(
                        new UserNoticeBoardFollow
                    {
                        NoticeBoardId = id,
                        UserId        = (await User.Identity.GetApplicationUserAsync()).Id
                    }
                        );

                    if (result > 0)
                    {
                        return(Ok(JsonViewModel.Success));
                    }
                }
            }
            catch
            {
                return(InternalServerError());
            }
            return(NotFound());
        }
    private RelationshipRank GetNearbyRelationship()
    {
        PlayerUnit playerUnit = GetComponent <PlayerUnit>();

        if (playerUnit == null)
        {
            return(RelationshipRank.NONE);
        }

        List <PlayerUnit> nearbyUnits = playerUnit.GetNearbyUnits();

        if (nearbyUnits.Count == 0)
        {
            return(RelationshipRank.NONE);
        }

        RelationshipRank rank = RelationshipRank.NONE;

        foreach (PlayerUnit unit in nearbyUnits)
        {
            RelationshipRank currentRank = RelationshipManager.GetRelationshipBetween(ID, unit.GetComponent <UnitStats>().ID).GetRank();
            if (currentRank > rank)
            {
                rank = currentRank;
            }
        }

        return(rank);
    }
Exemple #8
0
        public static EntityCollection <TElement> CreateCollection <T, TElement>(this T entity, Expression <Func <T, EntityCollection <TElement> > > expr, params TElement[] items)
            where T : EntityObject
            where TElement : EntityObject
        {
            if (expr.Body.NodeType != ExpressionType.MemberAccess)
            {
                throw new ArgumentException("Expression is not correct.", "expr");
            }
            var          member = ((MemberExpression)expr.Body).Member;
            PropertyInfo pi     = member as PropertyInfo;

            if (pi == null)
            {
                throw new ArgumentException("Expression is not correct.", "expr");
            }
            EdmRelationshipNavigationPropertyAttribute attribute = (EdmRelationshipNavigationPropertyAttribute)Attribute.GetCustomAttribute(pi, typeof(EdmRelationshipNavigationPropertyAttribute));
            EntityCollection <TElement> result = new EntityCollection <TElement>();
            RelationshipManager         rm     = RelationshipManager.Create(entity);

            rm.InitializeRelatedCollection(attribute.RelationshipName, attribute.TargetRoleName, result);
            foreach (var item in items)
            {
                result.Add(item);
            }
            return(result);
        }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Z))
        {
            print("STARTING WAR BETWEEN ALL FACTIONS!");
            RelationshipManager.StartWar("Faction1", "Faction2");
            RelationshipManager.StartWar("Faction2", "Faction1");

            RelationshipManager.StartWar("Faction1", "Faction3");
            RelationshipManager.StartWar("Faction3", "Faction1");

            RelationshipManager.StartWar("Faction3", "Faction2");
            RelationshipManager.StartWar("Faction2", "Faction3");
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            print("ENDING WAR BETWEEN ALL FACTIONS!");
            RelationshipManager.EndWar("Faction1", "Faction2");
            RelationshipManager.EndWar("Faction2", "Faction1");

            RelationshipManager.EndWar("Faction1", "Faction3");
            RelationshipManager.EndWar("Faction3", "Faction1");

            RelationshipManager.EndWar("Faction3", "Faction2");
            RelationshipManager.EndWar("Faction2", "Faction3");
        }
    }
Exemple #10
0
 private void Awake()
 {
     FactionsManager.SetFactions();
     RelationshipManager.InitializeRelations();
     ShipsManager.SetFactions();
     BuildingsManager.SetFactions();
 }
Exemple #11
0
        public override void Execute()
        {
            AppMapMarkers appMapMarkers = Pool.Get <AppMapMarkers>();

            appMapMarkers.markers = Pool.GetList <AppMarker>();
            RelationshipManager.PlayerTeam playerTeam = RelationshipManager.ServerInstance.FindPlayersTeam(base.UserId);
            if (playerTeam != null)
            {
                foreach (ulong member in playerTeam.members)
                {
                    BasePlayer basePlayer = RelationshipManager.FindByID(member);
                    if (!(basePlayer == null))
                    {
                        appMapMarkers.markers.Add(GetPlayerMarker(basePlayer));
                    }
                }
            }
            else if (base.Player != null)
            {
                appMapMarkers.markers.Add(GetPlayerMarker(base.Player));
            }
            foreach (MapMarker serverMapMarker in MapMarker.serverMapMarkers)
            {
                if (serverMapMarker.appType != 0)
                {
                    appMapMarkers.markers.Add(serverMapMarker.GetAppMarkerData());
                }
            }
            AppResponse appResponse = Pool.Get <AppResponse>();

            appResponse.mapMarkers = appMapMarkers;
            Send(appResponse);
        }
Exemple #12
0
        public ActionResult AddFriend(User user)
        {
            if (Authenticate.IsAuthenticated())
            {
                User loggedinUser = (User)Session["user"];
                if (!RelationshipManager.isRelated(user, loggedinUser))
                {
                    Relationship relationship = new Relationship();
                    relationship.Friend1  = loggedinUser;
                    relationship.Friend2  = user;
                    relationship.isFriend = false;

                    RelationshipManager.Insert(relationship);

                    return(View(user));
                }
                else
                {
                    ViewBag.Message = "You two are already friends";
                    return(RedirectToAction("Detail", "User", new { id = user.Id }));
                }
            }
            else
            {
                return(RedirectToAction("Login", "User", new { returnurl = HttpContext.Request.Url }));
            }
        }
Exemple #13
0
    private void showRelationshipData()
    {
        Relationship relationship = new Relationship();

        relationship             = RelationshipManager.GetRelationshipByRelationshipID(Int32.Parse(Request.QueryString["ID"]));
        txtRelationshipName.Text = relationship.RelationshipName.ToString();
    }
            public DamageGroup(ulong playerId, float damage)
            {
                TotalDamage        = damage;
                FirstDamagerDealer = playerId;

                if (!Instance.config.UseTeams)
                {
                    return;
                }

                var target = RelationshipManager.FindByID(playerId);

                if (!target.IsValid())
                {
                    return;
                }

                RelationshipManager.PlayerTeam team;
                if (!RelationshipManager.Instance.playerToTeam.TryGetValue(playerId, out team))
                {
                    return;
                }

                for (int i = 0; i < team.members.Count; i++)
                {
                    ulong member = team.members[i];

                    if (member == playerId)
                    {
                        continue;
                    }

                    additionalPlayers.Add(member);
                }
            }
    public void UpdateButtons(Point pos)
    {
        adjacentUnit = DirectionsExtensions.GetAdjacentPlayer(controller.board, pos);

        if (adjacentUnit == null)
        {
            talkButton.gameObject.SetActive(false);
            comboUI.gameObject.SetActive(false);

            return;
        }

        UnitID adjacentID = adjacentUnit.GetComponent <UnitStats>().ID;

        if (!controller.currentUnit.talked &&
            BattleDialogue.StillHasDialogue(currentUnit, adjacentID) &&
            !controller.talked)
        {
            talkButton.gameObject.SetActive(true);
        }

        comboUI.gameObject.SetActive(true);
        UnitPair pair = RelationshipManager.GetRelationshipPair(currentUnit, adjacentID);

        comboUI.SetWithoutObj(GameInformation.instance.GetComboInfo(pair));
    }
Exemple #16
0
 // <summary>
 // Constructs a wrapper for the given entity.
 // Note: use EntityWrapperFactory instead of calling this constructor directly.
 // </summary>
 // <param name="entity"> The entity to wrap </param>
 // <param name="propertyStrategy"> A delegate to create the property accesor strategy object </param>
 // <param name="changeTrackingStrategy"> A delegate to create the change tracking strategy object </param>
 // <param name="keyStrategy"> A delegate to create the entity key strategy object </param>
 internal EntityWrapperWithoutRelationships(
     TEntity entity, Func <object, IPropertyAccessorStrategy> propertyStrategy,
     Func <object, IChangeTrackingStrategy> changeTrackingStrategy, Func <object, IEntityKeyStrategy> keyStrategy,
     bool overridesEquals)
     : base(entity, RelationshipManager.Create(), propertyStrategy, changeTrackingStrategy, keyStrategy, overridesEquals)
 {
 }
            private List <DamageGroup> GetDamageGroups()
            {
                var result = new List <DamageGroup>();

                foreach (var damage in damageEntries)
                {
                    bool merged = false;

                    foreach (var dT in result)
                    {
                        if (dT.TryMergeDamage(damage.Key, damage.Value.DamageDealt))
                        {
                            merged = true;
                            break;
                        }
                    }

                    if (!merged)
                    {
                        if (RelationshipManager.FindByID(damage.Key) == null)
                        {
                            Instance.PrintError($"Invalid id, unable to find: {damage.Key}");
                            continue;
                        }

                        result.Add(new DamageGroup(damage.Key, damage.Value.DamageDealt));
                    }
                }

                return(result);
            }
    public void ShowRelationship(UnitID current, UnitID other)
    {
        UpdateButtons();

        relationship = RelationshipManager.GetRelationshipBetween(current, other);
        otherUnit    = GameInformation.instance.GetPlayerInfo(other);
        currentUnit  = current;

        unitSprite.sprite = otherUnit.unitSprite;
        nameText.text     = otherUnit.name;

        curr = -1;
        switch (relationship.GetRank())
        {
        case RelationshipRank.CRUDE:
            curr = 0;
            break;

        case RelationshipRank.BLAND:
            curr = 1;
            break;

        case RelationshipRank.APPETIZING:
            curr = 2;
            break;

        case RelationshipRank.SPICY:
            curr = 3;
            break;
        }

        UpdateRelationships();
    }
        public async Task <JsonResult> Unsubscribe(int noticeboardId)
        {
            try
            {
                var board = await db.GetAsync(noticeboardId);

                RelationshipManager rm = new RelationshipManager();
                int result             = await rm.DeleteAsync(
                    new UserNoticeBoardFollow
                {
                    NoticeBoardId = noticeboardId,
                    UserId        = (await User.Identity.GetApplicationUserAsync()).Id
                }
                    );

                if (result > 0)
                {
                    return(Json(JsonViewModel.Success, JsonRequestBehavior.DenyGet));
                }
            }
            catch
            {
                return(Json(JsonViewModel.Error, JsonRequestBehavior.DenyGet));
            }
            return(Json(JsonViewModel.Error, JsonRequestBehavior.DenyGet));
        }
Exemple #20
0
 /// <summary>
 ///
 /// </summary>
 private void Initialize()
 {
     RelationshipManager = new RelationshipManager();
     MyAPIGateway.Utilities.InvokeOnGameThread(() => SetUpdateOrder(MyUpdateOrder.NoUpdate));
     WriteToLog("FactionCore", $"Initialized... {UpdateOrder}", true);
     _initialized = true;
 }
 public override void Save(BaseNetworkable.SaveInfo info)
 {
     base.Save(info);
     info.msg.relationshipManager = (__Null)Pool.Get <RelationshipManager>();
     ((RelationshipManager)info.msg.relationshipManager).maxTeamSize = (__Null)RelationshipManager.maxTeamSize;
     if (!info.forDisk)
     {
         return;
     }
     ((RelationshipManager)info.msg.relationshipManager).lastTeamIndex = (__Null)(long)this.lastTeamIndex;
     ((RelationshipManager)info.msg.relationshipManager).teamList      = (__Null)Pool.GetList <ProtoBuf.PlayerTeam>();
     foreach (KeyValuePair <ulong, RelationshipManager.PlayerTeam> playerTeam1 in this.playerTeams)
     {
         RelationshipManager.PlayerTeam playerTeam2 = playerTeam1.Value;
         if (playerTeam2 != null)
         {
             ProtoBuf.PlayerTeam playerTeam3 = (ProtoBuf.PlayerTeam)Pool.Get <ProtoBuf.PlayerTeam>();
             playerTeam3.teamLeader = (__Null)(long)playerTeam2.teamLeader;
             playerTeam3.teamID     = (__Null)(long)playerTeam2.teamID;
             playerTeam3.teamName   = (__Null)playerTeam2.teamName;
             playerTeam3.members    = (__Null)Pool.GetList <ProtoBuf.PlayerTeam.TeamMember>();
             foreach (ulong member in playerTeam2.members)
             {
                 ProtoBuf.PlayerTeam.TeamMember teamMember = (ProtoBuf.PlayerTeam.TeamMember)Pool.Get <ProtoBuf.PlayerTeam.TeamMember>();
                 BasePlayer byId = RelationshipManager.FindByID(member);
                 teamMember.displayName = Object.op_Inequality((Object)byId, (Object)null) ? (__Null)byId.displayName : (__Null)"DEAD";
                 teamMember.userID      = (__Null)(long)member;
                 ((List <ProtoBuf.PlayerTeam.TeamMember>)playerTeam3.members).Add(teamMember);
             }
             ((List <ProtoBuf.PlayerTeam>)((RelationshipManager)info.msg.relationshipManager).teamList).Add(playerTeam3);
         }
     }
 }
Exemple #22
0
 public override void PrepareContent(HeapCellArrayWithStatistics aCells, HeapStatistics aStats, RawItem aRawItem)
 {
     try
     {
         System.Diagnostics.Debug.Assert(aCells.Count == 1);
         System.Diagnostics.Debug.Assert(aRawItem.Tag != null && aRawItem.Tag is RelationshipInfo);
         HeapCell            cell    = aCells[0];
         RelationshipManager relMgr  = cell.RelationshipManager;
         RelationshipInfo    relInfo = (RelationshipInfo)aRawItem.Tag;
         //
         StringBuilder msg = new StringBuilder();
         //
         msg.AppendFormat("This is an embedded reference to the cell at address 0x{0}", relInfo.ToCell.Address.ToString("x8"));
         if (relInfo.ToCell.Symbol != null)
         {
             msg.AppendFormat(", which is an instance of a {0} object.", relInfo.ToCell.SymbolString);
         }
         msg.Append(System.Environment.NewLine + System.Environment.NewLine);
         //
         msg.AppendFormat("In total, this cell references {0} other cell(s), and is referenced by {1} cell(s)", relMgr.EmbeddedReferencesTo.Count, relMgr.ReferencedBy.Count);
         msg.Append(System.Environment.NewLine + System.Environment.NewLine);
         //
         iLbl_Description.Text = msg.ToString();
     }
     finally
     {
         base.PrepareContent(aCells, aStats, aRawItem);
     }
 }
        public bool RemovePlayer(ulong playerID)
        {
            if (!this.members.Contains(playerID))
            {
                return(false);
            }
            this.members.Remove(playerID);
            BasePlayer basePlayer = RelationshipManager.FindByID(playerID);

            if (basePlayer != null)
            {
                basePlayer.ClearTeam();
            }
            if (this.teamLeader == playerID)
            {
                if (this.members.Count <= 0)
                {
                    this.Disband();
                }
                else
                {
                    this.SetTeamLeader(this.members[0]);
                }
            }
            this.MarkDirty();
            return(true);
        }
        public bool RemovePlayer(ulong playerID)
        {
            if (!this.members.Contains(playerID))
            {
                return(false);
            }
            this.members.Remove(playerID);
            BasePlayer byId = RelationshipManager.FindByID(playerID);

            if (Object.op_Inequality((Object)byId, (Object)null))
            {
                byId.ClearTeam();
            }
            if ((long)this.teamLeader == (long)playerID)
            {
                if (this.members.Count > 0)
                {
                    this.SetTeamLeader(this.members[0]);
                }
                else
                {
                    this.Disband();
                }
            }
            this.MarkDirty();
            return(true);
        }
 public override void Save(BaseNetworkable.SaveInfo info)
 {
     base.Save(info);
     info.msg.relationshipManager             = Pool.Get <ProtoBuf.RelationshipManager>();
     info.msg.relationshipManager.maxTeamSize = RelationshipManager.maxTeamSize;
     if (info.forDisk)
     {
         info.msg.relationshipManager.lastTeamIndex = this.lastTeamIndex;
         info.msg.relationshipManager.teamList      = Pool.GetList <ProtoBuf.PlayerTeam>();
         foreach (KeyValuePair <ulong, RelationshipManager.PlayerTeam> playerTeam in this.playerTeams)
         {
             RelationshipManager.PlayerTeam value = playerTeam.Value;
             if (value == null)
             {
                 continue;
             }
             ProtoBuf.PlayerTeam list = Pool.Get <ProtoBuf.PlayerTeam>();
             list.teamLeader = value.teamLeader;
             list.teamID     = value.teamID;
             list.teamName   = value.teamName;
             list.members    = Pool.GetList <ProtoBuf.PlayerTeam.TeamMember>();
             foreach (ulong member in value.members)
             {
                 ProtoBuf.PlayerTeam.TeamMember teamMember = Pool.Get <ProtoBuf.PlayerTeam.TeamMember>();
                 BasePlayer basePlayer = RelationshipManager.FindByID(member);
                 teamMember.displayName = (basePlayer != null ? basePlayer.displayName : "DEAD");
                 teamMember.userID      = member;
                 list.members.Add(teamMember);
             }
             info.msg.relationshipManager.teamList.Add(list);
         }
     }
 }
    public static void promote(ConsoleSystem.Arg arg)
    {
        BasePlayer basePlayer = arg.Player();

        if (basePlayer.currentTeam == 0)
        {
            return;
        }
        BasePlayer lookingAtPlayer = RelationshipManager.GetLookingAtPlayer(basePlayer);

        if (lookingAtPlayer == null)
        {
            return;
        }
        if (lookingAtPlayer.IsDead())
        {
            return;
        }
        if (lookingAtPlayer == basePlayer)
        {
            return;
        }
        if (lookingAtPlayer.currentTeam == basePlayer.currentTeam)
        {
            RelationshipManager.PlayerTeam item = RelationshipManager.Instance.playerTeams[basePlayer.currentTeam];
            if (item != null && item.teamLeader == basePlayer.userID)
            {
                if (Interface.CallHook("OnTeamPromote", item, lookingAtPlayer) != null)
                {
                    return;
                }
                item.SetTeamLeader(lookingAtPlayer.userID);
            }
        }
    }
Exemple #27
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         RelationshipManager.LoadRelationshipPage(gvRelationship, rptPager, 1, ddlPageSize);
     }
 }
        // <summary>
        // Constructs a wrapper as part of the materialization process.  This constructor is only used
        // during materialization where it is known that the entity being wrapped is newly constructed.
        // This means that some checks are not performed that might be needed when thw wrapper is
        // created at other times, and information such as the identity type is passed in because
        // it is readily available in the materializer.
        // </summary>
        // <param name="entity"> The entity to wrap </param>
        // <param name="relationshipManager"> The RelationshipManager associated with this entity </param>
        // <param name="entitySet"> The entity set, or null if none is known </param>
        // <param name="context"> The context to which the entity should be attached </param>
        // <param name="mergeOption"> NoTracking for non-tracked entities, AppendOnly otherwise </param>
        // <param name="identityType"> The type of the entity ignoring any possible proxy type </param>
        protected BaseEntityWrapper(
            TEntity entity, RelationshipManager relationshipManager, EntitySet entitySet, ObjectContext context, MergeOption mergeOption,
            Type identityType, bool overridesEquals)
        {
            Debug.Assert(!(entity is IEntityWrapper), "Object is an IEntityWrapper instance instead of the raw entity.");
            DebugCheck.NotNull(entity);

            if (relationshipManager == null)
            {
                throw new InvalidOperationException(Strings.RelationshipManager_UnexpectedNull);
            }

            _identityType        = identityType;
            _relationshipManager = relationshipManager;

            if (overridesEquals)
            {
                _flags = WrapperFlags.OverridesEquals;
            }

            RelationshipManager.SetWrappedOwner(this, entity);

            if (entitySet != null)
            {
                Context     = context;
                MergeOption = mergeOption;
                RelationshipManager.AttachContextToRelatedEnds(context, entitySet, mergeOption);
            }
        }
Exemple #29
0
 // <summary>
 // Constructs a wrapper as part of the materialization process.  This constructor is only used
 // during materialization where it is known that the entity being wrapped is newly constructed.
 // This means that some checks are not performed that might be needed when thw wrapper is
 // created at other times, and information such as the identity type is passed in because
 // it is readily available in the materializer.
 // </summary>
 // <param name="entity"> The entity to wrap </param>
 // <param name="key"> The entity's key </param>
 // <param name="entitySet"> The entity set, or null if none is known </param>
 // <param name="context"> The context to which the entity should be attached </param>
 // <param name="mergeOption"> NoTracking for non-tracked entities, AppendOnly otherwise </param>
 // <param name="identityType"> The type of the entity ignoring any possible proxy type </param>
 // <param name="propertyStrategy"> A delegate to create the property accesor strategy object </param>
 // <param name="changeTrackingStrategy"> A delegate to create the change tracking strategy object </param>
 // <param name="keyStrategy"> A delegate to create the entity key strategy object </param>
 internal EntityWrapperWithoutRelationships(
     TEntity entity, EntityKey key, EntitySet entitySet, ObjectContext context, MergeOption mergeOption, Type identityType,
     Func <object, IPropertyAccessorStrategy> propertyStrategy, Func <object, IChangeTrackingStrategy> changeTrackingStrategy,
     Func <object, IEntityKeyStrategy> keyStrategy, bool overridesEquals)
     : base(entity, RelationshipManager.Create(), key, entitySet, context, mergeOption, identityType,
            propertyStrategy, changeTrackingStrategy, keyStrategy, overridesEquals)
 {
 }
Exemple #30
0
        public void NodesAndRelationshipBuildEventArgs(Proxy.NodesEventArgs eventArgs, IDictionary <Guid, ServerObjects.Node> nodes, IDictionary <Guid, ServerObjects.Relationship> relationships)
        {
            foreach (ServerObjects.Node serviceNode in nodes.Values)
            {
                Proxy.INode proxyNode = NodeManager.FindNode(serviceNode);

                eventArgs.Nodes.Add(proxyNode.Id, proxyNode);
            }

            foreach (ServerObjects.Relationship serviceRelationship in relationships.Values)
            {
                RelationshipManager.CreateRelationship(serviceRelationship);
            }

            foreach (ServerObjects.Node serviceNode in nodes.Values)
            {
                Proxy.INode proxyNode = NodeManager.FindNode(serviceNode);

                SoapNode soapNode = proxyNode as SoapNode;

                /// Not all the nodes that are stored in the NodeManager are SoapNodes, some are FacadeNodes. In this scenario we want to check if they have an inner SoapNode and use that instead.
                if (soapNode == null)
                {
                    if (proxyNode is FacadeNode)
                    {
                        FacadeNode facadeNode = proxyNode as FacadeNode;
                        soapNode = facadeNode.BaseNode as SoapNode;
                    }
                }

                if (soapNode != null)
                {
                    soapNode.LoadNode(RelationshipManager);
                }
            }

            foreach (ServerObjects.Relationship serviceRelationship in relationships.Values)
            {
                Proxy.IRelationship proxyRelationship = RelationshipManager.FindRelationship(serviceRelationship);

                SoapRelationship soapRelationship = proxyRelationship as SoapRelationship;

                /// Not all the relationships that are stored in the RelationshipManager are SoapRelationships, some are FacadeRelationships. In this scenario we want to check if they have an inner SoapRelationship and use that instead.
                if (soapRelationship == null)
                {
                    if (proxyRelationship is FacadeRelationship)
                    {
                        FacadeRelationship facadeRelationship = proxyRelationship as FacadeRelationship;
                        soapRelationship = facadeRelationship.BaseRelationship as SoapRelationship;
                    }
                }

                if (soapRelationship != null)
                {
                    soapRelationship.LoadRelationship(NodeManager);
                }
            }
        }