protected string getFunctionDocAndExample(XmlReader reader)
        {
            //assumes doc is before example. Otherwise, could miss an example.
            string strRes = "";
            bool bFound = reader.ReadToDescendant("doc");
            if (bFound) strRes += (unencodeXml(reader.ReadString()));
            bFound = reader.ReadToNextSibling("example");
            if (bFound) strRes += ("\r\n\r\nExample:\r\n" + unencodeXml(reader.ReadString()));

            reader.Close();
            return strRes;
        }
Example #2
0
        public void ReadXml(XmlReader reader)
        {
            if (reader.LocalName != "icon" && !reader.ReadToDescendant("icon"))
                throw new InvalidDataException();

            XmlHelper.ParseXml(reader, new XmlParseSet
            {
                {"url", () => this.RelativeUrl = reader.ReadString()},
                {"mimetype", () => this.MimeType = reader.ReadString()},
                {"width", () => this.Width = reader.ReadElementContentAsInt()},
                {"height", () => this.Height = reader.ReadElementContentAsInt()},
                {"depth", () => this.Depth = reader.ReadElementContentAsInt()}
            });
        }
        /// <summary>
        /// Obtains the type and value of a parameter from an XML Error file.
        /// </summary>
        /// <param name="reader">XML Error file.</param>
        /// <param name="parameter">Parameter to obtain.</param>
        /// <returns>Parameter.</returns>
        public static Parameter Deserialize(XmlReader reader, Parameter parameter)
        {
            if (reader.IsStartElement(DTD.Error.ErrorParams.TagErrorParam))
            {
                if (parameter == null)
                {
                    parameter = new Parameter();
                }

                // Read Attributes of Node.
                parameter.Key = reader.GetAttribute(DTD.Error.ErrorParams.TagKey);
                switch (reader.GetAttribute(DTD.Error.ErrorParams.TagType))
                {
                    case ResponseException.ErrorKey:
                        parameter.Type = ErrorParamType.Key;
                        break;
                    case ResponseException.ErrorLiteral:
                        parameter.Type = ErrorParamType.Literal;
                        break;
                }

                if (!reader.IsEmptyElement)
                {
                    parameter.Text = reader.ReadString();
                }
                else
                {
                    reader.Skip();
                }
            }
            return parameter;
        }
Example #4
0
        public override void ReadXml(XmlReader reader)
        {
            var isEmptyElement = reader.IsEmptyElement;

            var packagePathHash = new FoxHash("packagePathHash");
            packagePathHash.ReadXml(reader);
            var archivePathHash = new FoxHash("archivePathHash");
            archivePathHash.ReadXml(reader);
            var nameInArchiveHash = new FoxHash("nameInArchiveHash");
            nameInArchiveHash.ReadXml(reader);

            var packagePath = reader.GetAttribute("packagePath");
            var archivePath = reader.GetAttribute("archivePath");
            var nameInArchive = reader.GetAttribute("nameInArchive");

            PackagePathLiteral = new FoxStringLiteral(packagePath, packagePathHash);
            ArchivePathLiteral = new FoxStringLiteral(archivePath, archivePathHash);
            NameInArchiveLiteral = new FoxStringLiteral(nameInArchive, nameInArchiveHash);

            reader.ReadStartElement("value");
            if (isEmptyElement == false)
            {
                string value = reader.ReadString();
                EntityHandle = value.StartsWith("0x")
                    ? ulong.Parse(value.Substring(2, value.Length - 2), NumberStyles.AllowHexSpecifier)
                    : ulong.Parse(value);
                reader.ReadEndElement();
            }
        }
		Dictionary<string, List<CallerInfo>> ReadValidCertificates(XmlReader parser) {
			var validCertificates = new Dictionary<string, List<CallerInfo>>();
			try {
				while (parser.Read()) {
					if (parser.IsStartElement() && parser.Name == "signing_certificate") {
						var name = parser[0];
						var packageName = parser[2];
						var isRelease = Convert.ToBoolean(parser[1]);
						var certificate = parser.ReadString();
						if (certificate != null)
							certificate = certificate.Replace("\\s|\\n", "");

						var info = new CallerInfo(name, packageName, isRelease, certificate);

						List<CallerInfo> infos; 
						validCertificates.TryGetValue(certificate, out infos);
						if (infos == null) {
							infos = new List<CallerInfo>();
							validCertificates.Add(certificate, infos);
						}
						LogHelper.Verbose(Tag, "Adding allowed caller: ", info.Name,
							" package=", info.PackageName, " release=", info.Release,
							" certificate=", certificate);
						infos.Add(info);
					}
				}
			} catch (XmlException e) {
				LogHelper.Error(Tag, e, "Could not read allowed callers from XML.");
			} catch (IOException e) {
				LogHelper.Error(Tag, e, "Could not read allowed callers from XML.");
			}
			return validCertificates;
		}
