public IConfigurationSettingItem Parse(System.Xml.XmlNode section)
        {
            //logger实现类的类型名称
            var cacheTypeName = section.GetAttributeValue("type");

            if (string.IsNullOrEmpty(cacheTypeName))
            {
                return(null);
            }

            var setting = new MyLoggingSetting();

            setting.Name    = section.GetAttributeValue("node");
            setting.LogType = Type.GetType(cacheTypeName);

            foreach (XmlNode node in section.ChildNodes)
            {
                var appender = ParseLoggingAppender(node);
                if (appender != null)
                {
                    setting.Appenders.Add(appender);
                }
            }

            return(setting);
        }
Пример #2
0
        public IConfigurationSettingItem Parse(System.Xml.XmlNode section)
        {
            var setting = new RedisCacheSetting();

            setting.Name      = section.GetAttributeValue("name");
            setting.CacheType = Type.GetType(section.GetAttributeValue("type"), false, true);
            var configNode = section.SelectSingleNode("config");

            if (configNode != null)
            {
                var serializerType = configNode.GetAttributeValue("serializerType");
                if (!string.IsNullOrEmpty(serializerType))
                {
                    setting.SerializerType = serializerType.ParseType();
                }

                setting.MaxReadPoolSize  = configNode.GetAttributeValue("maxReadPoolSize", 5);
                setting.MaxWritePoolSize = configNode.GetAttributeValue("maxWritePoolSize", 5);
                setting.DefaultDb        = configNode.GetAttributeValue("defaultDb", 0);
                setting.Password         = configNode.GetAttributeValue("password");

                foreach (XmlNode nd in configNode.SelectNodes("host"))
                {
                    var host = new RedisCacheHost();
                    host.Server   = nd.GetAttributeValue("server");
                    host.Port     = nd.GetAttributeValue("port", 0);
                    host.ReadOnly = nd.GetAttributeValue("readonly", false);

                    setting.Hosts.Add(host);
                }
            }

            return(setting);
        }
Пример #3
0
        private Weapon CreateWeapon(XmlNode weaponNode)
        {
            var weapon = new Weapon();

            weapon.Id = weaponNode.GetAttributeValue("id").ToInt();
            weapon.Name = weaponNode.GetAttributeValue("name");
            weapon.Power = weaponNode.GetAttributeValue("power").ToInt();
            weapon.MagicPower = weaponNode.GetAttributeValue("magicPower").ToInt();
            weapon.Value = weaponNode.GetAttributeValue("value").ToInt();

            return weapon;
        }
        public IConfigurationSettingItem Parse(System.Xml.XmlNode section)
        {
            var setting = new RedisConfigurationSetting();

            setting.ConnectionString = section.GetAttributeValue("connectionString");
            setting.Twemproxy        = section.GetAttributeValue <bool>("twemproxy");
            var configNode = section.SelectSingleNode("config");

            if (configNode != null)
            {
                var serializerType = configNode.GetAttributeValue("serializerType");
                if (!string.IsNullOrEmpty(serializerType))
                {
                    setting.SerializerType = serializerType.ParseType();
                }

                setting.PoolSize        = configNode.GetAttributeValue <int?>("poolSize");
                setting.DefaultDb       = configNode.GetAttributeValue("defaultDb", 0);
                setting.DbRange         = configNode.GetAttributeValue("dbRange");
                setting.KeyRule         = configNode.GetAttributeValue("keyRule");
                setting.Password        = configNode.GetAttributeValue("password");
                setting.Ssl             = configNode.GetAttributeValue <bool>("ssl");
                setting.WriteBuffer     = configNode.GetAttributeValue <int?>("writeBuffer");
                setting.LockTimeout     = configNode.GetAttributeValue("lockTimeout").ToTimeSpan(TimeSpan.FromSeconds(10));
                setting.ConnectTimeout  = configNode.GetAttributeValue("connectTimeout").ToTimeSpan(TimeSpan.FromMilliseconds(5000));
                setting.SyncTimeout     = configNode.GetAttributeValue("syncTimeout").ToTimeSpan(TimeSpan.FromMilliseconds(10000));
                setting.RetryDelayTime  = configNode.GetAttributeValue("retryDelayTime").ToTimeSpan(TimeSpan.FromSeconds(20));
                setting.RetryTimes      = configNode.GetAttributeValue("retryTimes").To <int?>();
                setting.SlidingTime     = configNode.GetAttributeValue("slidingTime").ToTimeSpan();
                setting.IgnoreException = configNode.GetAttributeValue("ignoreException").To(true);

                foreach (XmlNode nd in configNode.SelectNodes("host"))
                {
                    var host = new RedisHost(nd.GetAttributeValue("server"), nd.GetAttributeValue("port", 0))
                    {
                        ReadOnly = nd.GetAttributeValue("readonly", false)
                    };

                    setting.Hosts.Add(host);
                }
            }

            return(setting);
        }
