Beispiel #1
0
        internal static void WriteCustomPropertyFile(MetadataCache mdc,
                                                     string pathRoot,
                                                     string record)
        {
            // Theory has it that the fwdata file is all sorted.
            var cpElement = DataSortingService.SortCustomPropertiesRecord(record);
            // Not this one, since it leaves out the temporary "key' attr. var cpElement = XElement.Parse(SharedConstants.Utf8.GetString(record));
            // Add custom property info to MDC, since it may need to be sorted in the data files.
            var hasCustomProperties = false;

            foreach (var propElement in cpElement.Elements(SharedConstants.CustomField))
            {
                hasCustomProperties = true;
                var className         = propElement.Attribute(SharedConstants.Class).Value;
                var propName          = propElement.Attribute(SharedConstants.Name).Value;
                var typeAttr          = propElement.Attribute("type");
                var adjustedTypeValue = MetadataCache.AdjustedPropertyType(typeAttr.Value);
                if (adjustedTypeValue != typeAttr.Value)
                {
                    typeAttr.Value = adjustedTypeValue;
                }
                var customProp = new FdoPropertyInfo(
                    propName,
                    typeAttr.Value,
                    true);
                mdc.AddCustomPropInfo(
                    className,
                    customProp);
            }
            if (hasCustomProperties)
            {
                mdc.ResetCaches();
            }
            WriteCustomPropertyFile(Path.Combine(pathRoot, SharedConstants.CustomPropertiesFilename), cpElement);
        }
Beispiel #2
0
 private static void TokenizeFile(MetadataCache mdc, string srcFwdataPathname, Dictionary <string, SortedDictionary <string, byte[]> > unownedObjects, Dictionary <string, SortedDictionary <string, byte[]> > classData, Dictionary <string, string> guidToClassMapping)
 {
     using (var fastSplitter = new FastXmlElementSplitter(srcFwdataPathname))
     {
         bool foundOptionalFirstElement;
         // NB: The main input file *does* have to deal with the optional first element.
         foreach (var record in fastSplitter.GetSecondLevelElementBytes(SharedConstants.AdditionalFieldsTag, SharedConstants.RtTag, out foundOptionalFirstElement))
         {
             if (foundOptionalFirstElement)
             {
                 // Cache custom prop file for later write.
                 var cpElement = DataSortingService.SortCustomPropertiesRecord(SharedConstants.Utf8.GetString(record));
                 // Add custom property info to MDC, since it may need to be sorted in the data files.
                 foreach (var propElement in cpElement.Elements(SharedConstants.CustomField))
                 {
                     var className         = propElement.Attribute(SharedConstants.Class).Value;
                     var propName          = propElement.Attribute(SharedConstants.Name).Value;
                     var typeAttr          = propElement.Attribute("type");
                     var adjustedTypeValue = MetadataCache.AdjustedPropertyType(typeAttr.Value);
                     if (adjustedTypeValue != typeAttr.Value)
                     {
                         typeAttr.Value = adjustedTypeValue;
                     }
                     var customProp = new FdoPropertyInfo(
                         propName,
                         typeAttr.Value,
                         true);
                     mdc.AddCustomPropInfo(
                         className,
                         customProp);
                 }
                 mdc.ResetCaches();
                 //optionalFirstElement = Utf8.GetBytes(cpElement.ToString());
                 foundOptionalFirstElement = false;
             }
             else
             {
                 CacheDataRecord(unownedObjects, classData, guidToClassMapping, record);
             }
         }
     }
     GC.Collect(2, GCCollectionMode.Forced);
 }
        internal static void WriteCustomPropertyFile(MetadataCache mdc,
													 string pathRoot,
													 string record)
        {
            // Theory has it that the fwdata file is all sorted.
            var cpElement = DataSortingService.SortCustomPropertiesRecord(record);
            // Not this one, since it leaves out the temporary "key' attr. var cpElement = XElement.Parse(SharedConstants.Utf8.GetString(record));
            // Add custom property info to MDC, since it may need to be sorted in the data files.
            var hasCustomProperties = false;
            foreach (var propElement in cpElement.Elements(SharedConstants.CustomField))
            {
                hasCustomProperties = true;
                var className = propElement.Attribute(SharedConstants.Class).Value;
                var propName = propElement.Attribute(SharedConstants.Name).Value;
                var typeAttr = propElement.Attribute("type");
                var adjustedTypeValue = MetadataCache.AdjustedPropertyType(typeAttr.Value);
                if (adjustedTypeValue != typeAttr.Value)
                    typeAttr.Value = adjustedTypeValue;
                var customProp = new FdoPropertyInfo(
                    propName,
                    typeAttr.Value,
                    true);
                mdc.AddCustomPropInfo(
                    className,
                    customProp);
            }
            if (hasCustomProperties)
                mdc.ResetCaches();
            WriteCustomPropertyFile(Path.Combine(pathRoot, SharedConstants.CustomPropertiesFilename), cpElement);
        }