private static void HandleTrace(Hashtable config, XmlNode traceNode, object context)
        {
            bool flag = false;
            bool val  = false;

            if (HandlerBase.GetAndRemoveBooleanAttribute(traceNode, "autoflush", ref val) != null)
            {
                config["autoflush"] = val;
            }
            int num = 0;

            if (HandlerBase.GetAndRemoveIntegerAttribute(traceNode, "indentsize", ref num) != null)
            {
                config["indentsize"] = num;
            }
            foreach (XmlNode node in traceNode.ChildNodes)
            {
                if (!HandlerBase.IsIgnorableAlsoCheckForNonElement(node))
                {
                    if (node.Name == "listeners")
                    {
                        if (flag)
                        {
                            throw new ConfigurationErrorsException(System.SR.GetString("ConfigSectionsUnique", new object[] { "listeners" }));
                        }
                        flag = true;
                        HandleListeners(config, node, context);
                    }
                    else
                    {
                        HandlerBase.ThrowUnrecognizedElement(node);
                    }
                }
            }
        }
Exemple #2
0
        private SiteMapNode GetNodeFromSiteMapFile(XmlNode xmlNode, VirtualPath siteMapFile)
        {
            SiteMapNode node = null;

            // For external sitemap files, its secuity setting is inherited from parent provider
            bool secuityTrimmingEnabled = SecurityTrimmingEnabled;

            HandlerBase.GetAndRemoveBooleanAttribute(xmlNode, _securityTrimmingEnabledAttrName, ref secuityTrimmingEnabled);

            // No other attributes or non-comment nodes are allowed on a siteMapFile node
            HandlerBase.CheckForUnrecognizedAttributes(xmlNode);
            HandlerBase.CheckForNonCommentChildNodes(xmlNode);

            XmlSiteMapProvider childProvider = new XmlSiteMapProvider();

            // siteMapFile was relative to the sitemap file where this xmlnode is defined, make it an application path.
            siteMapFile = _normalizedVirtualPath.Parent.Combine(siteMapFile);

            childProvider.ParentProvider = this;
            childProvider.Initialize(siteMapFile, secuityTrimmingEnabled);
            childProvider.BuildSiteMap();

            node = childProvider._siteMapNode;

            ChildProviderTable.Add(childProvider, node);
            _childProviderList = null;

            return(node);
        }
Exemple #3
0
        // 响应客户端请求
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            HandlerBase curHandler = null;

            // 获取对应的Handler
            MyGameApplication.MyInstance.m_DicHandler.TryGetValue(operationRequest.OperationCode, out curHandler);

            OperationResponse response = new OperationResponse();

            response.OperationCode = operationRequest.OperationCode;
            response.Parameters    = new Dictionary <byte, object>();

            if (null == curHandler)
            {
                log.Debug("Can't Find OperationCode:" + operationRequest.OperationCode);
                return;
            }
            // 调用Handler处理对应逻辑
            curHandler.OnHandlerMessage(operationRequest, response, this, sendParameters);
            if (response != null)
            {
                // log.Debug("ClientPeer Deal Success!");
                // 返回给客户端处理结果
                SendOperationResponse(response, sendParameters);
            }
        }
Exemple #4
0
        /// <summary>
        /// 从流中接收并处理帧。
        /// </summary>
        /// <exception cref="Exception"></exception>
        protected async Task Receive(Stream stream)
        {
            using (Timer timer = new Timer((object obj) => { stream.Close(); }, null, Timeout.Infinite, Timeout.Infinite))
            {
                while (true)
                {
                    timer.Change(Common.Configs.HeartbeatInterval * 3, Timeout.Infinite);
                    FrameBase frame = await ReadFrame(stream).ConfigureAwait(false);

                    timer.Change(Timeout.Infinite, Timeout.Infinite);

                    if (Common.Configs.Debug)
                    {
                        Console.WriteLine("R >" + frame.GetType().ToString());
                    }
                    if (!Handlers.ContainsKey(frame.GetType()))
                    {
                        await SendAsync(new ErrorFrame(frame.Guid) { Message = "当前客户端不支持该操作。" }).ConfigureAwait(false);
                    }
                    else
                    {
                        foreach (Type handlerType in Handlers[frame.GetType()])
                        {
                            ConstructorInfo constructor = handlerType.GetConstructor(new Type[] { typeof(ClientBase) });
                            HandlerBase     handler     = constructor.Invoke(new object[] { this }) as HandlerBase;
                            handler.Start(frame);
                        }
                    }
                }
            }
        }