Пример #5
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="Style" /> class.
        /// </summary>
        /// <param name="styleNode"> The style node. </param>
        /// <param name="storage"> The storage. </param>
        public Style(XmlNode styleNode, IPhysicalStorage storage)
        {
            _storage = storage;
              _id = styleNode.GetId();
              _isDefault = styleNode.GetAttributeBoolValue("isdefault");
              _name = styleNode.GetAttributeValue("name");

              _foregroundColor = styleNode.GetNodeColorValue("Foreground", "color");
              _font = styleNode.GetNodeValue("Foreground", "font");
              _fontSize = styleNode.GetNodeIntValue("Foreground", "fontsize");

              if (styleNode.HasNode("Background"))
              {
            _backgroundColor = styleNode.GetNodeColorValue("Background", "color");

            if (styleNode.HasNode("Background", "image"))
            {
              _backgroundImageUri = styleNode.GetNodeValue("Background", "image", "uri");

              var cache = styleNode.GetNodeValue("Background", "image", "cache");
              if (!string.IsNullOrEmpty(cache))
              {
            _backgroundImage = ImageSerializer.DeserializeBase64(cache);
              }
              else if (File.Exists(_backgroundImageUri))
              {
            _backgroundImage = Image.FromFile(_backgroundImageUri);
              }

              _transparency = styleNode.GetNodeIntValue("Background", "image", "transparency");
              _scale = styleNode.GetNodeBoolValue("Background", "image", "scale");
            }

            if (styleNode.HasNode("Title"))
            {
              _titleMode = TitleModeExtensions.AsTitleMode(styleNode["Title"].GetAttributeValue("mode"));

              if (styleNode.HasNode("Title", "Foreground"))
              {
            _titleForegroundColor = styleNode.GetNodeColorValue("Title", "Foreground", "color");
            _titleFont = styleNode.GetNodeValue("Title", "Foreground", "font");
            _titleFontSize = styleNode.GetNodeIntValue("Title", "Foreground", "fontsize");
              }
              if (styleNode.HasNode("Title", "Background"))
              {
            _titleBackgroundColor = styleNode.GetNodeColorValue("Title", "Background", "color");
              }
            }
              }
        }
