Exemplo n.º 1
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     attrRec.Name = @new.name;
 }
Exemplo n.º 2
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     if ((mtdRefer as IAnnotationProvider).Annotations[NameAnalyzer.RenOk] == null)
         return;
     mtdRefer.Name = @new.name;
     Identifier id = (Identifier)(mtdRefer as IAnnotationProvider).Annotations[NameAnalyzer.RenId];
     Identifier n = @new;
     n.scope = mtdRefer.DeclaringType.FullName;
     foreach (IReference refer in (mtdRefer as IAnnotationProvider).Annotations[NameAnalyzer.RenRef] as List<IReference>)
     {
         refer.UpdateReference(id, n);
     }
 }
Exemplo n.º 3
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
 }
Exemplo n.º 4
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     EmbeddedResource res = mod.Resources[resId] as EmbeddedResource;
     foreach (KeyValuePair<string, BamlDocument> pair in (res as IAnnotationProvider).Annotations["Gbamls"] as Dictionary<string, BamlDocument>)
     {
         Stream dst = new MemoryStream();
         BamlWriter.WriteDocument(pair.Value, dst);
         ((res as IAnnotationProvider).Annotations["Gresources"] as Dictionary<string, object>)[pair.Key] = dst;
     }
     MemoryStream newRes = new MemoryStream();
     ResourceWriter wtr = new ResourceWriter(newRes);
     foreach (KeyValuePair<string, object> pair in (res as IAnnotationProvider).Annotations["Gresources"] as Dictionary<string, object>)
         wtr.AddResource(pair.Key, pair.Value);
     wtr.Generate();
     mod.Resources[resId] = new EmbeddedResource(res.Name, res.Attributes, newRes.ToArray());
 }
Exemplo n.º 5
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     MethodSpecification mSpec = refer as MethodSpecification;
     if (mSpec == null)//|| !(mSpec.DeclaringType.GetElementType() is TypeDefinition))
         //{
         //    TypeSpecification tSpec = refer.DeclaringType as TypeSpecification;
         //    TypeDefinition par = tSpec.GetElementType() as TypeDefinition;
         //    if (tSpec != null && par != null)
         //    {
         refer.Name = @new.name;
     //    }
     //}
     else
         (mSpec.ElementMethod).Name = @new.name;
 }
Exemplo n.º 6
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     inst.Operand = @new.scope;
 }
Exemplo n.º 7
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     string oldN = string.IsNullOrEmpty(old.scope) ? old.name : old.scope + "." + old.name;
     string newN = string.IsNullOrEmpty(@new.scope) ? @new.name : @new.scope + "." + @new.name;
     res.Name = res.Name.Replace(oldN, newN);
 }
Exemplo n.º 8
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     if (memRef is MethodReference || memRef is FieldReference)
     {
         memRef.Name = @new.name;
     }
     else if (memRef is TypeReference)
     {
         memRef.Name = @new.name;
         ((TypeReference)memRef).Namespace = @new.scope;
     }
 }
Exemplo n.º 9
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     string op = (string)ldstr.Operand;
     if (op == old.name)
         ldstr.Operand = @new.name;
     else if (op == old.scope)
         ldstr.Operand = @new.scope;
     else if (op == old.scope + "." + old.name)
         ldstr.Operand = string.IsNullOrEmpty(@new.scope) ? @new.name : @new.scope + "." + @new.name;
 }
Exemplo n.º 10
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     if (isField)
         attr.Fields[idx] = new CustomAttributeNamedArgument(@new.name, attr.Fields[idx].Argument);
     else
         attr.Properties[idx] = new CustomAttributeNamedArgument(@new.name, attr.Properties[idx].Argument);
 }
Exemplo n.º 11
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     refer.Namespace = @new.scope;
     refer.Name = @new.name;
 }
Exemplo n.º 12
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     self.Namespace = @new.scope;
     self.Name = @new.name;
     typeRec.TypeFullName = TypeParser.ToParseable(root);
 }
Exemplo n.º 13
0
        public void UpdateReference(Identifier old, Identifier @new)
        {
            string prefix = rec.Value.Substring(0, rec.Value.IndexOf(':'));
            if (old.scope != @new.scope)
            {
                string xmlNamespace = "clr-namespace:" + @new.scope;
                if (@new.scope == null || !string.IsNullOrEmpty(assembly))
                    xmlNamespace += ";assembly=" + assembly;

                for (int i = 0; i < doc.Count; i++)
                {
                    XmlnsPropertyRecord xmlns = doc[i] as XmlnsPropertyRecord;
                    if (xmlns != null)
                    {
                        if (xmlns.XmlNamespace == xmlNamespace)
                        {
                            prefix = xmlns.Prefix;
                            break;
                        }
                        else if (xmlns.Prefix == prefix)
                        {
                            XmlnsPropertyRecord r = new XmlnsPropertyRecord();
                            r.AssemblyIds = xmlns.AssemblyIds;
                            r.Prefix = prefix = ObfuscationHelper.Instance.GetNewName(xmlns.Prefix, NameMode.Letters);
                            r.XmlNamespace = xmlNamespace;
                            doc.Insert(i, r);
                            break;
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(prefix))
                rec.Value = prefix + ":" + @new.name;
            else
                rec.Value = @new.name;
        }
Exemplo n.º 14
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     propRec.Value = @new.name;
 }
Exemplo n.º 15
0
 public void UpdateReference(Identifier old, Identifier @new)
 {
     StringBuilder sb;
     if (rec is TextRecord)
         sb = new StringBuilder((rec as TextRecord).Value);
     else
         sb = new StringBuilder((rec as PropertyWithConverterRecord).Value);
     sb.Remove(startIdx, endIdx - startIdx + 1);
     sb.Insert(startIdx, @new.name);
     if (rec is TextRecord)
         (rec as TextRecord).Value = sb.ToString();
     else
         (rec as PropertyWithConverterRecord).Value = sb.ToString();
     int oEndIdx = endIdx;
     endIdx = startIdx + @new.name.Length - 1;
     foreach (var i in refers)
         if (this != i)
         {
             if (i.startIdx > this.startIdx)
                 i.startIdx = i.startIdx + (endIdx - oEndIdx);
             if (i.endIdx > this.startIdx)
                 i.endIdx = i.endIdx + (endIdx - oEndIdx);
         }
 }
Exemplo n.º 16
0
 public override void DeInitialize()
 {
     foreach (Resource res in mod.Resources)
     {
         if (!res.Name.EndsWith(".resources")) continue;
         string cult = mod.Assembly.Name.Culture;
         Identifier id = new Identifier()
         {
             scope = string.IsNullOrEmpty(cult) ? res.Name.Substring(0, res.Name.LastIndexOf('.')) : res.Name.Substring(0, res.Name.LastIndexOf('.', res.Name.LastIndexOf('.') - 1)),
             name = string.IsNullOrEmpty(cult) ? res.Name.Substring(res.Name.LastIndexOf('.') + 1) : res.Name.Substring(res.Name.LastIndexOf('.', res.Name.LastIndexOf('.') - 1) + 1)
         };
         foreach (IReference refer in (res as IAnnotationProvider).Annotations[NameAnalyzer.RenRef] as List<IReference>)
         {
             refer.UpdateReference(id, id);
         }
     }
 }