static AddinDescription ()
		{
			typeMap = new BinaryXmlTypeMap ();
			typeMap.RegisterType (typeof(AddinDescription), "AddinDescription");
			typeMap.RegisterType (typeof(Extension), "Extension");
			typeMap.RegisterType (typeof(ExtensionNodeDescription), "Node");
			typeMap.RegisterType (typeof(ExtensionNodeSet), "NodeSet");
			typeMap.RegisterType (typeof(ExtensionNodeType), "NodeType");
			typeMap.RegisterType (typeof(ExtensionPoint), "ExtensionPoint");
			typeMap.RegisterType (typeof(ModuleDescription), "ModuleDescription");
			typeMap.RegisterType (typeof(ConditionTypeDescription), "ConditionType");
			typeMap.RegisterType (typeof(Condition), "Condition");
			typeMap.RegisterType (typeof(AddinDependency), "AddinDependency");
			typeMap.RegisterType (typeof(AssemblyDependency), "AssemblyDependency");
			typeMap.RegisterType (typeof(NodeTypeAttribute), "NodeTypeAttribute");
		}
Esempio n. 2
0
		public BinaryXmlWriter (Stream stream, BinaryXmlTypeMap typeMap)
		{
			this.typeMap = typeMap;
			writer = new BinaryWriter (stream);
		}
		public void WriteObject (string file, object obj, BinaryXmlTypeMap typeMap)
		{
			using (Stream s = Create (file)) {
				BinaryXmlWriter writer = new BinaryXmlWriter (s, typeMap);
				writer.WriteValue ("data", obj);
			}
		}	
Esempio n. 4
0
 public BinaryXmlReader(Stream stream, BinaryXmlTypeMap typeMap)
 {
     reader       = new BinaryReader(stream);
     this.typeMap = typeMap;
     ReadNext();
 }
		public string WriteSharedObject (string directory, string sharedFileName, string extension, string objectId, string readFileName, BinaryXmlTypeMap typeMap, IBinaryXmlElement obj)
		{
			string file = readFileName;
			
			if (file == null) {
				int count = 1;
				string name = sharedFileName + "_" + Util.GetStringHashCode (objectId).ToString ("x");
				file = Path.Combine (directory, name + extension);
				
				while (Exists (file)) {
					count++;
					file = Path.Combine (directory, name + "_" + count + extension);
				}
			}
			
			using (Stream s = Create (file)) {
				BinaryXmlWriter writer = new BinaryXmlWriter (s, typeMap);
				writer.WriteBeginElement ("File");
				writer.WriteValue ("id", objectId);
				writer.WriteValue ("data", obj);
				writer.WriteEndElement ();
			}
			return file;
		}
		public object ReadObject (string file, BinaryXmlTypeMap typeMap)
		{
			using (Stream s = OpenRead (file)) {
				BinaryXmlReader reader = new BinaryXmlReader (s, typeMap);
				return reader.ReadValue ("data");
			}
		}
		bool OpenFileForPath (string f, string objectId, BinaryXmlTypeMap typeMap, bool checkOnly, out object result)
		{
			result = null;
			
			if (!Exists (f)) {
				return false;
			}
			using (Stream s = OpenRead (f)) {
				BinaryXmlReader reader = new BinaryXmlReader (s, typeMap);
				reader.ReadBeginElement ();
				string id = reader.ReadStringValue ("id");
				if (objectId == null || objectId == id) {
					if (!checkOnly)
						result = reader.ReadValue ("data");
					return true;
				}
			}
			return false;
		}
		public void WriteSharedObject (string objectId, string targetFile, BinaryXmlTypeMap typeMap, IBinaryXmlElement obj)
		{
			WriteSharedObject (null, null, null, objectId, targetFile, typeMap, obj);
		}
		object ReadSharedObject (string directory, string sharedFileName, string extension, string objectId, BinaryXmlTypeMap typeMap, bool checkOnly, out string fileName)
		{
			string name = sharedFileName + "_" + Util.GetStringHashCode (objectId).ToString ("x");
			string file = Path.Combine (directory, name + extension);

			object result;
			if (OpenFileForPath (file, objectId, typeMap, checkOnly, out result)) {
				fileName = file;
				return result;
			}
		
			// The file is not the one we expected. There has been a name colision
			
			foreach (string f in GetDirectoryFiles (directory, name + "*" + extension)) {
				if (f != file && OpenFileForPath (f, objectId, typeMap, checkOnly, out result)) {
					fileName = f;
					return result;
				}
			}
			
			// File not found
			fileName = null;
			return null;
		}
		public object ReadSharedObject (string directory, string sharedFileName, string extension, string objectId, BinaryXmlTypeMap typeMap, out string fileName)
		{
			return ReadSharedObject (directory, sharedFileName, extension, objectId, typeMap, false, out fileName);
		}
		public object ReadSharedObject (string fullFileName, BinaryXmlTypeMap typeMap)
		{
			object result;
			OpenFileForPath (fullFileName, null, typeMap, false, out result);
			return result;
		}
		public BinaryXmlReader (Stream stream, BinaryXmlTypeMap typeMap)
		{
			reader = new BinaryReader (stream);
			this.typeMap = typeMap;
			ReadNext ();
		}
Esempio n. 13
0
 public BinaryXmlWriter(Stream stream, BinaryXmlTypeMap typeMap)
 {
     this.typeMap = typeMap;
     writer       = new BinaryWriter(stream);
 }