private void AddDataRow(string elementName, string name, object value)
 {
     if (value is string)
     {
         this.AddDataRow(elementName, name, (string)value);
     }
     else if (value is byte[])
     {
         this.AddDataRow(elementName, name, (byte[])value);
     }
     else if (value is ResXFileRef)
     {
         ResXFileRef  fileRef = (ResXFileRef)value;
         ResXDataNode node    = new ResXDataNode(name, fileRef, this.typeNameConverter);
         if (fileRef != null)
         {
             fileRef.MakeFilePathRelative(this.BasePath);
         }
         DataNodeInfo dataNodeInfo = node.GetDataNodeInfo();
         this.AddDataRow(elementName, dataNodeInfo.Name, dataNodeInfo.ValueData, dataNodeInfo.TypeName, dataNodeInfo.MimeType, dataNodeInfo.Comment);
     }
     else
     {
         DataNodeInfo info2 = new ResXDataNode(name, value, this.typeNameConverter).GetDataNodeInfo();
         this.AddDataRow(elementName, info2.Name, info2.ValueData, info2.TypeName, info2.MimeType, info2.Comment);
     }
 }
Ejemplo n.º 2
0
        /// <devdoc>
        ///     Adds a resource to the resources. If the resource is a string,
        ///     it will be saved that way, otherwise it will be serialized
        ///     and stored as in binary.
        /// </devdoc>
        private void AddDataRow(string elementName, string name, object value)
        {
            Debug.WriteLineIf(ResValueProviderSwitch.TraceVerbose, "  resx: adding resource " + name);
            switch (value)
            {
            case string str:
                AddDataRow(elementName, name, str);
                break;

            case byte[] bytes:
                AddDataRow(elementName, name, bytes);
                break;

            case ResXFileRef fileRef:
            {
                ResXDataNode node = new ResXDataNode(name, fileRef, this.typeNameConverter);
                DataNodeInfo info = node.GetDataNodeInfo();
                AddDataRow(elementName, info.Name, info.ValueData, info.TypeName, info.MimeType, info.Comment);
                break;
            }

            default:
            {
                ResXDataNode node = new ResXDataNode(name, value, this.typeNameConverter);
                DataNodeInfo info = node.GetDataNodeInfo();
                AddDataRow(elementName, info.Name, info.ValueData, info.TypeName, info.MimeType, info.Comment);
                break;
            }
            }
        }
Ejemplo n.º 3
0
 /// <devdoc>
 ///     Adds a resource to the resources. If the resource is a string,
 ///     it will be saved that way, otherwise it will be serialized
 ///     and stored as in binary.
 /// </devdoc>
 private void AddDataRow(string elementName, string name, object value)
 {
     Debug.WriteLineIf(ResValueProviderSwitch.TraceVerbose, "  resx: adding resource " + name);
     if (value is string)
     {
         AddDataRow(elementName, name, (string)value);
     }
     else if (value is byte[])
     {
         AddDataRow(elementName, name, (byte[])value);
     }
     else if (value is ResXFileRef)
     {
         ResXFileRef  fileRef = (ResXFileRef)value;
         ResXDataNode node    = new ResXDataNode(name, fileRef, this.typeNameConverter);
         if (fileRef != null)
         {
             fileRef.MakeFilePathRelative(BasePath);
         }
         DataNodeInfo info = node.GetDataNodeInfo();
         AddDataRow(elementName, info.Name, info.ValueData, info.TypeName, info.MimeType, info.Comment);
     }
     else
     {
         ResXDataNode node = new ResXDataNode(name, value, this.typeNameConverter);
         DataNodeInfo info = node.GetDataNodeInfo();
         AddDataRow(elementName, info.Name, info.ValueData, info.TypeName, info.MimeType, info.Comment);
     }
 }
