Exemplo n.º 1
0
        IResourceData ReadSerializedObject(uint endPos, UserResourceType type)
        {
            var serializedData = reader.ReadBytes((int)(endPos - reader.Position));
            var res            = createResourceDataDelegate?.Invoke(resourceDataFactory, type, serializedData);

            return(res ?? resourceDataFactory.CreateSerialized(serializedData, type));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a user type. If the type already exists, the existing value is returned.
        /// </summary>
        /// <param name="fullName">Full name of type</param>
        /// <param name="useFullName">Use <paramref name="fullName"/> without converting it to a
        /// type in an existing assembly reference</param>
        /// <returns></returns>
        UserResourceType CreateUserResourceType(string fullName, bool useFullName)
        {
            if (dict.TryGetValue(fullName, out var type))
            {
                return(type);
            }

            var newFullName = useFullName ? fullName : GetRealTypeFullName(fullName);

            type              = new UserResourceType(newFullName, ResourceTypeCode.UserTypes + dict.Count);
            dict[fullName]    = type;
            dict[newFullName] = type;
            return(type);
        }
Exemplo n.º 3
0
		static ResourceElement CreateSerializedImage(Stream stream, string filename) {
			object obj;
			if (filename.EndsWith(".ico", StringComparison.OrdinalIgnoreCase))
				obj = new System.Drawing.Icon(stream);
			else
				obj = new System.Drawing.Bitmap(stream);
			var serializedData = Serialize(obj);

			var userType = new UserResourceType(obj.GetType().AssemblyQualifiedName, ResourceTypeCode.UserTypes);
			var rsrcElem = new ResourceElement {
				Name = Path.GetFileName(filename),
				ResourceData = new BinaryResourceData(userType, serializedData),
			};

			return rsrcElem;
		}
Exemplo n.º 4
0
 public IconResourceData(UserResourceType type, byte[] data)
     : base(type)
 {
     icon = new Icon(new MemoryStream(data));
 }
Exemplo n.º 5
0
 public CharArrayResourceData(UserResourceType type, char[] data)
     : base(type)
 {
     this.data = data;
 }
Exemplo n.º 6
0
 public ImageResourceData(UserResourceType type, byte[] data)
     : base(type)
 {
     bitmap = new Bitmap(Image.FromStream(new MemoryStream(data)));
 }
Exemplo n.º 7
0
		/// <summary>
		/// Creates a user type. If the type already exists, the existing value is returned.
		/// </summary>
		/// <param name="fullName">Full name of type</param>
		/// <param name="useFullName">Use <paramref name="fullName"/> without converting it to a
		/// type in an existing assembly reference</param>
		/// <returns></returns>
		UserResourceType CreateUserResourceType(string fullName, bool useFullName) {
			UserResourceType type;
			if (dict.TryGetValue(fullName, out type))
				return type;

			var newFullName = useFullName ? fullName : GetRealTypeFullName(fullName);
			type = new UserResourceType(newFullName, ResourceTypeCode.UserTypes + dict.Count);
			dict[fullName] = type;
			dict[newFullName] = type;
			return type;
		}
Exemplo n.º 8
0
		/// <summary>
		/// Creates serialized data
		/// </summary>
		/// <param name="value">Serialized data</param>
		/// <param name="type">Type of serialized data</param>
		/// <returns></returns>
		public BinaryResourceData CreateSerialized(byte[] value, UserResourceType type) {
			return new BinaryResourceData(CreateUserResourceType(type.Name, true), value);
		}
Exemplo n.º 9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">User resource type</param>
 public UserResourceData(UserResourceType type)
 {
     this.type = type;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">User resource type</param>
 /// <param name="data">Raw serialized data</param>
 public BinaryResourceData(UserResourceType type, byte[] data)
     : base(type)
 {
     this.data = data;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">User resource type</param>
 public UserResourceData(UserResourceType type) => this.type = type;
Exemplo n.º 12
0
 /// <summary>
 /// Creates serialized data
 /// </summary>
 /// <param name="value">Serialized data</param>
 /// <param name="type">Type of serialized data</param>
 /// <returns></returns>
 public BinaryResourceData CreateSerialized(byte[] value, UserResourceType type)
 {
     return(new BinaryResourceData(CreateUserResourceType(type.Name, true), value));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">User resource type</param>
 /// <param name="data">Raw serialized data</param>
 public BinaryResourceData(UserResourceType type, byte[] data)
     : base(type)
 {
     this.data = data;
 }