Example #1
0
        /// <summary>
        /// 创建 MvcHandler
        /// </summary>
        /// <param name="requestContext"></param>
        /// <returns></returns>
        internal MvcHandler Create(RequestContext requestContext)
        {
            string requiredString = requestContext.RouteData.Controller;

            if (string.IsNullOrEmpty(requiredString))
            {
                throw new HttpException(404, string.Format(CultureInfo.CurrentCulture, "没有找到路径:{0}对应的控制器", new object[]
                {
                    requestContext.HttpRequest.Path
                }));
            }
            var         factory = ControllerBuilder.GetControllerFactory();
            SessionMode mode    = factory.GetControllerSessionBehavior(requestContext, requiredString);

            switch (mode)
            {
            default:
            case SessionMode.Default:
                return(new MvcHandler(requestContext, factory));

            case SessionMode.NotSupport:
                return(new MvcHandler(requestContext, factory));

            case SessionMode.Support:
                return(new RequiresSessionActionHandler(requestContext, factory));

            case SessionMode.ReadOnly:
                return(new ReadOnlySessionActionHandler(requestContext, factory));
            }
        }
 public static bool IsDefined(SessionMode sessionMode)
 {
     if ((sessionMode != SessionMode.NotAllowed) && (sessionMode != SessionMode.Allowed))
     {
         return (sessionMode == SessionMode.Required);
     }
     return true;
 }
        public ISession CreateSession(bool transacted, SessionMode acknowledgeMode)
        {
            ISession session = singleConnectionFactory.GetSession(target, acknowledgeMode);

            if (session != null)
            {
                return(session);
            }
            return(target.CreateSession(transacted, acknowledgeMode));
        }
Example #4
0
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(TypeNode type)
        {
            // reset the class vars for each new type
            hasSessionMode = false;
            sessionMode    = SessionMode.Allowed; // Set to default value

            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(type, ServiceContractAttribute) ??
                                      SemanticRulesUtilities.GetAttribute(type, OperationContractAttribute);

            return(CheckForProblems(attribute, null));
        }
        /// <summary>
        /// Checks the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public override ProblemCollection Check(TypeNode type)
        {
            // reset the class vars for each new type
            hasSessionMode = false;
            sessionMode = SessionMode.Allowed; // Set to default value

            AttributeNode attribute = SemanticRulesUtilities.GetAttribute(type, ServiceContractAttribute) ??
                                      SemanticRulesUtilities.GetAttribute(type, OperationContractAttribute);
            
            return CheckForProblems(attribute, null);
        }
    private void RefreshPlayerLine(string playerName, int playerIndex)
    {
        Steamworks.SteamID steamID = Steamworks.SteamID.Zero;
        if (Steamworks.SteamAPI.IsSteamRunning)
        {
            try
            {
                steamID    = new Steamworks.SteamID(Convert.ToUInt64(playerName, 16));
                playerName = Steamworks.SteamAPI.SteamFriends.GetFriendPersonaName(steamID);
                goto IL_4E;
            }
            catch
            {
                Diagnostics.LogWarning("Unable to get player name from steam ID " + playerName);
                goto IL_4E;
            }
        }
        playerName = Environment.UserName + "(no Steam)";
IL_4E:
        this.PlayersTitleLabels[playerIndex].AgeTransform.Visible = true;
        this.PlayersTitleLabels[playerIndex].Text = playerName;
        AgeTooltip ageTooltip = this.PlayersTitleLabels[playerIndex].AgeTransform.AgeTooltip;

        if (ageTooltip != null)
        {
            ageTooltip.Content = playerName;
        }
        if (steamID == this.Session.SteamIDUser && playerIndex == 0)
        {
            this.CompetitorIsLocalOwner = true;
        }
        SessionMode sessionMode = this.Session.SessionMode;

        if (sessionMode == SessionMode.Single)
        {
            this.PlayerReadyToggles[playerIndex].AgeTransform.Visible = false;
            this.PlayerKickButtons[playerIndex].AgeTransform.Visible  = false;
            return;
        }
        if (sessionMode - SessionMode.Private > 2)
        {
            throw new ArgumentOutOfRangeException();
        }
        bool lobbyMemberData = this.Session.GetLobbyMemberData <bool>(steamID, "Ready", false);

        this.PlayerReadyToggles[playerIndex].AgeTransform.Visible = true;
        this.PlayerReadyToggles[playerIndex].State = lobbyMemberData;
        this.PlayerKickButtons[playerIndex].AgeTransform.Visible = (this.CompetitorIsHuman && this.Session.IsHosting && !this.CompetitorIsLocalOwner);
        this.PlayerKickButtons[playerIndex].OnActivateMethod     = "OnKickUserCB";
        this.PlayerKickButtons[playerIndex].OnActivateData       = steamID.ToString();
        bool visible = steamID == this.Session.LobbyOwnerSteamID;

        this.PlayerHostingIcons[playerIndex].AgeTransform.Visible = visible;
    }
