Пример #1
0
        internal ResXDataNode(string name, object value, Point_ position)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (name.Length == 0)
            {
                throw new ArgumentException("name");
            }

            Type type = (value == null) ? typeof(object) : value.GetType();

            if ((value != null) && !type.GetTypeInfo().IsSerializable)
            {
                throw new InvalidOperationException(String.Format("'{0}' of type '{1}' cannot be added"
                                                                  + " because it is not serializable",
                                                                  name, type));
            }

            this.name = name;
            this.pos  = position;
            handler   = new InMemoryHandler(value);
        }
Пример #2
0
        internal ResXDataNode(string nameAtt, string mimeTypeAtt, string typeAtt,
                              string dataString, string commentString, Point_ position,
                              string basePath)
        {
            name     = nameAtt;
            comment  = commentString;
            pos      = position;
            MimeType = mimeTypeAtt;
            Type     = typeAtt;

            if (!String.IsNullOrEmpty(mimeTypeAtt))
            {
                if (!String.IsNullOrEmpty(typeAtt))
                {
                    handler = new TypeConverterFromResXHandler(dataString, mimeTypeAtt, typeAtt);
                }
                else
                {
                    handler = new SerializedFromResXHandler(dataString, mimeTypeAtt);
                }
            }
            else if (!String.IsNullOrEmpty(typeAtt))                  //using hard coded types to avoid version mismatches
            {
                if (typeAtt.StartsWith("System.Resources.ResXNullRef, System.Windows.Forms"))
                {
                    handler = new NullRefHandler(typeAtt);
                }
                else if (typeAtt.StartsWith("System.Byte[], mscorlib"))
                {
                    handler = new ByteArrayFromResXHandler(dataString);
                }
                else if (typeAtt.StartsWith("System.Resources.ResXFileRef, System.Windows.Forms"))
                {
                    ResXFileRef newFileRef = BuildFileRef(dataString, basePath);
                    handler      = new FileRefHandler(newFileRef);
                    this.fileRef = newFileRef;
                }
                else
                {
                    handler = new TypeConverterFromResXHandler(dataString, mimeTypeAtt, typeAtt);
                }
            }
            else
            {
                handler = new InMemoryHandler(dataString);
            }

            if (handler == null)
            {
                throw new Exception("handler is null");
            }
        }
Пример #3
0
        public ResXDataNode(string name, ResXFileRef fileRef)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (fileRef == null)
            {
                throw new ArgumentNullException("fileRef");
            }

            if (name.Length == 0)
            {
                throw new ArgumentException("name");
            }

            this.name    = name;
            this.fileRef = fileRef;
            pos          = Point_.Empty;
            handler      = new FileRefHandler(fileRef);
        }
Пример #4
0
		public ResXDataNode (string name, ResXFileRef fileRef)
		{
			if (name == null)
				throw new ArgumentNullException ("name");

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

			if (name.Length == 0)
				throw new ArgumentException ("name");

			this.name = name;
			this.fileRef = fileRef;
			pos = Point.Empty;
			handler = new FileRefHandler (fileRef);
		}
Пример #5
0
		internal ResXDataNode (string nameAtt, string mimeTypeAtt, string typeAtt, 
		                       string dataString, string commentString, Point position, 
		                       string basePath)
		{

			name = nameAtt;
			comment = commentString;
			pos = position;
			MimeType = mimeTypeAtt;
			Type = typeAtt;

			if (!String.IsNullOrEmpty (mimeTypeAtt)) {
				if (!String.IsNullOrEmpty(typeAtt)) {
					handler = new TypeConverterFromResXHandler (dataString, mimeTypeAtt, typeAtt);
				} else {
					handler = new SerializedFromResXHandler (dataString, mimeTypeAtt);
				}
			} else if (!String.IsNullOrEmpty (typeAtt)) { //using hard coded types to avoid version mismatches
				if (typeAtt.StartsWith ("System.Resources.ResXNullRef, System.Windows.Forms")) {
					handler = new NullRefHandler (typeAtt);
				} else if (typeAtt.StartsWith ("System.Byte[], mscorlib")) { 
					handler = new ByteArrayFromResXHandler (dataString);
				} else if (typeAtt.StartsWith ("System.Resources.ResXFileRef, System.Windows.Forms")) {
					ResXFileRef newFileRef = BuildFileRef (dataString, basePath);
					handler = new FileRefHandler (newFileRef);
					this.fileRef = newFileRef;
				} else {
					handler = new TypeConverterFromResXHandler (dataString, mimeTypeAtt, typeAtt);
				}
			} else {
				handler = new InMemoryHandler (dataString);
			}

			if (handler == null)
				throw new Exception ("handler is null");
		}
Пример #6
0
		internal ResXDataNode (string name, object value, Point position)
		{
			if (name == null)
				throw new ArgumentNullException ("name");

			if (name.Length == 0)
				throw new ArgumentException ("name");

			Type type = (value == null) ? typeof (object) : value.GetType ();
			if ((value != null) && !type.IsSerializable) {
				throw new InvalidOperationException (String.Format ("'{0}' of type '{1}' cannot be added" 
				                                                    + " because it is not serializable", 
				                                                    name, type));
			}

			this.name = name;
			this.pos = position;
			handler = new InMemoryHandler (value);
		}