Пример #6
0
        public IConfigurationSettingItem Parse(System.Xml.XmlNode section)
        {
            var setting = new RedisConfigurationSetting();

            setting.ConnectionString = section.GetAttributeValue("connectionString");
            setting.Twemproxy        = section.GetAttributeValue <bool>("twemproxy");
            var configNode = section.SelectSingleNode("config");

            if (configNode != null)
            {
                var serializerType = configNode.GetAttributeValue("serializerType");
                if (!string.IsNullOrEmpty(serializerType))
                {
                    setting.SerializerType = serializerType.ParseType();
                }

                setting.PoolSize     = configNode.GetAttributeValue <int?>("poolSize");
                setting.DefaultDb    = configNode.GetAttributeValue("defaultDb", 0);
                setting.Password     = configNode.GetAttributeValue("password");
                setting.Ssl          = configNode.GetAttributeValue <bool>("ssl");
                setting.WriteBuffer  = configNode.GetAttributeValue <int?>("writeBuffer");
                setting.AdvanceDelay = configNode.GetAttributeValue <double?>("advanceDelay");
                setting.LockTimeout  = configNode.GetAttributeValue("lockTimeout", 10);

                foreach (XmlNode nd in configNode.SelectNodes("host"))
                {
                    var host = new RedisHost();
                    host.Server   = nd.GetAttributeValue("server");
                    host.Port     = nd.GetAttributeValue("port", 0);
                    host.ReadOnly = nd.GetAttributeValue("readonly", false);

                    setting.Hosts.Add(host);
                }
            }

            return(setting);
        }
Пример #7
0
		// Amazonへのリンクを追加
		private XmlNode ParseAmazonInfo(XmlNode myNode, int headingLevel){
			string code = myNode.GetAttributeValue(CodeAttribute);
			if(!string.IsNullOrEmpty(code)) myASINList.AddNew(code);
			return Html.CreateDocumentFragment();
		}
Пример #8
0
		// Amazon の画像を生成する
		public XmlNode ParseAmazonImage(XmlNode myNode, int headingLevel){
			string code = myNode.GetAttributeValue(CodeAttribute);
			if(string.IsNullOrEmpty(code)) return Html.Null;
			return GetAmazonImage(code);
		}
Пример #9
0
// Amazon関連

		// Amazon へのリンクを生成する
		public XmlNode ParseAmazon(XmlNode myNode, int headingLevel){
			XmlElement result = Html.Span("amazon");
			string code = myNode.GetAttributeValue(CodeAttribute);
			if(string.IsNullOrEmpty(code)){
				result.AppendChild(GetLink(myNode, AmazonManager.AmazonTopUrl));
				return result;
			}
			string amazonHref = String.Format(AmazonManager.AmazonHrefFormat, code);
			string amazonSrc = String.Format(AmazonManager.AmazonSrcFormat, code);

			// URL を作成
			XmlNode amazonA = GetLink(myNode, amazonHref);

			XmlElement amazonImg = Html.Img(amazonSrc, "", 1, 1);

			result.AppendChild(amazonA);
			result.AppendChild(amazonImg);

			myASINList.AddNew(code);
			return result;
		}
Пример #10
0
		// footnote要素を処理します。
		public XmlNode ParseFootNote(XmlNode myNode, int headingLevel){

			// 脚注のぶら下がり先を作る
			if(myFootNote == null){
				myFootNote = Html.Create("dl", "footnotes");
			}
			string fnTitle = myNode.GetAttributeValue(TitleAttribute);
			myFootNoteCount++;
			string fnHeadingId = FootNoteHeadingIdPrefix + myFootNoteCount.ToString();
			string fnLinkId = FootNoteLinkIdPrefix + myFootNoteCount.ToString();
			string fnLinkText = string.Format(FootNoteLinkTextFormat, myFootNoteCount);

			XmlElement fnHeadingAnchor = Html.Create("a");
			fnHeadingAnchor.SetAttribute("name", fnHeadingId);
			fnHeadingAnchor.SetAttribute("id", fnHeadingId);
			fnHeadingAnchor.SetAttribute("href", "#" + fnLinkId);
			fnHeadingAnchor.InnerText = fnLinkText;

			XmlElement fnDt = Html.Create("dt", null, fnHeadingAnchor);
			if(!string.IsNullOrEmpty(fnTitle)) fnDt.AppendChild(Html.Text(" " + fnTitle));
			XmlElement fnDd = Html.Create("dd");
			fnDd.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
			myFootNote.AppendChild(fnDt);
			myFootNote.AppendChild(fnDd);

			XmlElement fnLinkAnchor = Html.Create("a", FootNoteLinkIdPrefix);
			fnLinkAnchor.SetAttribute("name", fnLinkId);
			fnLinkAnchor.SetAttribute("id", fnLinkId);
			fnLinkAnchor.SetAttribute("href", "#" + fnHeadingId);
			fnLinkAnchor.InnerText = fnLinkText;
			if(!string.IsNullOrEmpty(fnTitle)) fnLinkAnchor.SetAttribute("title", fnTitle);

			return fnLinkAnchor;
		}