Ejemplo n.º 4
0
        /// <include file='doc\ResXResourceWriter.uex' path='docs/doc[@for="ResXResourceWriter.AddResource3"]/*' />
        /// <devdoc>
        ///     Adds a string resource to the resources.
        /// </devdoc>
        public void AddResource(ResXDataNode node)
        {
            // we're modifying the node as we're adding it to the resxwriter
            // this is BAD, so we clone it. adding it to a writer doesnt change it
            // we're messing with a copy
            ResXDataNode nodeClone = node.DeepClone();

            ResXFileRef fileRef          = nodeClone.FileRef;
            string      modifiedBasePath = BasePath;

            if (!string.IsNullOrEmpty(modifiedBasePath))
            {
                if (!(modifiedBasePath.EndsWith("\\")))
                {
                    modifiedBasePath += "\\";
                }
                if (fileRef != null)
                {
                    fileRef.MakeFilePathRelative(modifiedBasePath);
                }
            }
            DataNodeInfo info = nodeClone.GetDataNodeInfo();

            AddDataRow(DataStr, info.Name, info.ValueData, info.TypeName, info.MimeType, info.Comment);
        }
        public void AddResource(ResXDataNode node)
        {
            ResXDataNode node2    = node.DeepClone();
            ResXFileRef  fileRef  = node2.FileRef;
            string       basePath = this.BasePath;

            if (!string.IsNullOrEmpty(basePath))
            {
                if (!basePath.EndsWith(@"\"))
                {
                    basePath = basePath + @"\";
                }
                if (fileRef != null)
                {
                    fileRef.MakeFilePathRelative(basePath);
                }
            }
            DataNodeInfo dataNodeInfo = node2.GetDataNodeInfo();

            this.AddDataRow("data", dataNodeInfo.Name, dataNodeInfo.ValueData, dataNodeInfo.TypeName, dataNodeInfo.MimeType, dataNodeInfo.Comment);
        }
Ejemplo n.º 6
0
 /// <devdoc>
 ///     Adds a resource to the resources. If the resource is a string,
 ///     it will be saved that way, otherwise it will be serialized
 ///     and stored as in binary.
 /// </devdoc>
 private void AddDataRow(string elementName, string name, object value) {
     Debug.WriteLineIf(ResValueProviderSwitch.TraceVerbose, "  resx: adding resource " + name);
     if (value is string) {
         AddDataRow(elementName, name, (string)value);
     }
     else if (value is byte[]) {
         AddDataRow(elementName, name, (byte[])value);
     }
     else if(value is ResXFileRef) {
         ResXFileRef fileRef = (ResXFileRef)value;
         ResXDataNode node = new ResXDataNode(name, fileRef, this.typeNameConverter);
         if (fileRef != null) {
             fileRef.MakeFilePathRelative(BasePath);
         }
         DataNodeInfo info = node.GetDataNodeInfo();
         AddDataRow(elementName, info.Name, info.ValueData, info.TypeName, info.MimeType, info.Comment);
     } else {
         ResXDataNode node = new ResXDataNode(name, value, this.typeNameConverter);
         DataNodeInfo info = node.GetDataNodeInfo();
         AddDataRow(elementName, info.Name, info.ValueData, info.TypeName, info.MimeType, info.Comment);
     }
 }        
 private void AddDataRow(string elementName, string name, object value)
 {
     if (value is string)
     {
         this.AddDataRow(elementName, name, (string) value);
     }
     else if (value is byte[])
     {
         this.AddDataRow(elementName, name, (byte[]) value);
     }
     else if (value is ResXFileRef)
     {
         ResXFileRef fileRef = (ResXFileRef) value;
         ResXDataNode node = new ResXDataNode(name, fileRef, this.typeNameConverter);
         if (fileRef != null)
         {
             fileRef.MakeFilePathRelative(this.BasePath);
         }
         DataNodeInfo dataNodeInfo = node.GetDataNodeInfo();
         this.AddDataRow(elementName, dataNodeInfo.Name, dataNodeInfo.ValueData, dataNodeInfo.TypeName, dataNodeInfo.MimeType, dataNodeInfo.Comment);
     }
     else
     {
         DataNodeInfo info2 = new ResXDataNode(name, value, this.typeNameConverter).GetDataNodeInfo();
         this.AddDataRow(elementName, info2.Name, info2.ValueData, info2.TypeName, info2.MimeType, info2.Comment);
     }
 }