public SceneCommandInfo Load(XElement node, string basePath)
        {
            var info = new MenuOptionCommandInfo();

            var nameAttr = node.Attribute("name");
            if (nameAttr != null)
            {
                info.Name = nameAttr.Value;
            }

            info.X = node.GetAttribute<int>("x");
            info.Y = node.GetAttribute<int>("y");

            var onNode = node.Element("On");
            if (onNode != null)
            {
                info.OnEvent = _commandReader.LoadCommands(onNode, basePath);
            }

            var offNode = node.Element("Off");
            if (offNode != null)
            {
                info.OffEvent = _commandReader.LoadCommands(offNode, basePath);
            }

            var selectNode = node.Element("Select");
            if (selectNode != null)
            {
                info.SelectEvent = _commandReader.LoadCommands(selectNode, basePath);
            }

            return info;
        }
 public IEffectPartInfo Load(XElement partNode)
 {
     return new PaletteEffectPartInfo() {
         PaletteName = partNode.GetAttribute<string>("name"),
         PaletteIndex = partNode.GetAttribute<int>("index")
     };
 }
 public IEffectPartInfo Load(XElement partNode)
 {
     return new SetVarEffectPartInfo() {
         Name = partNode.GetAttribute<string>("name"),
         Value = partNode.GetAttribute<string>("value")
     };
 }
        public static void LoadFromXml(this Ellipse command, XElement element, LoadContext lc)
        {
            if (element.Attribute("thickness") != null)
                command.Thickness = double.Parse(element.Attribute("thickness").Value);

            var fill = element.Attribute("fill");
            if (fill != null && fill.Value.ToLowerInvariant() != "false")
                command.Fill = true;

            if (element.Attribute("centre") != null)
                command.Centre = new ComponentPoint(element.Attribute("centre").Value);
            else
            {
                string x = element.Attribute("x").Value;
                string y = element.Attribute("y").Value;
                command.Centre = new ComponentPoint(x, y);
            }

            string radius = "r";
            if (lc.FormatVersion <= new Version(1, 1))
                radius = "radius";

            string rx;
            if (element.GetAttribute(radius + "x", lc, out rx))
                command.RadiusX = double.Parse(rx);

            string ry;
            if (element.GetAttribute(radius + "y", lc, out ry))
                command.RadiusY = double.Parse(ry);
        }
Exemple #5
0
 /// <summary>
 /// XML ctor
 /// </summary>
 protected MemberEntry(XElement e)
 {
     name = e.GetAttribute("name");
     type = e.GetAttribute("type");
     dexName = e.GetAttribute("dname");
     dexType = e.GetAttribute("dtype");
 }
        public EntityPlacement Load(XElement node)
        {
            EntityPlacement info = new EntityPlacement();

            info.Id = node.TryAttribute("id", Guid.NewGuid().ToString());

            info.entity = node.TryAttribute("name", node.GetAttribute<string>("entity"));

            info.state = node.TryAttribute("state", "Start");

            info.screenX = node.GetAttribute<int>("x");
            info.screenY = node.GetAttribute<int>("y");

            var dirAttr = node.Attribute("direction");
            if (dirAttr != null)
            {
                Direction dir = Direction.Left;
                Enum.TryParse<Direction>(dirAttr.Value, true, out dir);
                info.direction = dir;
            }

            var respawnAttr = node.Attribute("respawn");
            if (respawnAttr != null)
            {
                RespawnBehavior respawn = RespawnBehavior.Offscreen;
                Enum.TryParse<RespawnBehavior>(respawnAttr.Value, true, out respawn);
                info.respawn = respawn;
            }

            return info;
        }
Exemple #7
0
 internal static VideoFile FromXml(XElement videoFile)
 {
     VideoFile v = new VideoFile();
     v.FormatCode = videoFile.GetAttribute("formatCode");
     v.MsnFileId = videoFile.GetAttribute("msnFileId");
     v.Url = new Uri(videoFile.GetElementValue(XName.Get("uri", Video.NamespaceMsnVideoCatalog)));
     return v;
 }
 public static PendingSet FromXml(XElement element)
 {
     PendingSet pSet = new PendingSet();
     pSet.Computer = element.GetAttribute("computer");
     pSet.Owner = element.GetAttribute("owner");
     pSet.PendingChanges.AddRange(element.Descendants(element.Name.Namespace + "PendingChange").Select(PendingChange.FromXml));
     return pSet;
 }