Пример #11
0
		// attr要素を処理します。
		public XmlNode ParseAttr(XmlNode myNode, int headingLevel){
			XmlElement result = Html.Create("dfn", "element");
			if(HtmlRef != null){
				string name = myNode.GetAttributeValue(TargetAttribute);
				if(string.IsNullOrEmpty(name)) name = myNode.InnerText;
				name = name.GetIdString();
				string forStr = myNode.GetAttributeValue(ForAttribute);
				HtmlAttribute ha = HtmlRef.GetAttribute(name, forStr);
				if(ha != null){
					AbsPath link = HtmlRef.BasePath.Combine(ha.LinkId, ha.Id.PathEncode());
					XmlElement a = Html.A(link);
					a.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
					result.AppendChild(a);
					return result;
				}
			}
			result.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
			return result;
		}
Пример #12
0
		// download要素を処理します。
		public XmlNode ParseDownload(XmlNode myNode, int headingLevel){
			string href = myNode.GetAttributeValue("href");
			if(string.IsNullOrEmpty(href)){
				href = myNode.InnerText;
			}
			AbsPath path = new AbsPath(href);
			if(path.Equals(myPath)) throw new Exception("ダウンロードリンクに自身が指定されています。");
			FileResponse dlResponse = myModel.Manager.GetResponse(path) as FileResponse;
			if(dlResponse == null){
				return Html.Text("(" + href + "のダウンロードは利用できません)");
			}
			XmlElement a = Html.A(path);
			string inner = string.Format("{0} ({1} {2})", dlResponse.FileSource.Name, dlResponse.ExtInfo.Description, dlResponse.LengthFormat);
			a.InnerText = inner;
			return a;
		}
Пример #13
0
		// a要素を処理します。
		public XmlNode ParseA(XmlNode myNode, int headingLevel){
			string href = myNode.GetAttributeValue("href");
			if(string.IsNullOrEmpty(href)){
				href = myNode.InnerText;
			}
			return GetLink(myNode, href);
		}
Пример #14
0
		// ノードをパースします。
		public XmlNode ParseNode(XmlNode myNode, int headingLevel){
			XmlNode result = null;
			switch(myNode.NodeType){
			case XmlNodeType.Document:
				result = ParseNode(myNode.ChildNodes, headingLevel);
				break;

			case XmlNodeType.Element:
				// 要素の場合
				result = ParseElement(myNode as XmlElement, headingLevel);
				// langかxml:langがあったら継承する
				string lang = myNode.GetAttributeValue("xml:lang");
				if(lang == null) lang = myNode.GetAttributeValue("lang");
				if(result is XmlElement && !string.IsNullOrEmpty(lang)){
					XmlElement e = result as XmlElement;
					e.SetAttribute("xml:lang", lang);
				}
				break;

			case XmlNodeType.Text:
			case XmlNodeType.CDATA:
				// テキストの場合
				string text = myNode.Value;
				text = text.Replace("\t", "    ");
				result = Html.CreateTextNode(text);
				break;

			case XmlNodeType.Comment:
			case XmlNodeType.XmlDeclaration:
			case XmlNodeType.DocumentType:
				// コメントやXML宣言は無視
				result = Html.Null;
				break;

			default:
				//その他のノード
				throw new Exception(String.Format("ノードタイプ {0} は処理できません", myNode.NodeType));
			}

			if(myRoopCounter++ > RoopMax){
				throw new Exception("パースループエラー: パーサーの処理回数が一定量を超えました。無限ループの可能性があるため処理を中止しました。");
			}

			return result;
		}