Exemple #5
0
        private static void HandleTrace(Hashtable config, XmlNode traceNode, object context)
        {
            bool autoFlush = false;

            if (HandlerBase.GetAndRemoveBooleanAttribute(traceNode, "autoflush", ref autoFlush) != null)
            {
                config["autoflush"] = autoFlush;
            }

            int indentSize = 0;

            if (HandlerBase.GetAndRemoveIntegerAttribute(traceNode, "indentsize", ref indentSize) != null)
            {
                config["indentsize"] = indentSize;
            }

            foreach (XmlNode traceChild in traceNode.ChildNodes)
            {
                if (HandlerBase.IsIgnorableAlsoCheckForNonElement(traceChild))
                {
                    continue;
                }

                if (traceChild.Name == "listeners")
                {
                    HandleListeners(config, traceChild, context);
                }
                else
                {
                    HandlerBase.ThrowUnrecognizedElement(traceChild);
                }
            }
        }
Exemple #6
0
        protected override void OnDisconnect(PhotonHostRuntimeInterfaces.DisconnectReason reasonCode, string reasonDetail)
        {
            // 断开连接时候需要从队伍中剔除该用户
            MyGameApplication.MyInstance.RemovePeer(m_strRoomID, this);

            // 断开连接时候需要从已经创建了怪物列表中剔除该用户
            if (MyGameApplication.MyInstance.m_pInitMonsterPeer.Contains(this))
            {
                MyGameApplication.MyInstance.m_pInitMonsterPeer.Remove(this);
            }

            // 清除MonsterManager
            if (m_monsterManager != null)
            {
                m_monsterManager.Clear();
            }

            // 玩家掉线,通知队伍玩家删除自己
            HandlerBase curHandler = null;

            // 获取对应的Handler
            MyGameApplication.MyInstance.m_DicHandler.TryGetValue((byte)OperationCode.RemoveTeamRole, out curHandler);
            if (curHandler != null)
            {
                BattleHandler h = (BattleHandler)curHandler;
                h.RemoveTeamRole(this);
            }
            m_curRole = null;
            m_curUser = null;
            log.Debug("A Peer Is Disconnect");
        }
Exemple #7
0
        private void Run(HandlerBase handler,
                         DialogResult dialogResult,
                         LoginData loginData)
        {
            if (handler == null ||
                dialogResult == null ||
                loginData == null)
            {
                throw new ArgumentNullException();
            }

            handler.Login(loginData);

            handler.SetLocalization();

            var requirements = handler.BuildProfileRequirements(dialogResult);

            handler.SetProfileRequirements(requirements);

            if (dialogResult.Search == Search.Encounters)
            {
                _logger.Log(Search.Encounters.LogInfo);

                handler.SearchFromEncounters();
            }
            else if (dialogResult.Search == Search.PeopleNearby)
            {
                _logger.Log(Search.PeopleNearby.LogInfo);

                handler.SearchFromPeopleNearby();
            }
        }
Exemple #8
0
        // helper method to convert an XmlNode to a SiteMapNode
        private SiteMapNode ConvertFromXmlNode(Queue queue)
        {
            SiteMapNode rootNode = null;

            while (true)
            {
                if (queue.Count == 0)
                {
                    return(rootNode);
                }

                SiteMapNode parentNode = (SiteMapNode)queue.Dequeue();
                XmlNode     xmlNode    = (XmlNode)queue.Dequeue();

                SiteMapNode node = null;

                if (!_siteMapNodeName.Equals(xmlNode.Name))
                {
                    throw new ConfigurationErrorsException(
                              SR.GetString(SR.XmlSiteMapProvider_Only_SiteMapNode_Allowed),
                              xmlNode);
                }

                string providerName = null;
                HandlerBase.GetAndRemoveNonEmptyStringAttribute(xmlNode, _providerAttribute, ref providerName);

                // If the siteMapNode references another provider
                if (providerName != null)
                {
                    node = GetNodeFromProvider(providerName);

                    // No other attributes or child nodes are allowed on a provider node.
                    HandlerBase.CheckForUnrecognizedAttributes(xmlNode);
                    HandlerBase.CheckForNonCommentChildNodes(xmlNode);
                }
                else
                {
                    string siteMapFile = null;
                    HandlerBase.GetAndRemoveNonEmptyStringAttribute(xmlNode, _siteMapFileAttribute, ref siteMapFile);

                    if (siteMapFile != null)
                    {
                        node = GetNodeFromSiteMapFile(xmlNode, VirtualPath.Create(siteMapFile));
                    }
                    else
                    {
                        node = GetNodeFromXmlNode(xmlNode, queue);
                    }
                }

                AddNodeInternal(node, parentNode, xmlNode);

                if (rootNode == null)
                {
                    rootNode = node;
                }
            }
        }