Example #6
0
		protected override void LoadLanguageSpecificSettings(XmlReader xr)
		{
			while(xr.Read())
				switch (xr.LocalName)
				{
					case "type":
						try
						{
							OutputType = (OutputTypes)Convert.ToInt32(xr.ReadString());
						}
						catch { }
						break;
					case "isrelease":
						IsRelease = xr.ReadString()=="true";
						break;
					case "dversion":
						DMDVersion = (DVersion)Convert.ToInt32(xr.ReadString());
						break;
					case "libs":
						var xr2 = xr.ReadSubtree();
						while (xr2.Read())
						{
							if (xr2.LocalName == "lib")
								LinkedLibraries.Add(xr2.ReadString());
						}
						break;
					default: break;
				}
		}
        //public static Oids.Oid Deserialize(XmlReader reader, Oids.Oid oid)
        /// <summary>
        /// Deserializes Oid from an XML stream.
        /// </summary>
        /// <param name="reader">XML stream.</param>
        /// <returns>Oid.</returns>
        public static Oids.Oid Deserialize(XmlReader reader)
        {
            Oids.Oid lResult = null;
            if (reader.IsStartElement(DTD.TagOID))
            {
                string lClassName = reader.GetAttribute(DTD.OID.TagClass);
                List<KeyValuePair<ModelType,object>> lFields = new List<KeyValuePair<ModelType,object>>();

                if (!reader.IsEmptyElement)
                {
                    reader.ReadStartElement();
                    do
                    {
                    #region Process tag <OID.Field>.
                    if (reader.IsStartElement(DTD.OID.TagOIDField))
                    {
                        if (!reader.IsEmptyElement)
                        {
                            ModelType lType = Convert.StringTypeToMODELType(reader.GetAttribute(DTD.OID.TagType));
                            lFields.Add(new KeyValuePair<ModelType, object>(lType, Convert.XmlToType(lType, reader.ReadString())));
                        }
                        else
                        {
                            throw new ArgumentException("Xml Reader have one OID.Field with empty Element.", "XmlReader reader");
                        }
                    }
                    #endregion Process tag <OID.Field>.
                    else
                    {
                        #region Process tag <?>
                        reader.Skip();
                        if (reader.NodeType == XmlNodeType.None)
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                        #endregion Process tag <?>
                    }
                    } while (reader.Read());
                }
                else
                {
                    reader.Skip();
                }

                if(lClassName.Length > 0)
                {
                    lResult = ServerConnection.CreateOid(lClassName,lFields);
                }
            }
            else
            {
                throw new ArgumentException("Xml Reader don't have the OID in Start Element.", "XmlReader reader");
            }
            return lResult;
        }
Example #8
0
 public void ReadXml(XmlReader reader)
 {
     if (reader.IsEmptyElement) {
         reader.Read();
         return;
     }
     reader.ReadStartElement("File");
     FilePath = reader.ReadString();
     reader.ReadEndElement();
 }
