public bool RemoveAssembly(Assembly assembly) { if (assembly == default) { throw new NullReferenceException("Assembly is null! This method can't be passed a null instance."); } lock (ObjLock) { if (AssemblyMappings.ContainsKey(assembly)) { if (OutfileMapping.ContainsKey(assembly.Location)) { while (!OutfileMapping.TryRemove(assembly.Location, out var _)) { } ; } var info = AssemblyMappings[assembly]; ReferencesCache.Remove(info.Reference); DomainCache.Remove(assembly); return(true); } } return(false); }
protected override void Initialize() { base.Initialize(); _httpContextFactory = new FakeHttpContextFactory("~/Home"); var umbracoSettings = Factory.GetInstance <IUmbracoSettingsSection>(); var globalSettings = Factory.GetInstance <IGlobalSettings>(); _xml = new XmlDocument(); _xml.LoadXml(GetXml()); var xmlStore = new XmlStore(() => _xml, null, null, null); var cacheProvider = new StaticCacheProvider(); var domainCache = new DomainCache(ServiceContext.DomainService, DefaultCultureAccessor); var publishedShapshot = new Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedSnapshot( new PublishedContentCache(xmlStore, domainCache, cacheProvider, globalSettings, new SiteDomainHelper(), ContentTypesCache, null, null), new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, cacheProvider, ContentTypesCache), new PublishedMemberCache(null, cacheProvider, Current.Services.MemberService, ContentTypesCache), domainCache); var publishedSnapshotService = new Mock <IPublishedSnapshotService>(); publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny <string>())).Returns(publishedShapshot); _umbracoContext = new UmbracoContext( _httpContextFactory.HttpContext, publishedSnapshotService.Object, new WebSecurity(_httpContextFactory.HttpContext, Current.Services.UserService, globalSettings), umbracoSettings, Enumerable.Empty <IUrlProvider>(), globalSettings, new TestVariationContextAccessor()); _cache = _umbracoContext.ContentCache; }
/// <summary> /// /// This method allows the caller to add a domain value to the set, whether it's a literal value or /// a referenced Attribute in the Transactional record. /// /// <param name="psDomainVal">The value to add to the set</param> /// <param name="pbIsLiteral">The indicator for whether the value is literal (i.e., '5') or an Attribute name (i.e., 'PubPrice')</param> /// <param name="peTargetRecord">The record with the Attribute value that we will add to the set (if the domain value is not literal)</param> /// <returns>None.</returns> /// </summary> public void AddDomainValue(string psDomainVal, bool pbIsLiteral, TARGET_RECORD peTargetRecord) { WonkaBreRuleValueProps oValueProps = new WonkaBreRuleValueProps() { IsLiteralValue = pbIsLiteral }; if (pbIsLiteral) { /* * NOTE: This is a bit of a hack...but since we must use commas to separate the domain values, we will require * that any rule value with an embedded comma must use ",", and that value will be replaced with an * actual comma here. My apologies. */ if (!String.IsNullOrEmpty(psDomainVal) && psDomainVal.Contains(",")) { psDomainVal = psDomainVal.Replace(",", ","); } DomainCache.Add(psDomainVal); } else { oValueProps.TargetRecord = peTargetRecord; oValueProps.AttributeInfo = WonkaRefEnvironment.GetInstance().GetAttributeByAttrName(psDomainVal); HasAttrIdTargets = true; } DomainValueProps[psDomainVal] = oValueProps; }
public void Dispose() { #if !NETSTANDARD2_0 _resolver = null; #endif DomainCache.Clear(this); ReferencesCache.Clear(); OutfileMapping.Clear(); AssemblyMappings.Clear(); }
/// <summary> /// /// This method will use the provided values to set the domain of this rule. More importantly, /// it will assist with the initialization of the rule by interpreting the provided values /// to detect which provided values are literal and which of them are Attribute names (which /// will be used to dynamically update the domain on every processed pair of records). /// /// <param name="asDomainValues">The set of values that are the domain for this particular rule</param> /// <returns>None</returns> /// </summary> public void SetDomain(string[] asDomainValues) { DomainCache.Clear(); DomainValueProps.Clear(); foreach (string sTempDomainVal in asDomainValues) { int nLiteralValueStartIdx = sTempDomainVal.IndexOf("'"); if (nLiteralValueStartIdx >= 0) { int nLiteralValueEndIdx = sTempDomainVal.LastIndexOf("'"); if (nLiteralValueEndIdx > nLiteralValueStartIdx) { string sLiteralValue = sTempDomainVal.Substring(nLiteralValueStartIdx + 1, nLiteralValueEndIdx - nLiteralValueStartIdx - 1); AddDomainValue(sLiteralValue, true, TARGET_RECORD.TRID_NONE); } } else { char[] acAttrNameDelim = new char[1] { '.' }; string sAttrName = sTempDomainVal; TARGET_RECORD eTargetRecord = TARGET_RECORD.TRID_NEW_RECORD; if (sTempDomainVal.Contains(acAttrNameDelim[0])) { string[] asAttrNameParts = sTempDomainVal.Split(acAttrNameDelim); if (asAttrNameParts.Length > 1) { string sTargetRecord = asAttrNameParts[0]; sAttrName = asAttrNameParts[1]; if (sTargetRecord == "O") { eTargetRecord = TARGET_RECORD.TRID_OLD_RECORD; } } } else { sAttrName = sTempDomainVal; } AddDomainValue(sAttrName, false, eTargetRecord); } } }
private static void SetComponentDefaultValue <T>(Entity entity) where T : struct, IComponentData { var session = Application.AuthoringProject.Session; var worldManager = session.GetManager <IWorldManager>(); var entityManager = worldManager.EntityManager; if (entityManager.HasComponent <T>(entity)) { entityManager.SetComponentData(entity, DomainCache.GetDefaultValue <T>()); } }
/// <summary> /// /// This method will apply the domain rule to either the transaction record or the current (i.e., database) record, /// using the other record as a reference. /// /// <param name="poTransactionRecord">The incoming record</param> /// <param name="poCurrentRecord">The current record (i.e., in the database)</param> /// <param name="poErrorMessage">The buffer that will contain an error message if the rule fails</param> /// <returns>Indicates whether or not the target product passed the rule successfully</returns> /// </summary> public override bool Execute(WonkaProduct poTransactionRecord, WonkaProduct poCurrentRecord, StringBuilder poErrorMessage) { bool bResult = false; WonkaProduct TargetRecord = null; WonkaRefEnvironment WonkaRefEnv = WonkaRefEnvironment.GetInstance(); if (RecordOfInterest == TARGET_RECORD.TRID_NEW_RECORD) { TargetRecord = poTransactionRecord; } else if (RecordOfInterest == TARGET_RECORD.TRID_OLD_RECORD) { TargetRecord = poCurrentRecord; } else { throw new Exception("ERROR! The target record is none!"); } string sTargetData = TargetRecord.GetPrimaryAttributeData(TargetAttribute.GroupId, TargetAttribute.AttrId); if (sTargetData == null) { sTargetData = string.Empty; } RefreshCache(poTransactionRecord, poCurrentRecord); if (DomainCache.Contains(sTargetData)) { bResult = true; } else { bResult = false; } if (poErrorMessage != null) { poErrorMessage.Clear(); poErrorMessage.Append(GetVerboseError(TargetRecord)); } return(bResult); }
/// <summary> /// /// This method allows the caller to add a domain value to the set, whether it's a literal value or /// a referenced Attribute in the Transactional record. /// /// <param name="psDomainVal">The value to add to the set</param> /// <param name="pbIsLiteral">The indicator for whether the value is literal (i.e., '5') or an Attribute name (i.e., 'PubPrice')</param> /// <param name="peTargetRecord">The record with the Attribute value that we will add to the set (if the domain value is not literal)</param> /// <returns>None.</returns> /// </summary> public void AddDomainValue(string psDomainVal, bool pbIsLiteral, TARGET_RECORD peTargetRecord) { WonkaBizRuleValueProps oValueProps = new WonkaBizRuleValueProps() { IsLiteralValue = pbIsLiteral }; if (pbIsLiteral) { /* * NOTE: This is a bit of a hack...but since we must use commas and parantheses to separate the domain values, * we will require that any rule value with certain embeddeded delimiters use HTML chars instead, so that * the value will be replaced with the correct equivalent here. My apologies. */ if (!string.IsNullOrEmpty(psDomainVal) && psDomainVal.Contains(",")) { psDomainVal = psDomainVal.Replace(",", ","); } if (!string.IsNullOrEmpty(psDomainVal) && psDomainVal.Contains("(")) { psDomainVal = psDomainVal.Replace("(", "("); } if (!string.IsNullOrEmpty(psDomainVal) && psDomainVal.Contains(")")) { psDomainVal = psDomainVal.Replace(")", ")"); } DomainCache.Add(psDomainVal); } else { oValueProps.TargetRecord = peTargetRecord; oValueProps.AttributeInfo = WonkaRefEnvironment.GetInstance().GetAttributeByAttrName(psDomainVal); HasAttrIdTargets = true; } DomainValueProps[psDomainVal] = oValueProps; }
public async Task <IEnumerable <Tuple <string, string> > > GetRestroomRoutesAsync() { var cacheKey = $"{Classname}.{MethodBase.GetCurrentMethod().Name}"; var routes = DomainCache.GetCache(cacheKey); if (routes == null) { routes = await new SchedulingUnitOfWork().Get <Entities.Scheduling.Route>() .Select(r => new { r.RouteTypeId, r.RouteAlpha }) .Distinct() .OrderBy(r => r.RouteAlpha) .AsEnumerable() .Select(r => new Tuple <string, string>(r.RouteAlpha, r.RouteAlpha)) .ToListAsync(); DomainCache.AddCache(cacheKey, routes); } return((IEnumerable <Tuple <string, string> >)routes); }
private void CreateEntityFromGameObject(GameObject go, EntityReference reference) { // create the entity var entity = m_WorldManager.CreateEntity(go.name, m_ArchetypeManager.FromGameObject(go)); m_WorldManager.SetEntityGuid(entity, reference.Guid); m_WorldManager.EntityManager.SetComponentData(entity, DomainCache.GetDefaultValue <SiblingIndex>()); // add it to the currently active scene var scene = m_SceneManager.GetActiveScene(); scene.AddEntityReference(m_WorldManager.EntityManager, entity); // prime the entity binding configuration (usually primed when running bindings the other way around) var bindingConfig = GenerateBindingConfiguration(entity); EntityToBindingConfiguration[reference.Guid.ToEntityGuid()] = bindingConfig; // create the link between the existing GO and the new entity m_ComponentCache.CreateLink(reference.Guid, reference); }
protected override void Initialize() { base.Initialize(); _httpContextFactory = new FakeHttpContextFactory("~/Home"); var globalSettings = new GlobalSettings(); var umbracoContextAccessor = Factory.GetRequiredService <IUmbracoContextAccessor>(); _xml = new XmlDocument(); _xml.LoadXml(GetXml()); var xmlStore = new XmlStore(() => _xml, null, null, null, HostingEnvironment); var appCache = new DictionaryAppCache(); var domainCache = new DomainCache(Mock.Of <IDomainService>(), DefaultCultureAccessor); var publishedShapshot = new PublishedSnapshot( new PublishedContentCache(xmlStore, domainCache, appCache, globalSettings, ContentTypesCache, null, VariationContextAccessor, null), new PublishedMediaCache(xmlStore, Mock.Of <IMediaService>(), Mock.Of <IUserService>(), appCache, ContentTypesCache, Factory.GetRequiredService <IEntityXmlSerializer>(), umbracoContextAccessor, VariationContextAccessor), new PublishedMemberCache(ContentTypesCache, VariationContextAccessor), domainCache); var publishedSnapshotService = new Mock <IPublishedSnapshotService>(); publishedSnapshotService.Setup(x => x.CreatePublishedSnapshot(It.IsAny <string>())).Returns(publishedShapshot); var httpContext = _httpContextFactory.HttpContext; var httpContextAccessor = TestHelper.GetHttpContextAccessor(httpContext); _umbracoContext = new UmbracoContext( httpContextAccessor, publishedSnapshotService.Object, Mock.Of <IBackOfficeSecurity>(), globalSettings, HostingEnvironment, new TestVariationContextAccessor(), UriUtility, new AspNetCookieManager(httpContextAccessor)); _cache = _umbracoContext.Content; }
/// <summary> /// /// This method allows the caller to add a value to the set for the arithmetic operation, whether it's a literal value or /// a referenced Attribute in the Transactional record. /// /// <param name="psDomainVal">The value to add to the set</param> /// <param name="pbIsLiteral">The indicator for whether the value is literal (i.e., '5') or an Attribute name (i.e., 'PubPrice')</param> /// <param name="peTargetRecord">The record with the Attribute value that we will add to the set (if the domain value is not literal)</param> /// <returns>None.</returns> /// </summary> public void AddDomainValue(string psDomainVal, bool pbIsLiteral, TARGET_RECORD peTargetRecord) { WonkaBizRuleValueProps oValueProps = new WonkaBizRuleValueProps() { IsLiteralValue = pbIsLiteral }; if (pbIsLiteral) { DomainCache.Add(psDomainVal); } else { oValueProps.TargetRecord = peTargetRecord; oValueProps.AttributeInfo = WonkaRefEnvironment.GetInstance().GetAttributeByAttrName(psDomainVal); HasAttrIdTargets = true; } DomainValueProps[psDomainVal] = oValueProps; }
private static bool ExportWorld(FileInfo outputFile, Project project, string scenePath, World world, bool performConversion = true) { if (performConversion) { SceneConversion.Convert(world); } // Null out any references to avoid the SerializeUtility from trying to patch asset entities. world.GetOrCreateSystem <ClearRemappedEntityReferenceSystem>().Update(); // Check for missing assembly references var unresolvedComponentTypes = GetAllUsedComponentTypes(world).Where(t => !DomainCache.IsIncludedInProject(project, t.GetManagedType())).ToArray(); if (unresolvedComponentTypes.Length > 0) { foreach (var unresolvedComponentType in unresolvedComponentTypes) { var type = unresolvedComponentType.GetManagedType(); Debug.LogError($"Could not resolve component type '{type.FullName}' while exporting {scenePath.HyperLink()}. Are you missing an assembly reference to '{type.Assembly.GetName().Name}' ?"); } return(false); } // Remove non-exported components var nonExportedComponentTypes = UnityEditor.TypeCache.GetTypesWithAttribute <NonExportedAttribute>().Select(t => new ComponentType(t)); world.EntityManager.RemoveComponent(world.EntityManager.UniversalQuery, new ComponentTypes(nonExportedComponentTypes.ToArray())); // Merges the entities and shared component streams, (optionally) compresses them, and finally serializes to disk with a small header in front using (var fileStream = new StreamBinaryWriter(outputFile.FullName)) using (var entitiesWriter = new MemoryBinaryWriter()) using (var sharedComponentWriter = new MemoryBinaryWriter()) using (var combinedDataWriter = new MemoryBinaryWriter()) { SerializeUtility.SerializeWorld(world.EntityManager, entitiesWriter, out var sharedComponentsToSerialize); if (sharedComponentsToSerialize.Length > 0) { SerializeUtility.SerializeSharedComponents(world.EntityManager, sharedComponentWriter, sharedComponentsToSerialize); } unsafe { combinedDataWriter.WriteBytes(sharedComponentWriter.Data, sharedComponentWriter.Length); combinedDataWriter.WriteBytes(entitiesWriter.Data, entitiesWriter.Length); var worldHeader = new SceneHeader(); worldHeader.SharedComponentCount = sharedComponentsToSerialize.Length; worldHeader.DecompressedSize = entitiesWriter.Length + sharedComponentWriter.Length; worldHeader.Codec = Codec.LZ4; worldHeader.SerializeHeader(fileStream); if (worldHeader.Codec != Codec.None) { int compressedSize = CodecService.Compress(worldHeader.Codec, combinedDataWriter.Data, combinedDataWriter.Length, out var compressedData); fileStream.WriteBytes(compressedData, compressedSize); } else { fileStream.WriteBytes(combinedDataWriter.Data, combinedDataWriter.Length); } } } return(true); }
public static AssemblyDomain GetDomain(this Type type) { return(DomainCache.GetDomain(type)); }
public static AssemblyDomain GetDomain(this Assembly @delegate) { return(DomainCache.GetDomain(@delegate)); }
/// <summary> /// /// This method will apply the assignment rule to either the transaction record or the current (i.e., database) /// record, using the other record as a reference. /// /// <param name="poTransactionRecord">The incoming record</param> /// <param name="poCurrentRecord">The current record (i.e., in the database)</param> /// <param name="poErrorMessage">The buffer that will contain an error message if the rule fails</param> /// <returns>Indicates whether or not the target product passed the rule successfully</returns> /// </summary> public override bool Execute(WonkaProduct poTransactionRecord, WonkaProduct poCurrentRecord, StringBuilder poErrorMessage) { bool bResult = false; WonkaProduct TargetRecord = null; WonkaRefEnvironment WonkaRefEnv = WonkaRefEnvironment.GetInstance(); int nAttrId = TargetAttribute.AttrId; int nGroupId = TargetAttribute.GroupId; if (RecordOfInterest == TARGET_RECORD.TRID_NEW_RECORD) { TargetRecord = poTransactionRecord; } else if (RecordOfInterest == TARGET_RECORD.TRID_OLD_RECORD) { TargetRecord = poCurrentRecord; } else { throw new Exception("ERROR! The target record is none!"); } string sTargetData = TargetRecord.GetPrimaryAttributeData(TargetAttribute.GroupId, TargetAttribute.AttrId); if (sTargetData == null) { sTargetData = string.Empty; } RefreshCache(poTransactionRecord, poCurrentRecord); WonkaPrdGroup TempProductGroup = null; if (RecordOfInterest == TARGET_RECORD.TRID_NEW_RECORD) { TempProductGroup = poTransactionRecord.GetProductGroup(nGroupId); } else { TempProductGroup = poCurrentRecord.GetProductGroup(nGroupId); } if ((CustomOpDelegate == null) && (CustomOpSource.CustomOpDelegate != null)) { CustomOpDelegate = CustomOpSource.CustomOpDelegate; } if (CustomOpDelegate != null) { string[] CustomOpArgs = new string[4]; for (int idx = 0; idx < 4; ++idx) { if (idx < DomainCache.Count()) { CustomOpArgs[idx] = DomainCache.ElementAt(idx); } else { CustomOpArgs[idx] = string.Empty; } } string sCustomOpResult = CustomOpDelegate(CustomOpArgs[0], CustomOpArgs[1], CustomOpArgs[2], CustomOpArgs[3]); // NOTE: If the result is empty, we consider the rule's invocation as a failure if (!String.IsNullOrEmpty(sCustomOpResult)) { TempProductGroup[0][nAttrId] = sCustomOpResult; bResult = true; } if (poErrorMessage != null) { poErrorMessage.Clear(); poErrorMessage.Append(GetVerboseError(TargetRecord)); } } return(bResult); }
public static void RemoveReferences(this Assembly assembly) { DomainCache.RemoveReferences(assembly); }
public static void DisposeDomain(this Assembly assembly) { DomainCache.DisposeDomain(assembly); }
public bool Run(BuildPipeline.BuildContext context) { using (var tmpWorld = new World(ConfigurationScene.Guid.ToString("N"))) { var configEntity = CopyEntity(context.WorldManager.GetConfigEntity(), context.World, tmpWorld); // Insert asset scene before all other startup scenes, if there's any asset if (AssetEnumerator.GetAllReferencedAssets(context.Project).Count > 0) { Assert.IsTrue(tmpWorld.EntityManager.HasComponent <StartupScenes>(configEntity)); var startupScenes = tmpWorld.EntityManager.GetBuffer <StartupScenes>(configEntity).Reinterpret <Guid>(); if (startupScenes.Length == 0) { Debug.LogWarning($"Project {context.Project.Name} contains no startup scenes."); } startupScenes.Insert(0, AssetsScene.Guid); } // Make sure components not owned by the users are removed if their assemblies are missing var configArchetype = context.Session.GetManager <IArchetypeManager>().Config; var componentsToRemove = GetAllComponentTypes(configArchetype).Where(t => !DomainCache.IsIncludedInProject(context.Project, t.GetManagedType())); tmpWorld.EntityManager.RemoveComponent(tmpWorld.EntityManager.UniversalQuery, new ComponentTypes(componentsToRemove.ToArray())); // Export configuration scene var outputFile = context.DataDirectory.GetFile(tmpWorld.Name); if (!ExportWorld(outputFile, context.Project, ConfigurationScene.Path, tmpWorld)) { return(false); } // Update manifest context.Manifest.Add(ConfigurationScene.Guid, ConfigurationScene.Path, outputFile.AsEnumerable()); // Dump debug file var debugFile = context.DataDirectory.GetFile(".debug.txt"); var debugLines = context.Manifest.Assets.OrderBy(x => x.Value).Select(x => $"{x.Key.ToString("N")} = {x.Value.DoubleQuoted()}"); debugFile.WriteAllLines(debugLines.ToArray()); } return(true); }
public static void DisposeDomain(this Type type) { DomainCache.DisposeDomain(type); }
/// <summary> /// 获取编译后的程序集 /// </summary> /// <returns></returns> public Assembly GetAssembly() { if (SyntaxInfos.Trees.Count == 0) { return(null); } if (AssemblyName == default) { AssemblyName = Guid.NewGuid().ToString("N"); } var result = StreamComplier(); Assembly assembly = result.Assembly; if (result.Compilation != null) { if (assembly == default || assembly == null) { bool CS0104SHUT = false; bool CS0234SHUT = false; bool CSO246SHUT = false; var tempCache = SyntaxInfos.TreeCodeMapping; SyntaxOption option = new SyntaxOption(); foreach (var item in result.Errors) { if (item.Id == "CS0104") { CS0104SHUT = true; var tempTree = item.Location.SourceTree; var tempCode = tempCache[tempTree]; var(str1, str2) = CS0104Helper.Handler(item.Descriptor.MessageFormat.ToString(), item.GetMessage()); var sets = SyntaxInfos.TreeUsingMapping[tempTree]; if (sets.Contains(str2)) { tempCache[tempTree] = tempCode.Replace($"using {str1};", ""); } else if (sets.Contains(str1)) { tempCache[tempTree] = tempCode.Replace($"using {str2};", ""); } else { tempCache[tempTree] = tempCode.Replace($"using {str1};", ""); } } else if (item.Id == "CS0234") { CS0234SHUT = true; var tempResult = CS0234Helper.Handler(item.Descriptor.MessageFormat.ToString(), item.GetMessage()); UsingDefaultCache.Remove(tempResult); var tempTree = item.Location.SourceTree; var tempCode = tempCache[tempTree]; tempCache[tempTree] = tempCode.Replace($"using {tempResult};", ""); } else if (item.Id == "CS0246") { CSO246SHUT = true; var tempTree = item.Location.SourceTree; var tempCode = tempCache[tempTree]; var formart = item.Descriptor.MessageFormat.ToString(); CS0246Helper.Handler(item.Descriptor.MessageFormat.ToString(), item.GetMessage()); foreach (var @using in CS0246Helper.GetUsings(formart, tempCode)) { UsingDefaultCache.Remove(@using); tempCache[tempTree] = tempCode.Replace($"using {@using};", ""); } } } if (CS0104SHUT || CS0234SHUT || CSO246SHUT) { ErrorRetryCount += 1; if (ErrorRetryCount < 2) { foreach (var item in tempCache) { option.Add(tempCache[item.Key], SyntaxInfos.TreeUsingMapping[item.Key]); } SyntaxInfos = option; return(GetAssembly()); } } ComplieException.Diagnostics.AddRange(result.Errors); ComplieException.ErrorFlag = ComplieError.Complie; ComplieException.Message = "发生错误,无法生成程序集!"; NError logError = new NError(); logError.Handler(result.Compilation, ComplieException.Diagnostics); ComplieException.Log = logError.Buffer.ToString(); if (NError.Enabled) { logError.Write(); } } else { if (_domain != DomainManagment.Default) { DomainCache.Add(result.Assembly, _domain); } NSucceed logSucceed = new NSucceed(); logSucceed.Handler(result.Compilation); ComplieException.ErrorFlag = ComplieError.None; ComplieException.Log = logSucceed.Buffer.ToString(); if (NSucceed.Enabled) { logSucceed.Write(); } } } return(assembly); }
public static void RemoveReferences(this Delegate @delegate) { DomainCache.RemoveReferences(@delegate); }
public static void DisposeDomain(this Delegate @delegate) { DomainCache.DisposeDomain(@delegate); }
public static bool WriteWorldToFile(World world, FileInfo outputFile) { // TODO need to bring this back #if false // Check for missing assembly references var unresolvedComponentTypes = GetAllUsedComponentTypes(world).Where(t => !DomainCache.IsIncludedInProject(project, t.GetManagedType())).ToArray(); if (unresolvedComponentTypes.Length > 0) { foreach (var unresolvedComponentType in unresolvedComponentTypes) { var type = unresolvedComponentType.GetManagedType(); Debug.LogError($"Could not resolve component type '{type.FullName}' while exporting {scenePath.ToHyperLink()}. Are you missing an assembly reference to '{type.Assembly.GetName().Name}' ?"); } return(false); } #endif var directoryName = Path.GetDirectoryName(outputFile.FullName); if (string.IsNullOrEmpty(directoryName)) { throw new ArgumentException($"Invalid output file directory: {directoryName}", nameof(outputFile)); } if (!Directory.Exists(directoryName)) { Directory.CreateDirectory(directoryName); } // Merges the entities and shared component streams, (optionally) compresses them, and finally serializes to disk with a small header in front using (var fileStream = new StreamBinaryWriter(outputFile.FullName)) using (var entitiesWriter = new MemoryBinaryWriter()) { var entityRemapInfos = new NativeArray <EntityRemapUtility.EntityRemapInfo>(world.EntityManager.EntityCapacity, Allocator.Temp); SerializeUtility.SerializeWorldInternal(world.EntityManager, entitiesWriter, out var referencedObjects, entityRemapInfos, isDOTSRuntime: true); entityRemapInfos.Dispose(); if (referencedObjects != null) { throw new ArgumentException("We are serializing a world that contains UnityEngine.Object references which are not supported in Dots Runtime."); } #if TINY_SCENE_DEP unsafe { var worldHeader = new SceneHeader(); worldHeader.DecompressedSize = entitiesWriter.Length; worldHeader.Codec = Codec.LZ4; worldHeader.SerializeHeader(fileStream); if (worldHeader.Codec != Codec.None) { int compressedSize = CodecService.Compress(worldHeader.Codec, entitiesWriter.Data, entitiesWriter.Length, out var compressedData); fileStream.WriteBytes(compressedData, compressedSize); } else { fileStream.WriteBytes(entitiesWriter.Data, entitiesWriter.Length); } } #endif } return(true); }
public static void RemoveReferences(this Type type) { DomainCache.RemoveReferences(type); }