Exemple #9
0
 public bool TryGetHandler(OperationCode operationCode, out HandlerBase handler)
 {
     if (mHandlers.TryGetValue(operationCode, out handler))
     {
         return(true);
     }
     mLogger.ErrorFormat("Can't find handler from operation code : " + operationCode);
     return(false);
 }
Exemple #10
0
 protected override void Arrange()
 {
     base.Arrange();
     base.Act();
     Counter.Stub(x => x.Count).Return(3);
     TimpexPredicate.Stub(x => x.Matches(Counter)).Return(false);
     HandlerBase.Stub(x => x.HandleWordBasedOnCounter(Counter)).Return(PexWord);
     ActualWord.Stub(x => x.Value()).Return("tim");
     WordAndCountPrinter.Stub(x => x.Print(Counter, ActualWord)).Return("tim 3");
 }
        public virtual object Create(object inheritedObject, object configContextObj, XmlNode node)
        {
            // if called through client config don't even load HttpRuntime
            if (!HandlerBase.IsServerConfiguration(configContextObj))
            {
                return(null);
            }

            return(PagesConfiguration.SectionHandler.CreateStatic(inheritedObject, node));
        }
        private static void HandleCounters(Hashtable parent, Hashtable config, XmlNode countersNode, object context)
        {
            int val = 0;

            if ((HandlerBase.GetAndRemoveIntegerAttribute(countersNode, "filemappingsize", ref val) != null) && (parent == null))
            {
                config["filemappingsize"] = val;
            }
            HandlerBase.CheckForChildNodes(countersNode);
        }
Exemple #13
0
        // 注册handler:OperationCode和它对应的Handler对应起来
        public void RegisteHandler(byte _code, HandlerBase _handler)
        {
            HandlerBase curHandler;

            if (m_DicHandler.TryGetValue(_code, out curHandler))
            {
                m_DicHandler.Remove(_code);
            }
            // 注册登录Handler
            m_DicHandler.Add(_code, _handler);
        }
            private static string GetAssembly(XmlNode node)
            {
                string assemblyName = null;

                HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(node, "assembly", ref assemblyName);

                HandlerBase.CheckForUnrecognizedAttributes(node);
                HandlerBase.CheckForChildNodes(node);

                return(assemblyName);
            }
 void RegistHandlers()
 {
     Type[] types = Assembly.GetAssembly(typeof(HandlerBase)).GetTypes();
     foreach (var type in types)
     {
         if (type.FullName.EndsWith("Handler"))
         {
             HandlerBase handlerBase = (HandlerBase)Activator.CreateInstance(type);
             handlers.Add((byte)handlerBase.OpCode, handlerBase);
         }
     }
 }
Exemple #16
0
        /// <summary>
        /// 处理客户端的请求
        /// </summary>
        /// <param name="operationRequest"></param>
        /// <param name="sendParameters"></param>
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            HandlerBase handler = DictTool.GetValue <OperationCode, HandlerBase>(ServerEntry.dict_Handler, (OperationCode)operationRequest.OperationCode);

            if (handler != null)
            {
                handler.OnOperationRequest(operationRequest, sendParameters, this);
            }
            else
            {
                HandlerBase defaultHandler = DictTool.GetValue <OperationCode, HandlerBase>(ServerEntry.dict_Handler, OperationCode.Default);
                defaultHandler.OnOperationRequest(operationRequest, sendParameters, this);
            }

            //switch (operationRequest.OperationCode)
            //{
            //    case 1:
            //        ServerEntry.log.Info("[Peer]Get Message");

            //        //接收数据
            //        Dictionary<byte, object> data = operationRequest.Parameters;
            //        object intValue;
            //        data.TryGetValue(1, out intValue);
            //        object stringValue;
            //        data.TryGetValue(2, out stringValue);
            //        ServerEntry.log.Info(string.Format("[Peer]<1,{0}>,<2,{1}>", intValue, stringValue));

            //        //回传数据
            //        OperationResponse onResponse = new OperationResponse(1);
            //        Dictionary<byte, object> data2 = new Dictionary<byte, object>();
            //        data2.Add(3, 200);
            //        data2.Add(4, "测试数据2");
            //        onResponse.SetParameters(data2);
            //        SendOperationResponse(onResponse, sendParameters);  //回传客户端

            //        //服务端主动推
            //        Dictionary<byte, object> data3 = new Dictionary<byte, object>();
            //        data3.Add(5, 300);
            //        data3.Add(6, "服务端主动推");

            //        EventData ed = new EventData(1);
            //        ed.Parameters = data3;
            //        SendEvent(ed, new SendParameters());
            //        break;

            //    case 2:
            //        break;

            //    default:
            //        break;
            //}
        }