Example #9
0
 public void ReadXml(XmlReader reader)
 {
     var isEmptyElement = reader.IsEmptyElement;
     reader.ReadStartElement("value");
     if (isEmptyElement == false)
     {
         Value = double.Parse(reader.ReadString(), CultureInfo.InvariantCulture);
         reader.ReadEndElement();
     }
 }
Example #10
0
 public void ReadXml(XmlReader reader)
 {
     var isEmptyElement = reader.IsEmptyElement;
     reader.ReadStartElement("value");
     if (isEmptyElement == false)
     {
         Value = bool.Parse(reader.ReadString());
         reader.ReadEndElement();
     }
 }
Example #11
0
 public void ReadXml(XmlReader reader)
 {
     var isEmptyElement = reader.IsEmptyElement;
     reader.ReadStartElement("value");
     if (isEmptyElement == false)
     {
         Value = ExtensionMethods.ParseFloatRoundtrip(reader.ReadString());
         reader.ReadEndElement();
     }
 }
Example #12
0
		public static string ReadContent(XmlReader xr)
		{
			string rlt;
			if (xr.NodeType != XmlNodeType.Element)
			{
				xr.MoveToElement();
			}
			rlt = xr.ReadString();
			xr.MoveToElement();
			return rlt;
		}
Example #13
0
File: test.cs Project: mono/gert
	void IXmlSerializable.ReadXml (XmlReader reader)
	{
		XmlDocument doc = new XmlDocument ();
		string str = reader.ReadString ();
		try {
			doc.LoadXml (str);
		} catch {
			doc.LoadXml (reader.ReadOuterXml ());
		}
		mFuncXmlNode = (XmlNode) (doc.DocumentElement);
	}
 private static bool ProcessChildNode(XmlReader xmlTextReader, LogEntry entry)
 {
     switch (xmlTextReader.Name)
     {
         case "log4j:event":
             return true;
         case ("log4j:message"):
             entry.Message = xmlTextReader.ReadString();
             break;
         case ("log4j:data"):
             ProcessDataTag(xmlTextReader, entry);
             break;
         case ("log4j:throwable"):
             entry.Throwable = xmlTextReader.ReadString();
             break;
         case ("log4j:locationInfo"):
             SetLocationInfo(entry, xmlTextReader);
             break;
     }
     return false;
 }
Example #15
0
 public void Load(XmlReader reader)
 {
     while (reader.Read()) {
         if (reader.IsStartElement()) {
             switch (reader.Name) {
                 case "ActionType": {
                         ActionType = reader.ReadString().ToEnum<Logic.Display.CharSprite.ActionType>();
                         break;
                     }
             }
         }
     }
 }
Example #16
0
 public void ReadXml(XmlReader reader)
 {
     var isEmptyElement = reader.IsEmptyElement;
     reader.ReadStartElement("value");
     if (isEmptyElement == false)
     {
         string value = reader.ReadString();
         Value = value.StartsWith("0x")
             ? sbyte.Parse(value.Substring(2, value.Length - 2), NumberStyles.AllowHexSpecifier)
             : sbyte.Parse(value);
         reader.ReadEndElement();
     }
 }
Example #17
0
 public void ReadXml(XmlReader reader)
 {
     var isEmptyElement = reader.IsEmptyElement;
     reader.ReadStartElement("value");
     if (isEmptyElement == false)
     {
         string entityPtr = reader.ReadString();
         EntityPtr = entityPtr.StartsWith("0x")
             ? ulong.Parse(entityPtr.Substring(2, entityPtr.Length - 2), NumberStyles.AllowHexSpecifier)
             : ulong.Parse(entityPtr);
         reader.ReadEndElement();
     }
 }
Example #18
0
 Profile(XmlReader r)
 {
     while (r.Read())
     {
         if (r.NodeType == XmlNodeType.Element)
         {
             if (r.Name == "guid")
             {
                 string content = r.ReadString();
                 profileId = new Guid(content);
             }
             else if (r.Name == "name")
             {
                 string content = r.ReadString();
                 profileName = content;
             }
             else if (r.Name == "description")
             {
                 string content = r.ReadString();
                 profileDesc = content;
             }
         }
     }
 }