Example #7
0
		public static void AssertContractDescription (
			string name, string ns,
			SessionMode session, Type contractType,
			Type callbackContractType,
			ContractDescription cd, string label)
		{
			Assert.AreEqual (name, cd.Name, label + " Name");
			Assert.AreEqual (ns, cd.Namespace, label + " Namespace");
			Assert.AreEqual (session, cd.SessionMode, label + " Session");
			Assert.AreEqual (contractType, cd.ContractType,
				label + " ContractType");
			Assert.AreEqual (callbackContractType, cd.CallbackContractType,
				label + " CallbackContractType");
		}
Example #8
0
        public override void StartSession(SyncDatabase db, SessionMode Mode)
        {
            ExecSql(db, "select rdb$set_context('USER_TRANSACTION', 'SYNC_RECV', '1') from rdb$database");

            if (Mode == SessionMode.Write)
            {
                using (IDbCommand cmd = db.CreateCommand())
                {
                    cmd.CommandText = "select rdb$set_context('USER_TRANSACTION', 'SYNC_LOG_DISABLED', '1') from rdb$database";
                    cmd.ExecuteNonQuery();
                }
                ExecSql(db, "select rdb$set_context('USER_TRANSACTION', 'TRG_DISABLE', '1') from rdb$database");
            }
        }
Example #9
0
        private ProblemCollection CheckForProblems(AttributeNode attribute, Member member)
        {
            if (SemanticRulesUtilities.HasAttribute <ServiceContractAttribute>(attribute))
            {
                // store state for check member analysis overload.
                hasSessionMode = SemanticRulesUtilities.HasAttribute <ServiceContractAttribute>(attribute, "SessionMode");
                if (hasSessionMode)
                {
                    sessionMode = SemanticRulesUtilities.GetAttributeValue <SessionMode>(attribute, "SessionMode");
                }
                return(base.Problems);
            }

            if (SemanticRulesUtilities.HasAttribute <OperationContractAttribute>(attribute) &&
                IsRuleViolated(attribute))
            {
                Resolution resolution = base.GetResolution(CustomizeDescription(attribute), member.Name.Name);
                Problem    problem    = new Problem(resolution, attribute.SourceContext);
                base.Problems.Add(problem);
                return(base.Problems);
            }
            return(base.Problems);
        }
        private ProblemCollection CheckForProblems(AttributeNode attribute, Member member)
        {
			if (SemanticRulesUtilities.HasAttribute<ServiceContractAttribute>(attribute))
			{
				// store state for check member analysis overload.
				hasSessionMode = SemanticRulesUtilities.HasAttribute<ServiceContractAttribute>(attribute, "SessionMode");
				if (hasSessionMode)
				{
					sessionMode = SemanticRulesUtilities.GetAttributeValue<SessionMode>(attribute, "SessionMode");
				}
				return base.Problems;
			}

			if (SemanticRulesUtilities.HasAttribute<OperationContractAttribute>(attribute) &&
				IsRuleViolated(attribute))
			{
				Resolution resolution = base.GetResolution(CustomizeDescription(attribute), member.Name.Name);
				Problem problem = new Problem(resolution, attribute.SourceContext);
				base.Problems.Add(problem);
				return base.Problems;
			}
            return base.Problems;
        }
 public ISession CreateSession(bool transacted, SessionMode acknowledgeMode)
 {
     ISession session = singleConnectionFactory.GetSession(target, acknowledgeMode);
     if (session != null)
     {
         return session;
     }
     return target.CreateSession(transacted, acknowledgeMode);
 }
        /// <summary>
        /// Obtaining a cached Session.
        /// </summary>
        /// <param name="con">The connection to operate on.</param>
        /// <param name="mode">The session ack mode.</param>
        /// <returns>The Session to use
        /// </returns>
        public override ISession GetSession(IConnection con, SessionMode mode)
        {
            LinkedList sessionList;
            lock (cachedSessions)
            {
                sessionList = (LinkedList) cachedSessions[mode];
                if (sessionList == null)
                {
                    sessionList = new LinkedList();
                    cachedSessions.Add(mode, sessionList);
                }
            }

            ISession session = null;
            lock (sessionList)
            {
                if (sessionList.Count > 0)
                {
                    session = (ISession) sessionList[0];
                    sessionList.RemoveAt(0);
                }
            }
            if (session != null)
            {
                if (LOG.IsDebugEnabled)
                {
                    LOG.Debug("Found cached Session for mode " + mode + ": "
                              + (session is IDecoratorSession ? ((IDecoratorSession) session).TargetSession : session));
                }
            } else
            {
                ISession targetSession = CreateSession(con, mode);
                if (LOG.IsDebugEnabled)
                {
                    LOG.Debug("Creating cached Session for mode " + mode + ": " + targetSession);
                }
                session = GetCachedSessionWrapper(targetSession, sessionList);
            }
            return session;
        }
        /// <summary>
        /// Template method for obtaining a (potentially cached) Session.
        /// </summary>
        /// <param name="con">The connection to operate on.</param>
        /// <param name="mode">The session ack mode.</param>
        /// <returns>the Session to use, or <code>null</code> to indicate
	    /// creation of a raw standard Session</returns>  
        public virtual ISession GetSession(IConnection con, SessionMode mode)
        {
            return null;
        }