Exemple #17
0
        //
        // Create - Given a partially composed config object (possibly null)
        // and some input from the config system, return a
        // further partially composed config object
        //
        public virtual object Create(Object parent, Object configContext, XmlNode section)
        {
            // start res off as a shallow clone of the parent

            Create(parent);

            // process XML

            HandlerBase.CheckForUnrecognizedAttributes(section);

            WalkXmlNodeList(section);

            return(Get());
        }
Exemple #18
0
        public void Dispatch(HandlerBase handler)
        {
            var runtimeHandler = handler as THandler;

            if (runtimeHandler != null)
            {
                var runtimeMessage = this as TMessage;
                if (runtimeMessage != null)
                {
                    runtimeHandler.HandleSpecific(runtimeMessage);
                    return;
                }
            }
            handler.HandleDefault(this);
        }
        private static void HandleCounters(Hashtable parent, Hashtable config, XmlNode countersNode, object context)
        {
            int filemappingsize = 0;

            if (HandlerBase.GetAndRemoveIntegerAttribute(countersNode, "filemappingsize", ref filemappingsize) != null)
            {
                //Should only be handled at machine config level
                if (parent == null)
                {
                    config["filemappingsize"] = filemappingsize;
                }
            }

            HandlerBase.CheckForChildNodes(countersNode);
        }
Exemple #20
0
        public virtual object Create(Object parent, Object configContextObj, XmlNode section)
        {
            // if called through client config don't even load HttpRuntime
            if (!HandlerBase.IsServerConfiguration(configContextObj))
            {
                return(null);
            }

            HttpConfigurationContext configContext = (HttpConfigurationContext)configContextObj;

            if (HandlerBase.IsPathAtAppLevel(configContext.VirtualPath) == PathLevel.BelowApp)
            {
                throw new ConfigurationException(
                          HttpRuntime.FormatResourceString(SR.Cannot_specify_below_app_level, section.Name),
                          section);
            }

            HandlerBase.CheckForChildNodes(section);
            CodeAccessSecurityValues oRet = new CodeAccessSecurityValues();

            XmlNode oAttribute = section.Attributes.RemoveNamedItem("level");

            if (oAttribute != null)
            {
                oRet.level = oAttribute.Value;
            }
            else
            {
                oRet.level = (parent != null ? ((CodeAccessSecurityValues)parent).level : "");
            }

            oAttribute = section.Attributes.RemoveNamedItem("originUrl");
            if (oAttribute != null)
            {
                oRet.url = oAttribute.Value;
            }
            else
            {
                oRet.url = (parent != null ? ((CodeAccessSecurityValues)parent).url : "");
            }

            HandlerBase.CheckForUnrecognizedAttributes(section);

            oRet.filename   = ConfigurationException.GetXmlNodeFilename(section);
            oRet.lineNumber = ConfigurationException.GetXmlNodeLineNumber(section);

            return(oRet);
        }