Example #19
0
		public void ReadXml(XmlReader reader) {
			reader.ReadToFollowing("TypeName");
			reader.ReadStartElement("TypeName");
			TypeName=reader.ReadString();
			reader.ReadEndElement();//TypeName
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();//gets rid of whitespace if in debug mode.
			}
			reader.ReadStartElement("Obj");
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();
			}
			string strObj=reader.ReadOuterXml();
			//now get the reader to the correct location
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//Obj
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//DtoObject
			Type type=null;
			if(TypeName.StartsWith("List<")) {
				Type typeGen=Type.GetType(TypeName.Substring(5,TypeName.Length-6));
				Type typeList=typeof(List<>);
				type=typeList.MakeGenericType(typeGen);
			}
			else if(TypeName=="System.Drawing.Color") {
				type=typeof(int);
			}
			else {
				//This works fine for non-system types as well without specifying the assembly,
				//because we are already in the OpenDentBusiness assembly.
				type=Type.GetType(TypeName);
			}
			XmlSerializer serializer = new XmlSerializer(type);
			//XmlReader reader2=XmlReader.Create(new StringReader(strObj));
			XmlTextReader reader2=new XmlTextReader(new StringReader(strObj));
			if(TypeName=="System.Drawing.Color") {
				Obj=Color.FromArgb((int)serializer.Deserialize(reader2));
			}
			else {
				Obj=serializer.Deserialize(reader2);
			}
				//Convert.ChangeType(serializer.Deserialize(reader2),type);
		}
Example #20
0
		public void ReadXml(XmlReader reader) {
			reader.ReadToFollowing("TypeName");
			reader.ReadStartElement("TypeName");
			TypeName=reader.ReadString();
			reader.ReadEndElement();//TypeName
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();//gets rid of whitespace if in debug mode.
			}
			reader.ReadStartElement("Obj");
			while(reader.NodeType!=XmlNodeType.Element) {
				reader.Read();
			}
			string strObj=reader.ReadOuterXml();
			//now get the reader to the correct location
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//Obj
			while(reader.NodeType!=XmlNodeType.EndElement) {
				reader.Read();
			}
			reader.ReadEndElement();//DtoObject
			//Now, process what we read.
			Type type=null;
			if(TypeName=="System.Drawing.Color") {
				type=typeof(int);
			}
			else{
				type=ConvertNameToType(TypeName);
			}
			XmlSerializer serializer = new XmlSerializer(type);
			//XmlReader reader2=XmlReader.Create(new StringReader(strObj));
			XmlTextReader reader2=new XmlTextReader(new StringReader(strObj));
			if(TypeName=="System.Drawing.Color") {
				Obj=Color.FromArgb((int)serializer.Deserialize(reader2));
			}
			else {
				Obj=serializer.Deserialize(reader2);
			}
				//Convert.ChangeType(serializer.Deserialize(reader2),type);
		}