Example #14
0
            public ConfigurableServiceProxyTypeBuilder(string targetName, string objectName, DefaultListableObjectFactory objectFactory, bool useServiceProxyTypeCache, Type contractInterface, string name, string ns, string configurationName, Type callbackContract, ProtectionLevel protectionLevel, SessionMode sessionMode)
                : base(targetName, objectName, objectFactory, useServiceProxyTypeCache)
            {
                this.objectFactory = objectFactory;
                this.contractInterface = contractInterface;
                if (!StringUtils.HasText(configurationName))
                {
                    name = this.Interfaces[0].Name;
                    configurationName = this.Interfaces[0].FullName;
                }

                // Creates a ServiceContractAttribute from configuration info
                this.serviceContractAttribute = CreateServiceContractAttribute(name, ns, configurationName, callbackContract, protectionLevel, sessionMode);
            }
Example #15
0
 private static CustomAttributeBuilder CreateServiceContractAttribute(string name, string ns, string configurationName,
     Type callbackContract, ProtectionLevel protectionLevel, SessionMode sessionMode)
 {
     ReflectionUtils.CustomAttributeBuilderBuilder scbb =
         new ReflectionUtils.CustomAttributeBuilderBuilder(typeof(ServiceContractAttribute));
     if (StringUtils.HasText(name))
     {
         scbb.AddPropertyValue("Name", name);
     }
     if (StringUtils.HasText(ns))
     {
         scbb.AddPropertyValue("Namespace", ns);
     }
     if (StringUtils.HasText(configurationName))
     {
         scbb.AddPropertyValue("ConfigurationName", configurationName);
     }
     if (callbackContract != null)
     {
         scbb.AddPropertyValue("CallbackContract", callbackContract);
     }
     if (protectionLevel != ProtectionLevel.None)
     {
         scbb.AddPropertyValue("ProtectionLevel", protectionLevel);
     }
     if (sessionMode != SessionMode.Allowed)
     {
         scbb.AddPropertyValue("SessionMode", sessionMode);
     }
     return scbb.Build();
 }
Example #16
0
 void SetSessionMode(SessionMode mode)
 {
    m_AllowedRadioButton.Checked = mode == SessionMode.Allowed;
    m_NotAllowedRadioButton.Checked = mode == SessionMode.NotAllowed;
    m_RequiredRadioButton.Checked = mode == SessionMode.Required;
 }
 protected virtual ISession CreateSession(IConnection con, SessionMode mode)
 {
     bool transacted = (mode == SessionMode.SessionTransacted);
     SessionMode ackMode = (transacted ? SessionMode.SessionTransacted : mode);
     return con.CreateSession(transacted, ackMode);
 }
Example #18
0
 /// <summary>
 /// Creates the session.
 /// </summary>
 /// <param name="transacted">if set to <c>true</c> [transacted].</param>
 /// <param name="acknowledgeMode">The acknowledge mode.
 /// When true, the new session has transaction semantics.
 /// Indicates whether and how the consumer is to acknowledge received messages.
 /// Legal values are listed under SessionMode.
 /// This parameter is ignored if the session is transacted.</param>
 /// <returns>A newly created session.</returns>
 public ISession CreateSession(bool transacted, SessionMode acknowledgeMode)
 {
     Session nativeSession = nativeConnection.CreateSession(transacted, acknowledgeMode);
     return new EmsSession(nativeSession);
 }
Example #19
0
 public ISession CreateSession(bool transacted, SessionMode acknowledgementMode)
 {
     createSessionCount++;
     return new TestSession();
 }
Example #20
0
 public static bool IsDefined(SessionMode sessionMode)
 {
     return (sessionMode == SessionMode.NotAllowed ||
             sessionMode == SessionMode.Allowed ||
             sessionMode == SessionMode.Required);
 }
 public DurableMessageDispatchInspector(SessionMode sessionMode)
 {
     this.sessionMode = sessionMode;
 }
 public SessionModeAttribute(SessionMode mode)
 {
     this.SessionMode = mode;
 }