Exemple #21
0
            public async Task <Result> Handle(GetBrands.SeedData req, CancellationToken cancellationToken)
            {
                Result rt = new HandlerBase <Request, Response> .Result();

                try
                {
                    req.Data.dddd = "cccc";

                    //rt.Data.dddd = req.Data.cccc + "완료";
                }
                catch (Exception exc)
                {
                    rt.ErrorMessage(exc.Message);
                }
                return(rt);
            }
        private static void HandleAssert(Hashtable config, XmlNode assertNode, object context)
        {
            bool val = false;

            if (HandlerBase.GetAndRemoveBooleanAttribute(assertNode, "assertuienabled", ref val) != null)
            {
                config["assertuienabled"] = val;
            }
            string str = null;

            if (HandlerBase.GetAndRemoveStringAttribute(assertNode, "logfilename", ref str) != null)
            {
                config["logfilename"] = str;
            }
            HandlerBase.CheckForChildNodes(assertNode);
        }
 public override UpdateCartResult Execute(IUnitOfWork unitOfWork, UpdateCartParameter parameter, UpdateCartResult result)
 {
     // 4.2 Code Sync
     if (parameter.Properties.ContainsKey("IsNewUser"))
     {
         if (result.GetCartResult != null && !result.GetCartResult.Properties.ContainsKey("IsNewUser"))
         {
             result.GetCartResult.Properties.Add("IsNewUser", "true");
         }
     }
     else
     {
         HandlerBase.CopyCustomPropertiesToResult((EntityBase)result.GetCartResult.Cart, (IPropertiesDictionary)result, (List <string>)null);
     }
     return(this.NextHandler.Execute(unitOfWork, parameter, result));
 }
        public virtual object Create(Object parent, object configContext, XmlNode section)
        {
            NetConfiguration netConfig;

            if (parent == null)
            {
                netConfig = new NetConfiguration();
            }
            else
            {
                netConfig = (NetConfiguration)((NetConfiguration)parent).Clone();
            }

            // process XML
            foreach (XmlNode child in section.ChildNodes)
            {
                // skip whitespace and comments
                if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case "servicePointManager":
                    HandlerBase.GetAndRemoveBooleanAttribute(child, "checkCertificateName", ref netConfig.checkCertName);
                    HandlerBase.GetAndRemoveBooleanAttribute(child, "checkCertificateRevocationList", ref netConfig.checkCertRevocationList);
                    HandlerBase.GetAndRemoveBooleanAttribute(child, "useNagleAlgorithm", ref netConfig.useNagleAlgorithm);
                    HandlerBase.GetAndRemoveBooleanAttribute(child, "expect100Continue", ref netConfig.expect100Continue);
                    break;

                case "ipv6":
                    HandlerBase.GetAndRemoveBooleanAttribute(child, "enabled", ref netConfig.ipv6Enabled);
                    break;

                case "httpWebRequest":
                    HandlerBase.GetAndRemoveIntegerAttribute(child, "maximumResponseHeadersLength", ref netConfig.maximumResponseHeadersLength);
                    break;

                default:
                    HandlerBase.ThrowUnrecognizedElement(child);
                    break;
                }
                HandlerBase.CheckForUnrecognizedAttributes(child);
            }
            return(netConfig);
        }
        /// <include file='doc\DiagnosticsConfigurationHandler.uex' path='docs/doc[@for="DiagnosticsConfigurationHandler.Create"]/*' />
        /// <devdoc>
        ///    <para>Parses the configuration settings between the
        ///       &lt;diagnostics&gt; and &lt;/diagnostics&gt; portion of the .config file to populate
        ///       the values of 'WebServicesConfiguration' object and returning it.
        ///    </para>
        /// </devdoc>
        /// <internalonly/>
        public virtual object Create(object parent, object configContext, XmlNode section)
        {
            // Since the tracing and switch code lives in System.Dll and config is in System.Configuration.dll
            // the settings just go into a hashtable to communicate to the values to the diagnostics code in System.dll
            Hashtable parentConfig = (Hashtable)parent;
            Hashtable config;

            if (parentConfig == null)
            {
                config = new Hashtable();
            }
            else
            {
                config = (Hashtable)parentConfig.Clone();
            }

            foreach (XmlNode child in section.ChildNodes)
            {
                if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case "switches":
                    HandleSwitches(config, child, configContext);
                    break;

                case "assert":
                    HandleAssert(config, child, configContext);
                    break;

                case "trace":
                    HandleTrace(config, child, configContext);
                    break;

                default:
                    HandlerBase.ThrowUnrecognizedElement(child);
                    break;
                } // switch(child.Name)

                HandlerBase.CheckForUnrecognizedAttributes(child);
            }
            return(config);
        }
        public override InvoiceModel MapResult(GetInvoiceResult serviceResult, HttpRequestMessage request)
        {
            InvoiceHistory invoiceHistory = serviceResult.InvoiceHistory;
            Currency       currency       = serviceResult.Currency;
            InvoiceModel   invoiceModel   = ObjectToObjectMapper.Map <InvoiceHistory, InvoiceModel>(invoiceHistory);

            invoiceModel.DiscountAmountDisplay      = CurrencyFormatProvider.GetString(invoiceModel.DiscountAmount, currency);
            invoiceModel.CurrentBalanceDisplay      = CurrencyFormatProvider.GetString(invoiceModel.CurrentBalance, currency);
            invoiceModel.InvoiceTotalDisplay        = CurrencyFormatProvider.GetString(invoiceModel.InvoiceTotal, currency);
            invoiceModel.OtherChargesDisplay        = CurrencyFormatProvider.GetString(invoiceModel.OtherCharges, currency);
            invoiceModel.ProductTotalDisplay        = CurrencyFormatProvider.GetString(invoiceModel.ProductTotal, currency);
            invoiceModel.ShippingAndHandlingDisplay = CurrencyFormatProvider.GetString(invoiceModel.ShippingAndHandling, currency);
            invoiceModel.TaxAmountDisplay           = CurrencyFormatProvider.GetString(invoiceModel.TaxAmount, currency);
            invoiceModel.ShipViaDescription         = serviceResult.ShipViaDescription;
            invoiceModel.Properties = serviceResult.Properties;
            invoiceModel.Uri        = request == null ? string.Empty : UrlHelper.Link("InvoiceV1", new
            {
                invoiceid = invoiceModel.InvoiceNumber
            }, request);
            HandlerBase.CopyCustomPropertiesToResult(invoiceHistory, invoiceModel, null);
            foreach (GetInvoiceLineResult invoiceLineResult in serviceResult.GetInvoiceLineResults)
            {
                InvoiceLineModel destination = new InvoiceLineModel();
                if (invoiceLineResult.ProductDto != null)
                {
                    ObjectToObjectMapper.Map(invoiceLineResult.ProductDto, destination);
                    destination.ProductUri = invoiceLineResult.ProductDto.ProductDetailUrl;
                    destination.Properties.Add("ProductID", invoiceLineResult.ProductDto.Id.ToString());
                }
                ObjectToObjectMapper.Map(invoiceLineResult.InvoiceHistoryLine, destination);
                destination.UnitPriceDisplay      = CurrencyFormatProvider.GetString(destination.UnitPrice, currency);
                destination.DiscountAmountDisplay = CurrencyFormatProvider.GetString(destination.DiscountAmount, currency);
                destination.LineTotalDisplay      = CurrencyFormatProvider.GetString(destination.LineTotal, currency);
                HandlerBase.CopyCustomPropertiesToResult(invoiceLineResult.InvoiceHistoryLine, destination, null);
                invoiceModel.InvoiceLines.Add(destination);
            }
            foreach (InvoiceHistoryTaxDto invoiceHistoryTax in invoiceModel.InvoiceHistoryTaxes)
            {
                invoiceHistoryTax.TaxCode          = TranslationLocalizer.TranslateLabel(invoiceHistoryTax.TaxCode);
                invoiceHistoryTax.TaxDescription   = TranslationLocalizer.TranslateLabel(invoiceHistoryTax.TaxDescription);
                invoiceHistoryTax.TaxAmountDisplay = CurrencyFormatProvider.GetString(invoiceHistoryTax.TaxAmount, currency);
            }
            //invoiceModel.InvoiceDate = DateTime.SpecifyKind(invoiceModel.InvoiceDate, DateTimeKind.Unspecified) removed in 4.4;
            return(invoiceModel);
        }