Exemple #9
0
 /// <summary>
 /// XML ctor
 /// </summary>
 internal ScopeEntry(XElement e)
 {
     name = e.GetAttribute("name");
     filename = e.GetAttribute("filename");
     var ts = e.GetAttribute("timestamp");
     timestamp = DateTime.ParseExact(ts, "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
     hashcode = e.GetAttribute("hashcode");
 }
Exemple #10
0
		public override bool Equals (XElement source, XElement target, ApiChanges changes)
		{
			if (base.Equals (source, target, changes))
				return true;

			var name = source.GetAttribute ("name");
			var srcValue = source.GetAttribute ("value");
			var tgtValue = target.GetAttribute ("value");
			var change = new ApiChange ();
			change.Header = "Modified " + GroupName;

			if (State.BaseType == "System.Enum") {
				change.Append (name).Append (" = ");
				if (srcValue != tgtValue) {
					change.AppendModified (srcValue, tgtValue, true);
				} else {
					change.Append (srcValue);
				}
			} else {
				RenderFieldAttributes (source.GetFieldAttributes (), target.GetFieldAttributes (), change);

				var srcType = source.GetTypeName ("fieldtype");
				var tgtType = target.GetTypeName ("fieldtype");

				if (srcType != tgtType) {
					change.AppendModified (srcType, tgtType, true);
				} else {
					change.Append (srcType);
				}
				change.Append (" ");
				change.Append (name);

				if (srcType == "string" && srcValue != null)
					srcValue = "\"" + srcValue + "\"";

				if (tgtType == "string" && tgtValue != null)
					tgtValue = "\"" + tgtValue + "\"";

				if (srcValue != tgtValue) {
					change.Append (" = ");
					if (srcValue == null)
						srcValue = "null";
					if (tgtValue == null)
						tgtValue = "null";
					change.AppendModified (srcValue, tgtValue, true);
				} else if (srcValue != null) {
					change.Append (" = ");
					change.Append (srcValue);
				}
				change.Append (";");
			}

			changes.Add (source, target, change);

			return false;
		}
Exemple #11
0
 /// <summary>
 /// XML ctor
 /// </summary>
 internal MethodEntry(XElement e)
 {
     name = e.GetAttribute("name");
     signature = e.GetAttribute("signature");
     dexName = e.GetAttribute("dname");
     dexSignature = e.GetAttribute("dsignature");
     mapFileId = int.Parse(e.GetAttribute("id") ?? "0");
     variables = new VariableList(e);
     parameters = new ParameterList(e);
 }
 public SceneCommandInfo Load(XElement node, string basePath)
 {
     var info = new SceneAddCommandInfo();
     var nameAttr = node.Attribute("name");
     if (nameAttr != null) info.Name = nameAttr.Value;
     info.Object = node.RequireAttribute("object").Value;
     info.X = node.GetAttribute<int>("x");
     info.Y = node.GetAttribute<int>("y");
     return info;
 }
 public SceneCommandInfo Load(XElement node, string basePath)
 {
     var info = new SceneFillMoveCommandInfo();
     info.Name = node.RequireAttribute("name").Value;
     info.Duration = node.GetAttribute<int>("duration");
     info.X = node.GetAttribute<int>("x");
     info.Y = node.GetAttribute<int>("y");
     info.Width = node.GetAttribute<int>("width");
     info.Height = node.GetAttribute<int>("height");
     return info;
 }
Exemple #14
0
        public HitBox(XElement xmlNode)
        {
            float width = xmlNode.GetAttribute<float>("width");

            float height = xmlNode.GetAttribute<float>("height");

            float x = xmlNode.GetAttribute<float>("x");

            float y = xmlNode.GetAttribute<float>("y");

            box = new RectangleF(x, y, width, height);
        }
        public static void LoadFromXml(this Line command, XElement element, LoadContext lc)
        {
            if (element.Attribute("thickness") != null)
                command.Thickness = double.Parse(element.Attribute("thickness").Value);

            string start;
            if (element.GetAttribute("start", lc, out start))
                command.Start = new ComponentPoint(start);

            string end;
            if (element.GetAttribute("end", lc, out end))
                command.End = new ComponentPoint(end);
        }
Exemple #16
0
		public OdetteNetworkStream(Stream stream, string name, XElement xConfig)
		{
			this.stream = stream;
			this.name = name;
			this.userData = xConfig.GetAttribute("userData", String.Empty);

			if (xConfig.GetAttribute("allowBufferCompression", false))
				initialCapabilities |= OdetteCapabilities.BufferCompression;
			if (xConfig.GetAttribute("allowRestart", false))
				initialCapabilities |= OdetteCapabilities.Restart;
			if (xConfig.GetAttribute("allowSecureAuthentification", false))
				initialCapabilities |= OdetteCapabilities.SecureAuthentification;
		} // ctor
Exemple #17
0
		public override void Modified (XElement source, XElement target, ApiChanges diff)
		{
			SourceAssembly = source.GetAttribute ("name");
			TargetAssembly = target.GetAttribute ("name");

			var sb = source.GetAttribute ("version");
			var tb = target.GetAttribute ("version");
			if (sb != tb) {
				Output.WriteLine ("<h4>Assembly Version Changed: {0} vs {1}</h4>", tb, sb);
			}

			// ? custom attributes ?
			comparer.Compare (source, target);
		}
Exemple #18
0
		public override bool Find (XElement e)
		{
			if (!base.Find (e))
				return false;
			// the same Item (indexer) property can have different parameters
			return e.GetAttribute ("params") == Source.GetAttribute ("params");
		}
Exemple #19
0
 internal static File FromXml(XElement file)
 {
     File f = new File();
     f.FormatCode = file.GetAttribute("formatCode");
     f.Url = new Uri(file.GetElementValue(XName.Get("uri", Video.NamespaceMsnVideoCatalog)));
     return f;
 }
Exemple #20
0
		public override string GetDescription (XElement e)
		{
			var sb = new StringBuilder ();

			var attribs = e.Attribute ("attrib");
			if (attribs != null) {
				var attr = (MethodAttributes) Int32.Parse (attribs.Value);
				if ((attr & MethodAttributes.Public) != MethodAttributes.Public) {
					sb.Append ("protected ");
				} else {
					sb.Append ("public ");
				}

				if ((attr & MethodAttributes.Static) != 0) {
					sb.Append ("static ");
				} else if ((attr & MethodAttributes.Virtual) != 0) {
					if ((attr & MethodAttributes.VtableLayoutMask) == 0)
						sb.Append ("override ");
					else
						sb.Append ("virtual ");
				}
			}

			string name = e.GetAttribute ("name");

			var r = e.GetTypeName ("returntype");
			if (r != null) {
				// ctor dont' have a return type
				sb.Append (r).Append (' ');
			} else {
				// show the constructor as it would be defined in C#
				name = name.Replace (".ctor", State.Type);
			}

			// the XML file `name` does not contain parameter names, so we must process them ourselves
			// which gives us the opportunity to simplify type names
			sb.Append (name.Substring (0, name.IndexOf ('(')));

			var genericp = e.Element ("generic-parameters");
			if (genericp != null) {
				var list = new List<string> ();
				foreach (var p in genericp.Elements ("generic-parameter")) {
					list.Add (p.GetTypeName ("name"));
				}
				sb.Append ("&lt;").Append (String.Join (", ", list)).Append ("&gt;");
			}

			sb.Append (" (");
			var parameters = e.Element ("parameters");
			if (parameters != null) {
				var list = new List<string> ();
				foreach (var p in parameters.Elements ("parameter")) {
					list.Add (p.GetTypeName ("type") + " " + p.GetAttribute ("name"));
				}
				sb.Append (String.Join (", ", list));
			}
			sb.Append (");");

			return sb.ToString ();
		}
        public SceneCommandInfo Load(XElement node, string basePath)
        {
            var info = new SceneTextCommandInfo();
            info.Content = node.TryAttribute<string>("content");
            info.Name = node.TryAttribute<string>("name");
            info.Speed = node.TryAttribute<int>("speed");
            info.X = node.GetAttribute<int>("x");
            info.Y = node.GetAttribute<int>("y");

            var bindingNode = node.Element("Binding");
            if (bindingNode != null) info.Binding = _bindingReader.Load(bindingNode);

            info.Font = node.TryAttribute<string>("font");

            return info;
        }
Exemple #22
0
		public override void Modified (XElement source, XElement target)
		{
			SourceAssembly = source.GetAttribute ("name");
			TargetAssembly = target.GetAttribute ("name");
			// TODO: version
			// ? custom attributes ?
			comparer.Compare (source, target);
		}
        private static HitBoxInfo GetHitbox(XElement boxnode)
        {
            float width = boxnode.GetAttribute<float>("width");
            float height = boxnode.GetAttribute<float>("height");
            float x = boxnode.GetAttribute<float>("x");
            float y = boxnode.GetAttribute<float>("y");

            var box = new HitBoxInfo() {
                Name = boxnode.TryAttribute<string>("name"),
                Box = new Common.Geometry.RectangleF(x, y, width, height),
                ContactDamage = boxnode.TryAttribute<float>("damage"),
                Environment = boxnode.TryAttribute<bool>("environment", true),
                PushAway = boxnode.TryAttribute<bool>("pushaway", true),
                PropertiesName = boxnode.TryAttribute<string>("properties", "Default")
            };
            return box;
        }
Exemple #24
0
		public override string GetDescription (XElement e)
		{
			StringBuilder sb = new StringBuilder ();
			// TODO: attribs
			sb.Append ("public event ");
			sb.Append (e.GetTypeName ("eventtype")).Append (' ');
			sb.Append (e.GetAttribute ("name")).Append (';');
			return sb.ToString ();
		}
 public SceneCommandInfo Load(XElement node, string basePath)
 {
     var info = new SceneFillCommandInfo();
     var nameAttr = node.Attribute("name");
     if (nameAttr != null) info.Name = nameAttr.Value;
     var colorAttr = node.RequireAttribute("color");
     var color = colorAttr.Value;
     var split = color.Split(',');
     info.Red = byte.Parse(split[0]);
     info.Green = byte.Parse(split[1]);
     info.Blue = byte.Parse(split[2]);
     info.X = node.GetAttribute<int>("x");
     info.Y = node.GetAttribute<int>("y");
     info.Width = node.GetAttribute<int>("width");
     info.Height = node.GetAttribute<int>("height");
     info.Layer = node.TryAttribute<int>("layer");
     return info;
 }
Exemple #26
0
		public override string GetDescription (XElement e)
		{
			var sb = GetObsoleteMessage (e);
			bool obsolete = sb.Length > 0;

			string name = e.GetAttribute ("name");
			string value = e.GetAttribute ("value");

			if (State.BaseType == "System.Enum") {
				sb.Append (name).Append (" = ").Append (value).Append (',');
			} else {
				var attribs = e.Attribute ("attrib");
				if (attribs != null) {
					var attr = (FieldAttributes)Int32.Parse (attribs.Value);
					if ((attr & FieldAttributes.Public) != FieldAttributes.Public) {
						sb.Append ("protected ");
					} else {
						sb.Append ("public ");
					}

					if ((attr & FieldAttributes.Static) != 0)
						sb.Append ("static ");

					if ((attr & FieldAttributes.Literal) != 0)
						sb.Append ("const ");
				}

				string ftype = e.GetTypeName ("fieldtype");
				sb.Append (ftype).Append (' ');
				sb.Append (name);
				if (ftype == "string" && e.Attribute ("value") != null) {
					if (value == null)
						sb.Append (" = null");
					else
						sb.Append (" = \"").Append (value).Append ('"');
				}
				sb.Append (';');
			}

			if (obsolete)
				sb.AppendLine (); // more readable output
			return sb.ToString ();
		}
Exemple #27
0
        public static Thumbnail FromXml(XElement elem)
        {
            Thumbnail tn = new Thumbnail();
            tn.Url = elem.GetAttribute("url");

            tn.Width = elem.GetIntAttribute("width");
            tn.Height = elem.GetIntAttribute("height");
            tn.Time = elem.GetTimeSpanAttribute("time");
            return tn;
        }
        public IEffectPartInfo Load(XElement partNode)
        {
            var info = new SpawnEffectPartInfo();
            info.Name = partNode.GetAttribute<string>("name");
            info.State = partNode.TryAttribute<string>("state", "Start");

            info.Position = (PositionEffectPartInfo)_positionReader.Load(partNode);

            return info;
        }
Exemple #29
0
		// operators have identical names but vary by return types
		public override bool Find (XElement e)
		{
			if (e.GetAttribute ("name") != Source.GetAttribute ("name"))
				return false;

			if (e.GetAttribute ("returntype") != Source.GetAttribute ("returntype"))
				return false;

			var eGP = e.Element ("generic-parameters");
			var sGP = Source.Element ("generic-parameters");

			if (eGP == null && sGP == null)
				return true;
			else if (eGP == null ^ sGP == null)
				return false;
			else {
				var eGPs = eGP.Elements ("generic-parameter");
				var sGPs = sGP.Elements ("generic-parameter");
				return eGPs.Count () == sGPs.Count ();
			}
		}
        private KeyFrameInfo LoadKeyFrame(XElement node, string basePath)
        {
            var info = new KeyFrameInfo();

            info.Frame = node.GetAttribute<int>("frame");

            info.Fade = node.TryAttribute<bool>("fade");

            info.Commands = _commandReader.LoadCommands(node, basePath);

            return info;
        }