Пример #15
0
        /**
         * Calculates the macro-expanded value of an attribute on the node.
         * Returns true if the attribute is defined.
         */
        bool GetAttributeValue(XmlNode node, XmlMacroCollection macros, string attribName, out string value)
        {
            value = node.GetAttributeValue(attribName);

            if (value != null)
            {
                try
                {
                    value = macros.GetExpandedValue(value);
                }
                catch (Exception ex)
                {
                    throw new JRunXmlException(node, ex, "Could not expand macro value for attribute \"{0}\"", attribName);
                }
            }

            return value != null;
        }
Пример #16
0
        /**
         * Creates a virtual shortcut for the given context and node
         */
        XmlVirtualShortcut CreateVirtualShortcut(XmlNode context, XmlNode shortcutNode, XmlMacroCollection outerMacros)
        {
            var nodeName = shortcutNode.GetAttributeValue("name");

            if (!String.IsNullOrEmpty(nodeName))
            {
                var realName = outerMacros.GetExpandedValue(nodeName);

                if (!String.IsNullOrEmpty(realName))
                {
                    var newMacros = new XmlMacroCollection(outerMacros);

                    AddTemplateMacros(shortcutNode, newMacros);

                    return new XmlVirtualShortcut(realName, context, shortcutNode, newMacros);
                }
            }

            return null;
        }
Пример #17
0
        public BaseLexer(int firstFreeStyle, XmlNode lexerNode, BaseLexer parent)
        {
            parentLexer = parent;
            defaultLexer = GetType().Name == "DefaultLexer" ? null
                : new DefaultLexer(firstFreeStyle, null, this);

            // get style and state ranges
            var stateValues = Enum.GetValues(StateType);
            int styleCount = stateValues.Length;
            int firstState = styleCount > 0 ? ((int[])stateValues).Min() : 0;

            // adjust style ranges if they fall into the Scintilla styles
            firstStyle = firstFreeStyle;
            if (SciStyle.Default <= firstStyle + styleCount && firstStyle <= SciStyle.CallTip)
                firstStyle = SciStyle.CallTip + 1;
            lastStyle = firstStyle + styleCount - 1;
            firstFreeStyle = lastStyle + 1;

            if (StateType.IsEquivalentTo(typeof(BaseState)))
            {
                firstBaseStyle = firstStyle;
                lastBaseStyle = lastStyle;
            }

            // allocate arrays for styles
            styles = Enumerable.Range(firstStyle, styleCount)
                .Select(x => new ScintillaNET.Lexing.Style {
                    id = x, fore = Theme.ForeColor, back = Theme.Workspace
                }).ToArray();
            keywords = new Trie<Keyword>[styleCount];

            // SET TO DEFAULT LEXER
            if (lexerNode == null)
            {
                lexerType = "default";
                lexer = new BaseLexer[0];
                return;
            }

            // get lexer type
            lexerType = lexerNode.GetAttributeValue("type");

            // get style colors
            var styleList = lexerNode.SelectNodes("Style");
            foreach (XmlNode style in styleList)
            {
                if (style.HasAttributeValue("theme") && style.GetAttributeValue("theme").ToLower() != Theme.Name.ToLower())
                    continue;
                var id = (int)Enum.Parse(StateType, style.GetAttributeValue("name"), true);
                var idx = id - firstState;
                if (style.HasAttributeValue("fore"))
                    styles[idx].fore = ColorTranslator.FromHtml(style.GetAttributeValue("fore"));
                if (style.HasAttributeValue("back"))
                    styles[idx].back = ColorTranslator.FromHtml(style.GetAttributeValue("back"));
            }

            // get keyword definitions
            var keywordList = lexerNode.SelectNodes("Keyword");
            foreach (XmlNode keyword in keywordList)
            {
                var id = (int)Enum.Parse(StateType, keyword.GetAttributeValue("style_name"), true);
                var idx = id - firstState;
                var name = keyword.GetAttributeValue("name");
                var hint = keyword.GetAttributeValue("hint");
                if (hint != null && hint.IndexOf('\\') >= 0)
                    hint = regexHint.Replace(hint, "\n");
                if (keywords[idx] == null)
                    keywords[idx] = new Trie<Keyword>();
                keywords[idx].Add(name, new Keyword { word = name, hint = hint });
            }

            // instantiate sub-lexers
            var lexerList = lexerNode.SelectNodes("Lexer");
            lexer = new BaseLexer[lexerList.Count];
            var assembly = typeof(BaseLexer).FullName.Substring(0,
                typeof(BaseLexer).FullName.Length - typeof(BaseLexer).Name.Length);
            for (int i = 0; i < lexerList.Count; i++)
            {
                var type = lexerList[i].GetAttributeValue("lexer");
                var param = new object[] { firstFreeStyle, lexerList[i], this };
                var t = Type.GetType($"{assembly}{type}");
                lexer[i] = (BaseLexer)Activator.CreateInstance(t, param);
                firstFreeStyle = lexer[i].MaxStyle + 1;
            }
        }