Example #21
0
 public static string ReadXmlElement(XmlReader r, string name)
 {
     if (r.IsStartElement(name))
     {
         //r.Read();
         if (!r.IsEmptyElement)
         {
             r.ReadStartElement(name);
             string s = r.ReadString();
             r.ReadEndElement();
             return s;
         }
         else
         {
             r.Read();
         }
     }
     else
     {
         r.Read();
     }
     return string.Empty;
 }
        private void CreateAnnotations(XmlReader reader, TrackingAnnotationCollection annotations)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == annotations)
                throw new ArgumentNullException("annotations");

            if (0 != string.Compare(reader.Name, "Annotations", StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "Annotations.");

            if (reader.IsEmptyElement)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Annotation", StringComparison.Ordinal))
                        {
                            //
                            // Preserve null and empty as distinct values
                            // null == <Annotation /> empty string = <Annotation></Annotation>
                            if (!reader.IsEmptyElement)
                                annotations.Add(reader.ReadString());
                            else
                                annotations.Add(null);
                        }
                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, "Annotations", StringComparison.Ordinal))
                            return;
                        break;
                }
            }
            //
            // Only valid exit is on an EndElement that matches the element that is passed in.
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "Annotations.");
        }
        private void CreateExtract(XmlReader reader, TrackingExtract extract)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == extract)
                throw new ArgumentNullException("extract");

            if (reader.IsEmptyElement)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Member", StringComparison.Ordinal))
                            extract.Member = reader.ReadString();
                        else if (0 == string.Compare(reader.Name, "Annotations", StringComparison.Ordinal))
                            CreateAnnotations(reader, extract.Annotations);
                        //
                        // Xsd validation will catch unknown elements

                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, extract.GetType().Name, StringComparison.Ordinal))
                            return;
                        break;
                }
            }
            //
            // Only valid exit is on an EndElement that matches the element that is passed in.
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + extract.GetType().Name);
        }
        private void CreateCondition(XmlReader reader, TrackingCondition condition)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == condition)
                throw new ArgumentNullException("condition");

            if (0 != string.Compare(condition.GetType().Name, reader.Name, StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + condition.GetType().Name);

            if (reader.IsEmptyElement)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Member", StringComparison.Ordinal))
                        {
                            condition.Member = reader.ReadString();
                        }
                        else if (0 == string.Compare(reader.Name, "Operator", StringComparison.Ordinal))
                        {
                            string op = reader.ReadString();
                            if ((null != op) && (op.Trim().Length > 0))
                            {
                                string[] names = Enum.GetNames(typeof(ComparisonOperator));
                                foreach (string s in names)
                                {
                                    if (0 == string.Compare(s, op, StringComparison.Ordinal))
                                        condition.Operator = (ComparisonOperator)Enum.Parse(typeof(ComparisonOperator), op);
                                }
                            }
                        }
                        else if (0 == string.Compare(reader.Name, "Value", StringComparison.Ordinal))
                        {
                            if (!reader.IsEmptyElement)
                                condition.Value = reader.ReadString();
                        }
                        //
                        // Xsd validation will catch unknown elements

                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, condition.GetType().Name, StringComparison.Ordinal))
                            return;
                        break;
                }
            }
            //
            // Only valid exit is on an EndElement that matches the element that is passed in.
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + condition.GetType().Name);
        }
        private void CreateStatusEvents(XmlReader reader, IList<ActivityExecutionStatus> events)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == events)
                throw new ArgumentNullException("events");

            if (0 != string.Compare("ExecutionStatusEvents", reader.Name, StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "ExecutionStatusEvents.");

            if (reader.IsEmptyElement)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "ExecutionStatus", StringComparison.Ordinal))
                        {
                            string status = reader.ReadString();
                            if ((null != status) && (status.Trim().Length > 0))
                            {
                                string[] names = Enum.GetNames(typeof(ActivityExecutionStatus));
                                foreach (string s in names)
                                {
                                    if (0 == string.Compare(s, status, StringComparison.Ordinal))
                                        events.Add((ActivityExecutionStatus)Enum.Parse(typeof(ActivityExecutionStatus), status));
                                }
                            }
                        }
                        //
                        // Xsd validation will catch unknown elements

                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, "ExecutionStatusEvents", StringComparison.Ordinal))
                            return;
                        break;
                }
            }
            //
            // Something is funky
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "ExecutionStatusEvents.");
        }
        private void CreateWorkflowTrackPoint(XmlReader reader, TrackingProfile profile)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == profile)
                throw new ArgumentNullException("profile");

            if (0 != string.Compare(reader.Name, "WorkflowTrackPoint", StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "WorkflowTrackPoint.");

            if (reader.IsEmptyElement)
                return;

            WorkflowTrackPoint point = new WorkflowTrackPoint();
            point.MatchingLocation = new WorkflowTrackingLocation();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Annotations", StringComparison.Ordinal))
                            CreateAnnotations(reader, point.Annotations);
                        else if (0 == string.Compare(reader.Name, "TrackingWorkflowEvent", StringComparison.Ordinal))
                            point.MatchingLocation.Events.Add((TrackingWorkflowEvent)Enum.Parse(typeof(TrackingWorkflowEvent), reader.ReadString()));
                        //
                        // Xsd validation will catch unknown elements
                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, "WorkflowTrackPoint", StringComparison.Ordinal))
                        {
                            profile.WorkflowTrackPoints.Add(point);
                            return;
                        }
                        break;
                }
            }
            //
            // Only valid exit is on an EndElement that matches the element that is passed in.
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "WorkflowTrackPoint.");
        }
        private void CreateUserTrackingLocation(XmlReader reader, UserTrackingLocation location)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == location)
                throw new ArgumentNullException("location");

            if (0 != string.Compare(reader.Name, "UserTrackingLocation", StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "UserTrackingLocation.");

            if (reader.IsEmptyElement)
                return;

            string name = null, type = null;
            bool derived = false, seenAct = false, seenArg = false;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Activity", StringComparison.Ordinal))
                            seenAct = true;
                        else if (0 == string.Compare(reader.Name, "KeyName", StringComparison.Ordinal))
                            location.KeyName = reader.ReadString();
                        else if (0 == string.Compare(reader.Name, "Argument", StringComparison.Ordinal))
                            seenArg = true;
                        else if (0 == string.Compare(reader.Name, "TypeName", StringComparison.Ordinal))
                            name = reader.ReadString();
                        else if (0 == string.Compare(reader.Name, "Type", StringComparison.Ordinal))
                            type = reader.ReadString();
                        else if (0 == string.Compare(reader.Name, "MatchDerivedTypes", StringComparison.Ordinal))
                            derived = reader.ReadElementContentAsBoolean();
                        else if (0 == string.Compare(reader.Name, "Conditions", StringComparison.Ordinal))
                            CreateConditions(reader, location.Conditions);
                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, "UserTrackingLocation", StringComparison.Ordinal))
                        {
                            if (!seenAct)
                            {
                                location.ActivityType = typeof(Activity);
                                location.MatchDerivedActivityTypes = true;
                            }

                            if (!seenArg)
                            {
                                location.ArgumentType = typeof(object);
                                location.MatchDerivedArgumentTypes = true;
                            }

                            if ((null == location.ActivityType) && ((null == location.ActivityTypeName) || (0 == location.ActivityTypeName.Trim().Length)) && (null == location.ArgumentType) && ((null == location.ArgumentTypeName) || (0 == location.ArgumentTypeName.Trim().Length)))
                                throw new TrackingProfileDeserializationException(ExecutionStringManager.MissingActivityType);

                            return;
                        }
                        else if (0 == string.Compare(reader.Name, "Activity", StringComparison.Ordinal))
                        {
                            if (!seenAct)
                            {
                                location.ActivityType = typeof(Activity);
                                location.MatchDerivedActivityTypes = true;
                            }
                            else
                            {
                                if ((null != type) && (type.Trim().Length > 0))
                                    location.ActivityType = Type.GetType(type, true);
                                else
                                    location.ActivityTypeName = name;

                                location.MatchDerivedActivityTypes = derived;
                            }

                            name = null;
                            type = null;
                            derived = false;
                        }
                        else if (0 == string.Compare(reader.Name, "Argument", StringComparison.Ordinal))
                        {
                            if (!seenArg)
                            {
                                location.ArgumentType = typeof(object);
                                location.MatchDerivedArgumentTypes = true;
                            }
                            else
                            {
                                if ((null != type) && (type.Trim().Length > 0))
                                    location.ArgumentType = Type.GetType(type, true);
                                else
                                    location.ArgumentTypeName = name;

                                location.MatchDerivedArgumentTypes = derived;
                            }

                            name = null;
                            type = null;
                            derived = false;
                        }

                        break;
                }
            }
            //
            // Something bad happened
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "UserTrackingLocation.");
        }
        private void CreateActivityTrackingLocation(XmlReader reader, ActivityTrackingLocation location)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == location)
                throw new ArgumentNullException("location");

            if (0 != string.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + "ActivityTrackingLocation.");

            if (reader.IsEmptyElement)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "TypeName", StringComparison.Ordinal))
                        {
                            if (null != location.ActivityType)
                                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidType);

                            location.ActivityTypeName = reader.ReadString();
                        }
                        else if (0 == string.Compare(reader.Name, "Type", StringComparison.Ordinal))
                        {
                            if (null != location.ActivityTypeName)
                                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidType);

                            if (!reader.IsEmptyElement)
                            {
                                //
                                // Schema validation will catch empty elements, just make sure
                                // we don't pass GetType a null or empty string and continue.
                                string type = reader.ReadString();
                                if ((null != type) && (type.Trim().Length > 0))
                                    location.ActivityType = Type.GetType(type, true);
                            }
                        }
                        else if (0 == string.Compare(reader.Name, "MatchDerivedTypes", StringComparison.Ordinal))
                            location.MatchDerivedTypes = reader.ReadElementContentAsBoolean();
                        else if (0 == string.Compare(reader.Name, "ExecutionStatusEvents", StringComparison.Ordinal))
                            CreateStatusEvents(reader, location.ExecutionStatusEvents);
                        else if (0 == string.Compare(reader.Name, "Conditions", StringComparison.Ordinal))
                            CreateConditions(reader, location.Conditions);
                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, "ActivityTrackingLocation", StringComparison.Ordinal))
                        {
                            //
                            // If we don't have a type or name create the Activity type to track all activities
                            if ((null == location.ActivityType) && (null == location.ActivityTypeName))
                            {
                                location.ActivityType = typeof(Activity);
                                location.MatchDerivedTypes = true;
                            }

                            return;
                        }
                        break;
                }
            }
            //
            // Something bad happened
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + "ActivityTrackingLocation.");
        }
