public override void ParseXml(System.Xml.XmlElement aNode) { base.ParseXml(aNode); if (aNode.HasAttribute("readonly")) { FReadOnly = aNode.Attributes["readonly"].Value == "1"; } else { FReadOnly = false; } if (aNode.HasAttribute("printonlytext")) { FPrintOnlyText = aNode.Attributes["printonlytext"].Value == "1"; } else { FPrintOnlyText = true; } HC.SetBorderSideByPro(aNode.Attributes["border"].Value, FBorderSides); FBorderWidth = byte.Parse(aNode.Attributes["borderwidth"].Value); FText = aNode.InnerText; }
public override void ParseXml(System.Xml.XmlElement aNode) { base.ParseXml(aNode); FText = aNode.InnerText; if (aNode.HasAttribute("autosize")) { FAutoSize = bool.Parse(aNode.Attributes["autosize"].Value); } else { FAutoSize = true; } if (aNode.HasAttribute("showtext")) { FShowText = bool.Parse(aNode.Attributes["showtext"].Value); } else { FShowText = true; } if (aNode.HasAttribute("penwidth")) { FPenWidth = Byte.Parse(aNode.Attributes["penwidth"].Value); } else { FPenWidth = 2; } }
public override void ParseXml(System.Xml.XmlElement aNode) { base.ParseXml(aNode); FCode128.Text = aNode.InnerText; if (aNode.HasAttribute("autosize")) { FAutoSize = bool.Parse(aNode.Attributes["autosize"].Value); } else { FAutoSize = true; } if (aNode.HasAttribute("showtext")) { FCode128.TextVisible = bool.Parse(aNode.Attributes["showtext"].Value); } else { FCode128.TextVisible = true; } if (aNode.HasAttribute("penwidth")) { FCode128.Zoom = Byte.Parse(aNode.Attributes["penwidth"].Value); } else { FCode128.Zoom = 1; } }
public override bool FromXML(System.Xml.XmlElement myElement) { if (myElement != null) { this.Type = StringCommon.GetTypeByName(myElement.GetAttribute("type")); this.Name = myElement.GetAttribute("name"); this.Code = myElement.GetAttribute("code"); //Add by wwj 2013-08-01 if (myElement.HasAttribute("candelete")) { this.CanDelete = bool.Parse(myElement.GetAttribute("candelete")); } //Add by wwj 2013-08-01 if (myElement.HasAttribute("direction")) { this.Direction = (ZYFlagDirection)Enum.Parse(typeof(ZYFlagDirection), myElement.GetAttribute("direction")); } //Add by wwj 2013-08-01 if (myElement.HasAttribute("isholdspacewhenprint")) { this.IsHoldSpaceWhenPrint = bool.Parse(myElement.GetAttribute("isholdspacewhenprint")); } return(true); } return(false); }
public static ItemArchetype CreateFromXml(System.Xml.XmlElement n, Roar.DataConversion.IXCRMParser ixcrm_parser) { DomainObjects.ItemArchetype retval = new DomainObjects.ItemArchetype(); retval.id = n.GetAttributeOrDefault("id", null); retval.ikey = n.GetAttributeOrDefault("ikey", null); retval.type = n.GetAttributeOrDefault("type", null); retval.label = n.GetAttributeOrDefault("label", null); retval.description = n.GetAttributeOrDefault("description", null); if (n.HasAttribute("consumable")) { retval.consumable = n.GetAttribute("consumable").ToLower() == "true"; } if (n.HasAttribute("sellable")) { retval.sellable = n.GetAttribute("sellable").ToLower() == "true"; } retval.stats = ixcrm_parser.ParseItemStatList(n.SelectSingleNode("./stats") as System.Xml.XmlElement); retval.price = ixcrm_parser.ParseModifierList(n.SelectSingleNode("./price") as System.Xml.XmlElement); retval.tags = ixcrm_parser.ParseTagList(n.SelectSingleNode("./tags") as System.Xml.XmlElement); System.Xml.XmlNodeList property_nodes = n.SelectNodes("./properties/property"); foreach (System.Xml.XmlElement property_node in property_nodes) { Roar.DomainObjects.ItemArchetypeProperty property = new Roar.DomainObjects.ItemArchetypeProperty(); property.ikey = property_node.GetAttribute("ikey"); property.value = property_node.GetAttribute("value"); retval.properties.Add(property); } return(retval); }
/// <summary> /// 已重载:从XML节点加载对象数据 /// </summary> /// <param name="myElement">XML节点</param> /// <returns>操作是否成功</returns> public override bool FromXML(System.Xml.XmlElement myElement) { if (base.FromXML(myElement)) { this.Width = 30; this.Height = 30; if (myImage != null) { myImage.Dispose(); myImage = null; imagecontent = string.Empty; } if (this.SaveInFile) { try { myImage = StringCommon.ImageFromBase64String(myElement.InnerText); } catch { //如果不能加载出图片,则说明是该图片已经被修改过了 //需要使用图片编辑器 myImage = null; } if (myImage == null) { imagecontent = myElement.InnerText; MemoryStream ms = new MemoryStream(Convert.FromBase64String(imagecontent)); m_temppanel.LoadImage(ms); myImage = m_temppanel.CurrentImage; } } else { myImage = ZYTextConst.ImageFromURL(this.Src); //todo } if (myImage != null) { this.Width = myImage.Size.Width; this.Height = myImage.Size.Height; } if (myElement.HasAttribute(ZYTextConst.c_Width)) { this.Width = StringCommon.ToInt32Value(myElement.GetAttribute(ZYTextConst.c_Width), intWidth); } if (myElement.HasAttribute(ZYTextConst.c_Height)) { this.Height = StringCommon.ToInt32Value(myElement.GetAttribute(ZYTextConst.c_Height), intHeight); } myAttributes.SetValue(ZYTextConst.c_Width, intWidth.ToString()); myAttributes.SetValue(ZYTextConst.c_Height, intHeight.ToString()); return(true); } return(false); }
public override void Read(System.Xml.XmlElement element) { this.type = (ActorType)Enum.Parse(typeof(ActorType), element.GetAttribute("type")); if (element.HasAttribute("powerFactor")) { this.powerFactor = Int32.Parse(element.GetAttribute("powerFactor")); } if (element.HasAttribute("isTarget")) { this.IsTarget = bool.Parse(element.GetAttribute("isTarget")); } this.Position = this.ReadPoint(element["point"]); }
public virtual Field Parse(System.Xml.XmlElement element, ParsingContext context) { if (element.HasAttribute("name")) { QName templateName = element.HasAttribute("templateNs") ? new QName(element.GetAttribute("name"), element.GetAttribute("templateNs")) : new QName(element.GetAttribute("name"), ""); if (context.TemplateRegistry.IsDefined(templateName)) { return(new StaticTemplateReference(context.TemplateRegistry.get_Renamed(templateName))); } context.ErrorHandler.Error(Error.FastConstants.D8_TEMPLATE_NOT_EXIST, "The template \"" + templateName + "\" was not found."); return(null); } return(DynamicTemplateReference.INSTANCE); }
} //public static System.Xml.XmlElement CreateChildElement() /// <summary> /// 根据XML节点的名称和属性值找到子节点 /// </summary> /// <param name="rootElement">根节点</param> /// <param name="strName">指定的节点名称</param> /// <param name="strAttrName">指定的节点属性名</param> /// <param name="strAttrValue">指定的属性值</param> /// <param name="bolCreate">若为找到相匹配的节点则是否创建该节点</param> /// <returns>找到的XML节点,若没参数错误或没找到则返回空引用</returns> public static System.Xml.XmlElement GetElementByAttribute( System.Xml.XmlElement rootElement, string strName, string strAttrName, string strAttrValue, bool bolCreate) { System.Xml.XmlElement myElement = null; if (rootElement == null || strName == null || strAttrName == null || strAttrValue == null) { return(null); } else { foreach (System.Xml.XmlNode myNode in rootElement.ChildNodes) { myElement = myNode as System.Xml.XmlElement; if (myElement != null && myElement.Name == strName && myElement.HasAttribute(strAttrName) && myElement.GetAttribute(strAttrName) == strAttrValue) { return(myElement); } } } if (bolCreate) { myElement = rootElement.OwnerDocument.CreateElement(strName); myElement.SetAttribute(strAttrName, strAttrValue); rootElement.AppendChild(myElement); return(myElement); } return(null); } //public static System.Xml.XmlElement GetElementByAttribute()
private string GetOptionalPrevalenceBase(System.Xml.XmlElement element, string id) { if (element.HasAttribute("base")) { return(element.GetAttribute("base")); } return(Path.Combine(GetPersonalPrevalenceFolder(), id)); }
public override void ReadXml(System.Xml.XmlElement element) { base.ReadXml(element); if (element.HasAttribute("baudRate")) { baudRate = Convert.ToInt32(element.GetAttribute("baudRate")); } if (element.HasAttribute("autoDetectAnimation")) { autoDetectAnimation = Convert.ToBoolean(element.GetAttribute("autoDetectAnimation")); } if (element.HasAttribute("animationEnabled")) { animationEnabled = Convert.ToBoolean(element.GetAttribute("animationEnabled")); } }
private string GetOptionalAttribute(System.Xml.XmlElement element, string name, string defaultValue) { if (element.HasAttribute(name)) { return(element.GetAttribute(name)); } return(defaultValue); }
protected internal override string GetTypeName(System.Xml.XmlElement fieldNode) { if (fieldNode.HasAttribute("charset")) { return(fieldNode.GetAttribute("charset")); } return("ascii"); }
public override void LoadFromXml(System.Xml.XmlElement xml) { base.LoadFromXml(xml); // backward compatibility if (xml.HasAttribute("filename")) { XmlFileName = xml.GetAttribute("filename"); } }
public override Field Parse(System.Xml.XmlElement fieldNode, bool optional, ParsingContext context) { Operator.Operator operator_Renamed = Operator.Operator.NONE; string defaultValue = null; string key = null; string ns = ""; System.Xml.XmlElement operatorElement = GetOperatorElement(fieldNode); if (operatorElement != null) { if (operatorElement.HasAttribute("value")) { defaultValue = operatorElement.GetAttribute("value"); } operator_Renamed = Operator.Operator.GetOperator(operatorElement.Name); if (operatorElement.HasAttribute("key")) { key = operatorElement.GetAttribute("key"); } if (operatorElement.HasAttribute("ns")) { ns = operatorElement.GetAttribute("ns"); } if (operatorElement.HasAttribute("dictionary")) { context.Dictionary = operatorElement.GetAttribute("dictionary"); } } FASTType type = GetType(fieldNode, context); var scalar = new Scalar(GetName(fieldNode, context), type, operator_Renamed, type.GetValue(defaultValue), optional); if (fieldNode.HasAttribute("id")) { scalar.Id = fieldNode.GetAttribute("id"); } if (key != null) { scalar.Key = new QName(key, ns); } scalar.Dictionary = context.Dictionary; ParseExternalAttributes(fieldNode, scalar); return(scalar); }
protected internal static void ParseMore(System.Xml.XmlElement groupElement, Group group, ParsingContext context) { group.ChildNamespace = context.Namespace; if (groupElement.HasAttribute("id")) { group.Id = groupElement.GetAttribute("id"); } group.TypeReference = GetTypeReference(groupElement); ParseExternalAttributes(groupElement, group); }
public ParsingContext(System.Xml.XmlElement node, ParsingContext parent) { this.parent = parent; if (node.HasAttribute("templateNs")) { TemplateNamespace = node.GetAttribute("templateNs"); } if (node.HasAttribute("ns")) { Namespace = node.GetAttribute("ns"); } if (node.HasAttribute("dictionary")) { Dictionary = node.GetAttribute("dictionary"); } if (node.HasAttribute("name")) { setName(new QName(node.GetAttribute("name"), Namespace)); } }
private static ThreeDSecuredCreditCard Verify3D_Saferpay(ThreeDSecuredCreditCard threeDCard) { ThreeDSecuredCreditCard result3DCard = new ThreeDSecuredCreditCard(); result3DCard = threeDCard; System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(threeDCard.PaRes); System.Xml.XmlElement root = doc.DocumentElement; string authenticationResult = (null != root && root.HasAttribute("RESULT")) ? root.Attributes["RESULT"].Value : string.Empty; string mpiSessionId = (null != root && root.HasAttribute("MPI_SESSIONID")) ? root.Attributes["MPI_SESSIONID"].Value : string.Empty; string authenticationMessage = (null != root && root.HasAttribute("MESSAGE")) ? root.Attributes["MESSAGE"].Value : string.Empty; string authenticationType = (null != root && root.HasAttribute("MSGTYPE")) ? root.Attributes["MSGTYPE"].Value : string.Empty; string eci = (null != root && root.HasAttribute("ECI")) ? root.Attributes["ECI"].Value : string.Empty; result3DCard.ReasonCode = !string.IsNullOrEmpty(authenticationResult) ? authenticationResult : threeDCard.ReasonCode; result3DCard.Decision = !string.IsNullOrEmpty(authenticationMessage) ? authenticationMessage : threeDCard.Decision; result3DCard.Eci = !string.IsNullOrEmpty(eci) ? eci : threeDCard.Eci; // 3D popup response data is good, then call Verify3DAuthentication(...) if (authenticationType == "AuthenticationConfirm" && authenticationResult == "0") { bool callVerificationService = true; if (HLConfigManager.Configurations.PaymentsConfiguration.Check3DPaymentEci && eci != "1" && eci != "2") { callVerificationService = false; result3DCard.IsErrored = true; } if (callVerificationService) { result3DCard = ThreeDPaymentProvider.Verify3DThroughSevice(result3DCard); } } else { result3DCard.IsErrored = true; } return(result3DCard); }
public override bool FromXML(System.Xml.XmlElement myElement) { if (myElement != null) { this.Type = StringCommon.GetTypeByName(myElement.GetAttribute("type")); this.Attributes.FromXML(myElement); this.Name = myElement.GetAttribute("name"); this.Event = myElement.GetAttribute("event"); if (myElement.HasAttribute("print")) { this.Print = bool.Parse(myElement.GetAttribute("print")); } if (myElement.HasAttribute("candelete")) { this.CanDelete = bool.Parse(myElement.GetAttribute("candelete")); } return(true); } return(false); }
private anmar.SharpWebMail.ServerSelector ParseConfigServers(System.Xml.XmlNodeList list) { anmar.SharpWebMail.ServerSelector selector = new anmar.SharpWebMail.ServerSelector(); foreach (System.Xml.XmlNode item in list) { if (item.NodeType.Equals(System.Xml.XmlNodeType.Element) && (item.LocalName.Equals("server") || item.LocalName.Equals("add"))) { System.Xml.XmlElement element = (System.Xml.XmlElement)item; if (element.HasAttribute("key") && element.HasAttribute("value")) // Old format { selector.Add(element.GetAttribute("key"), element.GetAttribute("value")); } else if (element.HasAttribute("protocol") && element.HasAttribute("host") && element.HasAttribute("port")) // New format { anmar.SharpWebMail.EmailServerInfo server = new anmar.SharpWebMail.EmailServerInfo(element.GetAttribute("protocol"), element.GetAttribute("host"), element.GetAttribute("port")); if (element.HasAttribute("regexp")) { server.SetCondition(element.GetAttribute("regexp")); } if (element.HasAttribute("name")) { server.Name = element.GetAttribute("name"); } if (server.IsValid()) { selector.Add(server); } } } } return(selector); }
public bool FromXML(System.Xml.XmlElement myElement) { if (myElement != null) { strUserName = myElement.GetAttribute("name"); //dtSaveDateTime = ZYCommon.StringCommon.ConvertToDateTime( myElement.GetAttribute("time"),null,System.DateTime.Now); dtSaveDateTime = StringCommon.ConvertToDateTime(myElement.GetAttribute("time"), null, ZYTime.GetServerTime()); this.Lock = myElement.HasAttribute("lock"); this.Level = StringCommon.ToInt32Value(myElement.GetAttribute("level"), 0); return(true); } return(false); }
public static InventoryItem CreateFromXml(System.Xml.XmlElement n, Roar.DataConversion.IXCRMParser ixcrm_parser) { DomainObjects.InventoryItem retval = new DomainObjects.InventoryItem(); retval.id = n.GetAttribute("id"); retval.ikey = n.GetAttribute("ikey"); retval.type = n.GetAttribute("type"); retval.label = n.GetAttribute("label"); retval.description = n.GetAttribute("description"); if (n.HasAttribute("count") && !System.Int32.TryParse(n.GetAttribute("count"), out retval.count)) { throw new InvalidXMLElementException("Unable to parse count to integer"); } if (n.HasAttribute("consumable")) { retval.consumable = n.GetAttribute("consumable").ToLower() == "true"; } if (n.HasAttribute("sellable")) { retval.sellable = n.GetAttribute("sellable").ToLower() == "true"; } if (n.HasAttribute("equipped")) { retval.equipped = n.GetAttribute("equipped").ToLower() == "true"; } retval.stats = ixcrm_parser.ParseItemStatList(n.SelectSingleNode("./stats") as System.Xml.XmlElement); retval.price = ixcrm_parser.ParseModifierList(n.SelectSingleNode("./price") as System.Xml.XmlElement); retval.tags = ixcrm_parser.ParseTagList(n.SelectSingleNode("./tags") as System.Xml.XmlElement); System.Xml.XmlNodeList property_nodes = n.SelectNodes("./properties/property"); foreach (System.Xml.XmlElement property_node in property_nodes) { Roar.DomainObjects.ItemArchetypeProperty property = new Roar.DomainObjects.ItemArchetypeProperty(); property.ikey = property_node.GetAttribute("ikey"); property.value = property_node.GetAttribute("value"); retval.properties.Add(property); } return(retval); }
/** * This extension allows us to do things like * * n.SelectSingleNode( "./blah" ).GetAttributeOrDefaulr("foo",null) * * in the case where the selected node may be null, while keeping the code concise. * It also allows us to default to null,. rather than empty string when the attribute is not present. */ public static string GetAttributeOrDefault(this System.Xml.XmlNode n, string attribute, string default_value) { System.Xml.XmlElement e = n as System.Xml.XmlElement; if (e == null) { return(default_value); } if (!e.HasAttribute(attribute)) { return(default_value); } return(e.GetAttribute(attribute)); }
private new void LoadFromXml(System.Xml.XmlElement xmlEl) { base.LoadFromXml(xmlEl); if (this.MdxParameters.Count < 1 || this.MdxParameters.Count > 2) { throw new Exception("Number of references expected: 1 or 2"); } if (xmlEl.HasAttribute("F")) // backward compat { _operation = (Operations)System.Enum.Parse(typeof(Operations), xmlEl.GetAttribute("F")); } Initialize(_name, false); }
/// <summary> /// 对元素数据进行基础的加载 /// </summary> /// <param name="myElement"></param> /// <returns></returns> protected bool BaseFromXML(System.Xml.XmlElement myElement) { if (myElement != null) { myAttributes.FromXML(myElement); //myAttributes.RemoveAttribute(ZYTextConst.c_Creator); //myAttributes.RemoveAttribute(ZYTextConst.c_Deleter); myAttributes.RemoveAttribute("createtime"); myAttributes.RemoveAttribute("deletetime"); if (myElement.HasAttribute(ZYTextConst.c_Creator)) { this.CreatorIndex = StringCommon.ToInt32Value(myElement.GetAttribute(ZYTextConst.c_Creator), 0); } else { this.CreatorIndex = 0; } if (myElement.HasAttribute(ZYTextConst.c_Deleter)) { this.DeleterIndex = StringCommon.ToInt32Value(myElement.GetAttribute(ZYTextConst.c_Deleter), -1); } else { this.DeleterIndex = -1; } //intDeleter = myAttributes.GetInt32( ZYTextConst.c_Deleter ); //intCreatorIndex = myAttributes.GetInt32( ZYTextConst.c_Creator); if (myBorder != null) { myBorder.FromXML(myElement); } UpdateAttrubute(); return(true); } return(false); }
private new void LoadFromXml(System.Xml.XmlElement xmlEl) { base.LoadFromXml(xmlEl); if (this.MdxParameters.Count != 2) { throw new Exception("Number of references expected: 2"); } if (xmlEl.HasAttribute("O")) // backward compat { _operator = (Operators)System.Enum.Parse(typeof(Operators), xmlEl.GetAttribute("O")); } _value = xmlEl.GetAttribute("V"); Initialize(_name); }
public override Field Parse(System.Xml.XmlElement templateElement, bool optional, ParsingContext context) { var messageTemplate = new MessageTemplate(getTemplateName(templateElement, context), ParseFields(templateElement, context)); ParseMore(templateElement, messageTemplate, context); if (loadTemplateIdFromAuxId && templateElement.HasAttribute("id")) { try { int templateId = System.Int32.Parse(templateElement.GetAttribute("id")); context.TemplateRegistry.Register(templateId, messageTemplate); } catch (System.FormatException) { context.TemplateRegistry.Define(messageTemplate); } } else { context.TemplateRegistry.Define(messageTemplate); } return(messageTemplate); }
public void Load(System.Xml.XmlElement templateElement) { System.Xml.XmlElement smtpElement = templateElement["Smtp"]; if (smtpElement == null) { this.Smtp = new System.Net.Mail.SmtpClient(); } else { this.Smtp.Host = smtpElement.GetAttribute("host"); this.Smtp.Port = int.Parse(smtpElement.GetAttribute("port")); this.Smtp.EnableSsl = bool.Parse(smtpElement.GetAttribute("enableSSL")); this.Smtp.DeliveryMethod = (System.Net.Mail.SmtpDeliveryMethod) Enum.Parse(typeof(System.Net.Mail.SmtpDeliveryMethod), smtpElement.GetAttribute("deliveryMethod")); this.Smtp.Credentials = new System.Net.NetworkCredential( smtpElement.GetAttribute("username"), smtpElement.GetAttribute("password")); } System.Xml.XmlElement subjectElement = templateElement["Subject"]; this.Subject = subjectElement == null ? null : subjectElement.InnerText; System.Xml.XmlElement bodyElement = templateElement["Body"]; this.Body = bodyElement == null ? null : bodyElement.InnerText; this.BodyIsHtml = bodyElement == null || !bodyElement.HasAttribute("isHtml") ? false : bool.Parse(bodyElement.GetAttribute("isHtml")); System.Xml.XmlElement fromElement = templateElement["From"]; if (fromElement == null) { this.From = null; } else { this.From = new System.Net.Mail.MailAddress( fromElement.GetAttribute("address"), fromElement.GetAttribute("displayName"), System.Text.Encoding.UTF8); } System.Xml.XmlElement senderElement = templateElement["Sender"]; if (senderElement == null) { this.Sender = null; } else { this.Sender = new System.Net.Mail.MailAddress( senderElement.GetAttribute("address"), senderElement.GetAttribute("displayName"), System.Text.Encoding.UTF8); } System.Xml.XmlElement replyTo = templateElement["ReplyTo"]; if (replyTo == null) { this.ReplyTo = null; } else { this.ReplyTo = new System.Net.Mail.MailAddress( replyTo.GetAttribute("address"), replyTo.GetAttribute("displayName"), System.Text.Encoding.UTF8); } }
/// <summary> Parses the beepd element in the configuration file and loads the /// classes for the specified profiles. /// /// </summary> /// <param name="serverConfig"><beepd> configuration element. /// </param> private Beepd(Element serverConfig) { reg = new ProfileRegistry(); if (serverConfig.HasAttribute("port") == false) { throw new System.Exception("Invalid configuration, no port specified"); } port = System.Int32.Parse(serverConfig.GetAttribute("port")); // Parse the list of profile elements. NodeList profiles = serverConfig.GetElementsByTagName("profile"); for (int i = 0; i < profiles.Count; ++i) { if (profiles[i].NodeType != System.Xml.XmlNodeType.Element) { continue; } Element profile = (Element) profiles[i]; if (profile.Name.ToUpper().Equals("profile".ToUpper()) == false) { continue; } string uri; string className; //string requiredProperites; //string tuningProperties; if (profile.HasAttribute("uri") == false) { throw new System.Exception("Invalid configuration, no uri specified"); } uri = profile.GetAttribute("uri"); if (profile.HasAttribute("class") == false) { throw new System.Exception("Invalid configuration, no class " + "specified for profile " + uri); } className = profile.GetAttribute("class"); // parse the parameter elements into a ProfileConfiguration ProfileConfiguration profileConfig = parseProfileConfig(profile.GetElementsByTagName("parameter")); // load the profile class IProfile p; try { p = (IProfile) new beepcore.beep.profile.echo.EchoProfile(); //SupportClass.CreateNewInstance(System.Type.GetType(className)); //p = (IProfile) Activator.CreateInstance(Type.GetType(className, true, true)); } catch (System.InvalidCastException) { throw new System.Exception("class " + className + " does not " + "implement the " + "beepcore.beep.profile.Profile " + "interface"); } catch (System.Exception e) { throw new System.Exception("Class " + className + " not found - " + e.ToString()); } SessionTuningProperties tuning = null; if (profile.HasAttribute("tuning")) { string tuningString = profile.GetAttribute("tuning"); System.Collections.Hashtable hash = new System.Collections.Hashtable(); string[] tokens = tuningString.Split(":=".ToCharArray()); for(int tki=0; tki+1<tokens.Length; tki+=2) { string parameter = tokens[tki]; string paramvalue = tokens[tki+1]; hash[parameter] = paramvalue; } tuning = new SessionTuningProperties(hash); } // Initialize the profile and add it to the advertised profiles reg.addStartChannelListener(uri, p.Init(uri, profileConfig), tuning); } thread = new Thread(new ThreadStart(this.ThreadProc)); }
private static Field createComposedDecimal(System.Xml.XmlElement fieldNode, QName name, bool optional, System.Xml.XmlNode mantissaNode, System.Xml.XmlNode exponentNode, ParsingContext context) { string mantissaOperator = "none"; string exponentOperator = "none"; ScalarValue mantissaDefaultValue = ScalarValue.UNDEFINED; ScalarValue exponentDefaultValue = ScalarValue.UNDEFINED; QName mantissaKey = null; QName exponentKey = null; string mantissaDictionary = context.Dictionary; string exponentDictionary = context.Dictionary; string mantissaNamespace = context.Namespace; string exponentNamespace = context.Namespace; if ((mantissaNode != null) && mantissaNode.HasChildNodes) { System.Xml.XmlElement operatorElement = GetElement((System.Xml.XmlElement)mantissaNode, 1); mantissaOperator = operatorElement.Name; if (operatorElement.HasAttribute("value")) { mantissaDefaultValue = FASTType.I64.GetValue(operatorElement.GetAttribute("value")); } if (operatorElement.HasAttribute("ns")) { mantissaNamespace = operatorElement.GetAttribute("ns"); } if (operatorElement.HasAttribute("key")) { mantissaKey = new QName(operatorElement.GetAttribute("key"), mantissaNamespace); } if (operatorElement.HasAttribute("dictionary")) { mantissaDictionary = operatorElement.GetAttribute("dictionary"); } } if ((exponentNode != null) && exponentNode.HasChildNodes) { System.Xml.XmlElement operatorElement = GetElement((System.Xml.XmlElement)exponentNode, 1); exponentOperator = operatorElement.Name; if (operatorElement.HasAttribute("value")) { exponentDefaultValue = FASTType.I32.GetValue(operatorElement.GetAttribute("value")); } if (operatorElement.HasAttribute("ns")) { exponentNamespace = operatorElement.GetAttribute("ns"); } if (operatorElement.HasAttribute("key")) { exponentKey = new QName(operatorElement.GetAttribute("key"), exponentNamespace); } if (operatorElement.HasAttribute("dictionary")) { exponentDictionary = operatorElement.GetAttribute("dictionary"); } } ComposedScalar scalar = Util.ComposedDecimal(name, Operator.Operator.GetOperator(exponentOperator), exponentDefaultValue, Operator.Operator.GetOperator(mantissaOperator), mantissaDefaultValue, optional); Scalar exponent = scalar.Fields[0]; exponent.Dictionary = exponentDictionary; if (exponentKey != null) { exponent.Key = exponentKey; } Scalar mantissa = scalar.Fields[1]; mantissa.Dictionary = mantissaDictionary; if (mantissaKey != null) { mantissa.Key = mantissaKey; } if (fieldNode.HasAttribute("id")) { scalar.Id = fieldNode.GetAttribute("id"); } return(scalar); }
protected override void ParseXML(System.Xml.XmlElement root, System.Xml.XmlElement current, QuestDetail item) { switch (root.Name.ToLower()) { case "quest": { switch (current.Name.ToLower()) { case "id": item.QuestID = uint.Parse(current.InnerText); break; case "step": { QuestStep s = new QuestStep() { StepID = byte.Parse(current.Attributes["id"].Value), Finish = current.HasAttribute("finish") && bool.Parse(current.Attributes["finish"].Value) }; item.Steps.Add(s.StepID, s); } break; case "nextquest": { Job job = Job.None; if (current.HasAttribute("job")) { job = (Job)Enum.Parse(typeof(Job), current.Attributes["job"].Value); } item.NextQuest[job] = uint.Parse(current.InnerText); } break; } } break; case "step": { QuestStep step = item.Steps[byte.Parse(root.Attributes["id"].Value)]; switch (current.Name.ToLower()) { case "target": { QuestTarget target = new QuestTarget(); string type = current.Attributes["type"].Value; switch (type.ToLower()) { case "npc": target.TargetType = StepTargetType.NPC; break; case "mapobject": target.TargetType = StepTargetType.MapObject; break; case "map": target.TargetType = StepTargetType.Map; break; case "loot": target.TargetType = StepTargetType.Loot; break; default: target.TargetType = StepTargetType.None; break; } if (current.HasAttribute("flagidx")) { target.TargetFlagIndex = int.Parse(current.Attributes["flagidx"].Value); } if (current.HasAttribute("increment")) { target.TargetFlagIncrement = short.Parse(current.Attributes["increment"].Value); } if (current.HasAttribute("index")) { target.SpecifyIndex = int.Parse(current.Attributes["index"].Value); } if (current.HasAttribute("finishflagidx")) { target.TargetFinishFlagIndex = int.Parse(current.Attributes["finishflagidx"].Value); } if (current.HasAttribute("finishincrement")) { target.TargetFinishFlagIncrement = short.Parse(current.Attributes["finishincrement"].Value); } if (current.HasAttribute("count")) { target.TargetCount = short.Parse(current.Attributes["count"].Value); } if (current.HasAttribute("x")) { target.HasCoordinate = true; target.TargetX = short.Parse(current.Attributes["x"].Value); } if (current.HasAttribute("y")) { target.HasCoordinate = true; target.TargetY = short.Parse(current.Attributes["y"].Value); } if (current.HasAttribute("z")) { target.HasCoordinate = true; target.TargetZ = short.Parse(current.Attributes["z"].Value); } if (target.TargetType != StepTargetType.None) { foreach (string s in current.InnerText.Split(',')) { target.TargetIDs.Add(uint.Parse(s)); } } if (target.TargetType == StepTargetType.MapObject) { target.TargetMapID = uint.Parse(current.Attributes["map"].Value); foreach (uint id in target.TargetIDs) { ulong objID = (ulong)target.TargetMapID << 32 | id; Dictionary <uint, byte> tbl; if (mapObjectMapping.ContainsKey(objID)) { tbl = mapObjectMapping[objID]; } else { tbl = new Dictionary <uint, byte>(); mapObjectMapping.Add(objID, tbl); } tbl.Add(item.QuestID, step.StepID); } } if (target.TargetType == StepTargetType.Map && target.HasCoordinate) { foreach (uint i in target.TargetIDs) { NPC.SpawnData spawn = new NPC.SpawnData() { IsQuest = true, MapID = i, X = target.TargetX, Y = target.TargetY, Z = target.TargetZ }; NPC.NPCSpawnManager.Instance[i].Add(spawn); } } step.Targets.Add(target); } break; case "nextstep": step.NextStep = byte.Parse(current.InnerText); break; case "stepstatus": step.StepStatus = byte.Parse(current.InnerText); break; case "giveitem": { ushort count = 1; Job job = Job.None; if (current.HasAttribute("count")) { count = ushort.Parse(current.Attributes["count"].Value); } if (current.HasAttribute("job")) { job = (Job)Enum.Parse(typeof(Job), current.Attributes["job"].Value); } step.GiveItems[job].Add(uint.Parse(current.InnerText), count); } break; case "rewarditemoption": { int count = 1; Job job = Job.None; if (current.HasAttribute("count")) { count = int.Parse(current.Attributes["count"].Value); } if (current.HasAttribute("job")) { job = (Job)Enum.Parse(typeof(Job), current.Attributes["job"].Value); } step.RewardOptions[job][uint.Parse(current.InnerText)] = count; } break; case "teleport": step.TeleportMapID = uint.Parse(current.InnerText); if (current.HasAttribute("x")) { step.X = short.Parse(current.Attributes["x"].Value); } if (current.HasAttribute("y")) { step.Y = short.Parse(current.Attributes["y"].Value); } if (current.HasAttribute("z")) { step.Z = short.Parse(current.Attributes["z"].Value); } if (current.HasAttribute("u1")) { step.TeleportU1 = short.Parse(current.Attributes["u1"].Value); } if (current.HasAttribute("u2")) { step.TeleportU2 = short.Parse(current.Attributes["u2"].Value); } if (current.HasAttribute("cutscene")) { step.TeleportCutscene = uint.Parse(current.Attributes["cutscene"].Value); } break; case "cutscene": step.CutScene = uint.Parse(current.InnerText); break; case "takeitem": { ushort count = 1; Job job = Job.None; if (current.HasAttribute("count")) { count = ushort.Parse(current.Attributes["count"].Value); } if (current.HasAttribute("job")) { job = (Job)Enum.Parse(typeof(Job), current.Attributes["job"].Value); } step.TakeItems[job].Add(uint.Parse(current.InnerText), count); } break; case "exp": { step.Exp = uint.Parse(current.InnerText); } break; case "learnskill": { Job job = Job.None; if (current.HasAttribute("job")) { job = (Job)Enum.Parse(typeof(Job), current.Attributes["job"].Value); } step.LearnSkills[job].Add(uint.Parse(current.InnerText)); } break; case "gold": { step.Gold = int.Parse(current.InnerText); } break; case "spawn": { NPC.SpawnData spawn = new NPC.SpawnData() { NpcID = ushort.Parse(current.Attributes["npcID"].Value), X = short.Parse(current.Attributes["x"].Value), Y = short.Parse(current.Attributes["y"].Value), Z = short.Parse(current.Attributes["z"].Value), Dir = ushort.Parse(current.Attributes["dir"].Value) }; if (current.HasAttribute("motion")) { spawn.Motion = ushort.Parse(current.Attributes["motion"].Value); } if (current.HasAttribute("appeareffect")) { spawn.AppearEffect = ushort.Parse(current.Attributes["appeareffect"].Value); } step.Spawns.Add(spawn); } break; case "flag1": step.Flag1 = short.Parse(current.InnerText); break; case "flag2": step.Flag2 = short.Parse(current.InnerText); break; case "flag3": step.Flag3 = short.Parse(current.InnerText); break; case "holditem": step.HoldItem = uint.Parse(current.InnerText); break; case "dropitem": step.DropItem = uint.Parse(current.InnerText); break; } } break; } }