Exemple #1
0
 public override bool CommitChanges()
 {
     this.ReplaceReferenceRKs();
     RKContainer.SetRKInField(this.FlushReferenceRKs(),
                              base.contentFieldPath, base.rootField);
     return(true);
 }
Exemple #2
0
 public DefaultConnection(IResourceKey rk,
                          RKContainer rkContainer, ResourceDataActions childActions,
                          string absolutePath)
     : base(rk, absolutePath, childActions)
 {
     this.rkContainer = rkContainer;
 }
Exemple #3
0
        /*public override bool SetParentReferenceRK(IResourceKey newKey)
         * {
         *  string[] fieldNames = this.contentFieldPath.Split(new char[] { '.' },
         *      StringSplitOptions.RemoveEmptyEntries);
         *  if (fieldNames.Length == 1)
         *  {
         *      IResourceKey rk = this.rootField as IResourceKey;
         *      rk.Instance = newKey.Instance;
         *  }
         *  int i, j, index, indexStrStart, indexStrLength;
         *  TypedValue tv;
         *  string name;
         *  AApiVersionedFields field = this.rootField;
         *  for (i = 1; i < fieldNames.Length; i++)
         *  {
         *      name = fieldNames[i];
         *      indexStrStart = name.IndexOf('[');
         *      if (indexStrStart == -1)
         *      {
         *          tv = field[name];
         *          // TODO: Should we account for the possibility of value type resource keys?
         *          if (typeof(IResourceKey).IsAssignableFrom(tv.Type))
         *          {
         *              IResourceKey rk = tv.Value as IResourceKey;
         *              rk.Instance = newKey.Instance;
         *              field[name] = tv;
         *              return true;
         *          }
         *          if (typeof(TextReader).IsAssignableFrom(tv.Type))
         *          {
         *              this.textFieldHelper.SetReferenceRK(base.OriginalChildKey, newKey);
         *              field[name] = new TypedValue(tv.Type, this.textFieldHelper.FlushReferenceRKs());
         *          }
         *          field = tv.Value as AApiVersionedFields;
         *      }
         *      else
         *      {
         *          indexStrLength = name.IndexOf(']');
         *          if (indexStrLength == -1)
         *              indexStrLength = name.Length - 1 - indexStrStart;
         *          else
         *              indexStrLength = indexStrLength - 1 - indexStrStart;
         *          index = int.Parse(name.Substring(indexStrStart, indexStrLength));
         *          tv = field[name.Substring(0, indexStrStart)];
         *          j = -1;
         *          foreach (var e in tv.Value as IEnumerable)
         *          {
         *              if (index == ++j)
         *              {
         *                  if (e is IResourceKey)
         *                  {
         *                      IResourceKey rk = e as IResourceKey;
         *                      rk.Instance = newKey.Instance;
         *                      return true;
         *                  }
         *                  else if (e is IEnumerable)
         *                  {
         *                      IEnumerable list = e as IEnumerable;
         *                      string suffix = name.Substring(indexStrStart + indexStrLength + 1);
         *                      indexStrStart = suffix.IndexOf('[');
         *                      while (indexStrStart != -1)
         *                      {
         *                          indexStrLength = suffix.IndexOf(']');
         *                          if (indexStrLength == -1)
         *                              indexStrLength = suffix.Length - 1 - indexStrStart;
         *                          else
         *                              indexStrLength = indexStrLength - 1 - indexStrStart;
         *                          int subIndex = int.Parse(suffix.Substring(indexStrStart, indexStrLength));
         *                          int k = -1;
         *                          foreach (var f in list)
         *                          {
         *                              if (index == ++k)
         *                              {
         *                                  if (f is IResourceKey)
         *                                  {
         *                                      IResourceKey rk = f as IResourceKey;
         *                                      rk.Instance = newKey.Instance;
         *                                      return true;
         *                                  }
         *                                  else if (f is IEnumerable)
         *                                  {
         *                                      list = f as IEnumerable;
         *                                      suffix = suffix.Substring(indexStrStart + indexStrLength + 1);
         *                                      indexStrStart = suffix.IndexOf('[');
         *                                  }
         *                                  else
         *                                  {
         *                                      field = f as AApiVersionedFields;
         *                                  }
         *                              }
         *                          }
         *                      }
         *                  }
         *                  else
         *                  {
         *                      field = e as AApiVersionedFields;
         *                  }
         *              }
         *          }
         *      }
         *  }
         *  return false;
         * }/**/

        public DefaultConnection(IResourceKey rk,
                                 AApiVersionedFields rkField, ResourceDataActions childActions,
                                 string absolutePath, string rkFieldPath = "root",
                                 Predicate <IResourceKey> validate       = null)
            : base(rk, absolutePath, childActions)
        {
            this.rkContainer = new RKContainer(rkFieldPath, rkField, absolutePath, validate);
        }
 public DefaultConnection(IResourceKey rk,
     RKContainer rkContainer, ResourceDataActions childActions,
     string absolutePath)
     : base(rk, absolutePath, childActions)
 {
     this.rkContainer = rkContainer;
 }
 /*public override bool SetParentReferenceRK(IResourceKey newKey)
 {
     string[] fieldNames = this.contentFieldPath.Split(new char[] { '.' },
         StringSplitOptions.RemoveEmptyEntries);
     if (fieldNames.Length == 1)
     {
         IResourceKey rk = this.rootField as IResourceKey;
         rk.Instance = newKey.Instance;
     }
     int i, j, index, indexStrStart, indexStrLength;
     TypedValue tv;
     string name;
     AApiVersionedFields field = this.rootField;
     for (i = 1; i < fieldNames.Length; i++)
     {
         name = fieldNames[i];
         indexStrStart = name.IndexOf('[');
         if (indexStrStart == -1)
         {
             tv = field[name];
             // TODO: Should we account for the possibility of value type resource keys?
             if (typeof(IResourceKey).IsAssignableFrom(tv.Type))
             {
                 IResourceKey rk = tv.Value as IResourceKey;
                 rk.Instance = newKey.Instance;
                 field[name] = tv;
                 return true;
             }
             if (typeof(TextReader).IsAssignableFrom(tv.Type))
             {
                 this.textFieldHelper.SetReferenceRK(base.OriginalChildKey, newKey);
                 field[name] = new TypedValue(tv.Type, this.textFieldHelper.FlushReferenceRKs());
             }
             field = tv.Value as AApiVersionedFields;
         }
         else
         {
             indexStrLength = name.IndexOf(']');
             if (indexStrLength == -1)
                 indexStrLength = name.Length - 1 - indexStrStart;
             else
                 indexStrLength = indexStrLength - 1 - indexStrStart;
             index = int.Parse(name.Substring(indexStrStart, indexStrLength));
             tv = field[name.Substring(0, indexStrStart)];
             j = -1;
             foreach (var e in tv.Value as IEnumerable)
             {
                 if (index == ++j)
                 {
                     if (e is IResourceKey)
                     {
                         IResourceKey rk = e as IResourceKey;
                         rk.Instance = newKey.Instance;
                         return true;
                     }
                     else if (e is IEnumerable)
                     {
                         IEnumerable list = e as IEnumerable;
                         string suffix = name.Substring(indexStrStart + indexStrLength + 1);
                         indexStrStart = suffix.IndexOf('[');
                         while (indexStrStart != -1)
                         {
                             indexStrLength = suffix.IndexOf(']');
                             if (indexStrLength == -1)
                                 indexStrLength = suffix.Length - 1 - indexStrStart;
                             else
                                 indexStrLength = indexStrLength - 1 - indexStrStart;
                             int subIndex = int.Parse(suffix.Substring(indexStrStart, indexStrLength));
                             int k = -1;
                             foreach (var f in list)
                             {
                                 if (index == ++k)
                                 {
                                     if (f is IResourceKey)
                                     {
                                         IResourceKey rk = f as IResourceKey;
                                         rk.Instance = newKey.Instance;
                                         return true;
                                     }
                                     else if (f is IEnumerable)
                                     {
                                         list = f as IEnumerable;
                                         suffix = suffix.Substring(indexStrStart + indexStrLength + 1);
                                         indexStrStart = suffix.IndexOf('[');
                                     }
                                     else
                                     {
                                         field = f as AApiVersionedFields;
                                     }
                                 }
                             }
                         }
                     }
                     else
                     {
                         field = e as AApiVersionedFields;
                     }
                 }
             }
         }
     }
     return false;
 }/**/
 public DefaultConnection(IResourceKey rk,
     AApiVersionedFields rkField, ResourceDataActions childActions,
     string absolutePath, string rkFieldPath = "root",
     Predicate<IResourceKey> validate = null)
     : base(rk, absolutePath, childActions)
 {
     this.rkContainer = new RKContainer(rkFieldPath, rkField, absolutePath, validate);
 }