Example #29
0
        void ParseBoneScale(XmlReader xml, Dictionary<int, XmlBoneKeyFrame> frames)
        {
            int depth = xml.Depth;
            while (xml.Read() && xml.Depth > depth)
            {
                if (xml.IsStartElement() && !xml.IsEmptyElement)
                {
                    if (xml.Name == "Value")
                    {
                        int fr = int.Parse(xml.GetAttribute("Frame"));

                        XmlBoneKeyFrame frame;
                        if (!frames.TryGetValue(fr, out frame))
                        {
                            frame.Position = new Vector3();
                            frame.FrameId = fr;
                            frame.Scale = new Vector3(1, 1, 1);
                            frame.Rotation = Quaternion.Identity;
                            frames.Add(fr, frame);
                        }

                        frame.Scale = ParseVector3(xml.ReadString());
                        frames[fr] = frame;
                    }
                }
            }
        }
Example #30
0
        VertexWeight ParseVertexWeight(XmlReader xml)
        {
            VertexWeight w = new VertexWeight();

            List<int> bones = new List<int>();
            List<float> weights = new List<float>();

            int subDepth = xml.Depth;
            while (xml.Read() && xml.Depth > subDepth)
            {
                if (xml.IsStartElement() && !xml.IsEmptyElement)
                {
                    if (xml.Name == "Value")
                    {
                        int id = int.Parse(xml.GetAttribute("BoneID"));
                        float weight = float.Parse(xml.ReadString());

                        bones.Add(id);
                        weights.Add(weight);
                    }
                }
            }

            w.BoneID = bones.ToArray();
            w.Weight = weights.ToArray();
            return w;
        }