Пример #18
0
		// dfn要素を処理します。
		public XmlNode ParseDfn(XmlNode myNode, int headingLevel){
			XmlElement result = Html.Create("dfn", "glossary");
			if(Glossary != null){
				string name = myNode.GetAttributeValue(TargetAttribute);
				if(string.IsNullOrEmpty(name)) name = myNode.InnerText;
				GlossaryWord gw = Glossary.GetWordByName(name);
				if(gw != null){
					AbsPath wordLink = Glossary.BasePath.Combine(gw.Name.PathEncode());
					XmlElement a = Html.A(wordLink);
					a.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
					result.AppendChild(a);
					return result;
				}
			}
			result.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
			return result;
		}
Пример #19
0
		// data要素を処理します。
		public XmlNode ParseData(XmlNode myNode, int headingLevel){
			XmlElement result = Html.Create("dfn", "data");
			if(HtmlRef != null){
				string name = myNode.GetAttributeValue(TargetAttribute);
				if(string.IsNullOrEmpty(name)) name = myNode.InnerText;
				name = name.GetIdString();
				HtmlData hd = HtmlRef.GetDataByName(name);
				if(hd != null){
					AbsPath link = HtmlRef.BasePath.Combine(hd.LinkId, hd.Id.PathEncode());
					XmlElement a = Html.A(link);
					a.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
					result.AppendChild(a);
					return result;
				}
			}
			result.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
			return result;
		}
Пример #20
0
        private Ability CreateRegularAbility(XmlNode abilityNode, Ability ability)
        {
            ability.Id = abilityId++;
            ability.Name = abilityNode.GetAttributeValue("name");
            ability.Description = abilityNode.GetAttributeValue("description");

            var cooldown = abilityNode.GetAttributeValue("cooldown");
            if (!string.IsNullOrEmpty(cooldown))
                ability.Cooldown = cooldown.ToInt();

            ability.ElementType = abilityNode.GetEnumAttributeValue("elementType", ElementType.None);
            ability.TargetType = abilityNode.GetEnumAttributeValue("targetType", TargetTypes.Single);
            ability.AbilityType = abilityNode.GetEnumAttributeValue("abilityType", AbilityType.Physical);

            var iconString = abilityNode.GetAttributeValue("icon");
            if (!string.IsNullOrEmpty(iconString))
            {
                var icon = Resources.Load("Images/" + iconString) as Texture2D;
                if (icon != null)
                    ability.Icon = icon;
            }

            ability.DamageRange = ParseDamageRange(abilityNode);

            var clip = Resources.Load("SoundEffects/SwordSwing") as AudioClip;
            ability.AudioClip = clip;

            return ability;
        }