Exemple #6
0
        protected List <IResourceConnection> SlurpAllRKs()
        {
            List <IResourceConnection> results = new List <IResourceConnection>();
            string rootStr = this.GetContentPathRootName();

            if (!RKContainer.IsLegalFieldName(rootStr))
            {
                Diagnostics.Log("Illegal Root Field Name for "
                                + ResourceGraph.PrintRK(base.originalKey) + ":" + rootStr);
                rootStr = "root";
            }
            if (base.resource is GenericRCOLResource)
            {
                Diagnostics.Log("Slurping RCOL Resource RKs for "
                                + rootStr + ":" + ResourceGraph.PrintRK(base.originalKey));
                GenericRCOLResource rcol = base.resource as GenericRCOLResource;
                TGIBlock            tgiBlock;
                int i, count = rcol.Resources.Count;
                for (i = 0; i < count; i++)
                {
                    tgiBlock = rcol.Resources[i];
                    if (includeDDSes || !ResourceGraph.IsDDS(tgiBlock.ResourceType))
                    {
                        results.Add(new DefaultConnection(tgiBlock, tgiBlock,
                                                          ResourceDataActions.FindWrite, rootStr + ".Resources[" + i + "]"));
                    }
                }
                Diagnostics.Log("Slurping RCOL ChunkEntry RKs for "
                                + rootStr + ":" + ResourceGraph.PrintRK(base.originalKey));
                string absolutePath;
                GenericRCOLResource.ChunkEntry chunk;
                count = rcol.ChunkEntries.Count;
                for (i = 0; i < count; i++)
                {
                    absolutePath = rootStr + ".ChunkEntries[" + i + "].RCOLBlock";
                    chunk        = rcol.ChunkEntries[i];
                    tgiBlock     = chunk.TGIBlock;
                    switch (GetChunkType(tgiBlock))
                    {
                    case ChunkEntryType.Kindred:
                        this.kindredRCOLChunkKeys.Add(tgiBlock);
                        results.AddRange(RKContainer.SlurpRKsFromField(absolutePath,
                                                                       chunk.RCOLBlock, this.rkContainers, this.ICanSlurpRK));
                        break;

                    case ChunkEntryType.Internal:
                        results.AddRange(RKContainer.SlurpRKsFromField(absolutePath,
                                                                       chunk.RCOLBlock, this.rkContainers, this.ICanSlurpRK));
                        break;

                    case ChunkEntryType.Unique:
                        results.Add(new DefaultConnection(tgiBlock,
                                                          chunk.RCOLBlock, ResourceDataActions.None, absolutePath));
                        break;
                    }
                }
            }
            else if (base.resource is AApiVersionedFields)
            {
                Diagnostics.Log("Slurping RKs for "
                                + rootStr + ":" + ResourceGraph.PrintRK(base.originalKey));
                results.AddRange(RKContainer.SlurpRKsFromField(rootStr,
                                                               base.resource as AApiVersionedFields,
                                                               this.rkContainers, this.ICanSlurpRK));
            }
            return(results);
        }