Exemple #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="configContext"></param>
        /// <param name="section"></param>
        /// <returns></returns>
        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            Hashtable parentConfig = (Hashtable)parent;
            Hashtable config;

            if (parentConfig == null)
            {
                config = new Hashtable();
            }
            else
            {
                config = (Hashtable)parentConfig.Clone();
            }

            foreach (XmlNode child in section.ChildNodes)
            {
                if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case "trace":
                    HandleTrace(config, child, configContext);
                    break;

                case "assert":
                    HandleAssert(config, child, configContext);
                    break;

                case "switches":
                    HandleSwitches(config, child, configContext);
                    break;

                default:
                    HandlerBase.ThrowUnrecognizedElement(child);
                    break;
                }

                HandlerBase.CheckForUnrecognizedAttributes(child);
            }

            return(config);
        }
Exemple #28
0
        private static void HandleAssert(Hashtable config, XmlNode assertNode, object context)
        {
            bool assertUiEnabled = false;

            if (HandlerBase.GetAndRemoveBooleanAttribute(assertNode, "assertuienabled", ref assertUiEnabled) != null)
            {
                config["assertuienabled"] = assertUiEnabled;
            }

            string logFile = null;

            if (HandlerBase.GetAndRemoveStringAttribute(assertNode, "logfilename", ref logFile) != null)
            {
                config["logfilename"] = logFile;
            }

            HandlerBase.CheckForChildNodes(assertNode);
        }
Exemple #29
0
        //
        // WalkXmlNodeList - Walks list of XML nodes,
        //  and processes them for by calling Add, Clear, Remove
        //  to cause them to update the config object we are processing
        //
        protected virtual void WalkXmlNodeList(XmlNode section)
        {
            foreach (XmlNode child in section.ChildNodes)
            {
                // skip whitespace and comments
                if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child))
                {
                    continue;
                }

                // handle <set>, <remove>, <clear> tags
                if (child.Name == "add")
                {
                    String key   = HandlerBase.RemoveRequiredAttribute(child, KeyAttributeName);
                    String value = HandlerBase.RemoveAttribute(child, ValueAttributeName);

                    HandlerBase.CheckForUnrecognizedAttributes(child);

                    if (value == null)
                    {
                        value = "";
                    }

                    Add(key, value);
                }
                else if (child.Name == "remove")
                {
                    String key = HandlerBase.RemoveRequiredAttribute(child, KeyAttributeName);
                    HandlerBase.CheckForUnrecognizedAttributes(child);

                    Remove(key);
                }
                else if (child.Name.Equals("clear"))
                {
                    HandlerBase.CheckForUnrecognizedAttributes(child);
                    Clear();
                }
                else
                {
                    HandlerBase.ThrowUnrecognizedElement(child);
                }
            } // foreach
        }
Exemple #30
0
        // 客户端请求的处理
        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            Dictionary <OperationCode, HandlerBase> handlerDict = MyGameServer.Instance.HandlerDict;                   // 得到MyGameServer类中定义的handler字典
            HandlerBase handler = null;
            bool        isGet   = handlerDict.TryGetValue((OperationCode)operationRequest.OperationCode, out handler); // 从字典通过操作码取得对应的handler

            if (isGet)
            {
                handler.OnOperationRequest(operationRequest, sendParameters, this);       // 调用对应的操作码的handler处理请求
            }
            else
            {
                MyGameServer.log.Info("没有找到与操作码对应的handler去处理");
            }

            // 不使用字典和操作码进行处理分发
            //switch (operationRequest.OperationCode) {       // 通过客户端传递过来的请求operationRequest的OperationCode区分请求
            //    case 1:
            //        MyGameServer.log.Info("收到了1个请求");

            //        Dictionary<byte, object> data1 = operationRequest.Parameters;
            //        object health;
            //        object msg;
            //        data1.TryGetValue(11, out health);
            //        data1.TryGetValue(12, out msg);
            //        MyGameServer.log.Info("得到的数据是" + health + " " + msg);

            //        Dictionary<byte, object> data2 = new Dictionary<byte, object>();
            //        data2.Add(11,80);
            //        data2.Add(12,"Yes");
            //        OperationResponse opResponse = new OperationResponse(1);        // 可以指定参数operationCode,作为客户端判断是那条请求得到的响应(通常应与请求的operationRequest.OperationCode一致)
            //        opResponse.SetParameters(data2);       // 设置响应传回的数据字典
            //        SendOperationResponse(opResponse, sendParameters);      // 响应客户端的请求,sendParameters为一些传送数据时的参数设置(这里直接使用客户端发送时用的设置参数)

            //        EventData ed = new EventData(101);      // 创建一个事件数据,指定eventCode作为区分是哪个事件,ed可以SetParameters指定字典数据(类似请求响应)
            //        SendEvent(ed, new SendParameters());        // 发送事件,可以在程序的任意地方发送事件
            //        break;
            //    default:
            //        break;
            //}
        }
Exemple #31
0
 protected override void Act()
 {
     Sut = new HandlerBase(TimPredicate,PexPredicate,TimpexWordFactory,PexWordFactory,TimWordFactory);
 }