public static Stream OpenFile(PackageRecord record) { long offset = 0; if (record.Flags.HasFlag(ContentFlags.Bundle)) { offset = record.Offset; } if (!CASC.EncodingHandler.GetEntry(record.LoadHash, out EncodingEntry enc)) { return(null); } MemoryStream ms = new MemoryStream((int)record.Size); try { Stream fstream = CASC.OpenFile(enc.Key); fstream.Position = offset; fstream.CopyBytes(ms, (int)record.Size); ms.Position = 0; } catch (Exception e) { if (e is BLTEKeyException exception) { Debugger.Log(0, "DataTool", $"[DataTool:CASC]: Missing key: {exception.MissingKey:X16}\r\n"); } return(null); } return(ms); }
private void LoadPackage(int i, ClientHandler client, ContentManifestFile cmf) { var entry = m_packageEntries[i]; using (Stream packageStream = cmf.OpenFile(client, entry.m_packageGUID) !) using (BinaryReader packageReader = new BinaryReader(packageStream)) { var package = packageReader.Read <PackageHeader>(); m_packages[i] = package; if (package.m_recordCount == 0) { m_packageRecords[i] = new PackageRecord[0]; return; } if (package.m_bundleCount > 0) { packageStream.Position = package.m_offsetBundles; m_packageBundles[i] = packageReader.ReadArray <ulong>((int)package.m_bundleCount); } packageStream.Position = package.m_offsetRecords; using (GZipStream decompressedStream = new GZipStream(packageStream, CompressionMode.Decompress)) using (BinaryReader decompressedReader = new BinaryReader(decompressedStream)) { m_packageRecords[i] = decompressedReader.ReadArray <PackageRecord>((int)package.m_recordCount); } } }
public Package(PackageRecord record) { Record = record ?? throw new ArgumentNullException(nameof(record)); _dependencies = new Dictionary <string, DependencyPackage>(); _plugins = new Dictionary <string, IPlugin>(); }
private Package LoadPackage(DataContext data, PackageRecord packageRecord) { var package = new Package(packageRecord); package.Load(data, Loader); return(package); }
/// <summary> /// Creates for package record. /// </summary> /// <param name="objectSpace">The object space.</param> /// <param name="record">The record.</param> /// <param name="nodeId">The node id.</param> /// <returns></returns> public static ProtocolRecord CreateForPackageRecord(IObjectSpace objectSpace, PackageRecord record, string nodeId) { if (objectSpace == null) { throw new ArgumentNullException("objectSpace"); } if (record == null) { throw new ArgumentNullException("record"); } var session = ((ObjectSpace)objectSpace).Session; var result = objectSpace.CreateObject <ProtocolRecord>(); if (record.AuditedObject != null && record.AuditedObject.IsAssigned) { result.AuditedObject = new AuditedObjectWeakReference(session, OidMap.FindApplicationObject(objectSpace, record.AuditedObject, nodeId)); } result.OperationType = record.OperationType; result.ModifiedOn = record.ModifiedOn; result.Description = record.Description; result.NewBlobValue = record.NewBlobValue; if (record.NewObject != null) { result.NewObject = new XPWeakReference(session, OidMap.FindApplicationObject(objectSpace, record.NewObject, nodeId)); } if (record.OldObject != null) { result.OldObject = new XPWeakReference(session, OidMap.FindApplicationObject(objectSpace, record.OldObject, nodeId)); } result.NewValue = record.NewValue; result.OldValue = record.OldValue; result.PropertyName = record.PropertyName; if (record.AuditedObject != null && record.AuditedObject.IsAssigned) { result.ReplicationKey = record.AuditedObject.ReplicationKey; } return(result); }
public void Dispose() { Websites.Clear(); AddtionalInfo.Clear(); PackageRecord.Dispose(); PackageRecord = null; AdPlanSettings.Dispose(); AdPlanSettings = null; OutputData.Dispose(); OutputData = null; Parent = null; }
public T Map <T>(PackageFile package) where T : PackageRecord { var record = new PackageRecord { Id = package.Id, Name = package.Name, Icon = package.Icon, Website = package.Website, Version = package.Version, Description = package.Description, OctgnVersion = package.OctgnVersion, Path = package.Path }; if (package.Dependencies != null && package.Dependencies.Count > 0) { record.SetDependencies(package.Dependencies); } return((T)record); }
public static Stream OpenFile(PackageRecord record, CASCHandler handler) { long offset = 0; EncodingEntry enc; if (record.Flags.HasFlag(ContentFlags.Bundle)) { offset = record.Offset; } if (!handler.Encoding.GetEntry(record.Hash, out enc)) { return(null); } MemoryStream ms = new MemoryStream((int)record.Size); try { Stream fstream = handler.OpenFile(enc.Key); fstream.Position = offset; CopyBytes(fstream, ms, (int)record.Size); ms.Position = 0; } catch (Exception ex) { Console.Out.WriteLine("Error {0} with file {2} ({1})", ex.Message, TypeAlias(GUID.Type(record.GUID)), GUID.AsString(record.GUID)); return(null); } if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Log(0, "CASC:IO", $"[CASC:IO] Opened file {GUID.AsString(record.GUID)}\n"); } return(ms); }
public static IEnumerable <PluginRecord> GameMenuPlugins(this DataContext context, PackageRecord package) { var query = context.PackagePlugins(package) .Where(plugin => plugin.Type == "octgn.plugin.gamemenu" ); ; foreach (var plugin in query) { yield return(plugin); } foreach (var dependencyRecord in package.Dependencies()) { var dependantPackage = context.Packages.Find( dependencyRecord.Id, dependencyRecord.Version ); foreach (var yunderPlugin in GameMenuPlugins(context, dependantPackage)) { yield return(yunderPlugin); } } }
public DependencyPackage(PackageRecord packageRecord, Package parent) : base(packageRecord) { Parent = parent ?? throw new ArgumentNullException(nameof(parent)); }
public void Deserialize(XmlNode node) { int tempInt; decimal tempDecimal; foreach (XmlAttribute productAttribute in node.Attributes) { switch (productAttribute.Name) { #region Basic Properties case "Name": Name = productAttribute.Value; break; case "UniqueID": Guid tempGuid; if (Guid.TryParse(productAttribute.Value, out tempGuid)) { UniqueID = tempGuid; } break; case "Index": if (int.TryParse(productAttribute.Value, out tempInt)) { Index = tempInt; } break; case "Category": Category = productAttribute.Value; break; case "SubCategory": SubCategory = productAttribute.Value; break; case "RateType": RateType = productAttribute.Value; switch (RateType) { case "0": RateType = "CPM"; break; case "1": RateType = "Fixed"; break; } break; case "Location": Location = productAttribute.Value; break; case "Width": if (int.TryParse(productAttribute.Value, out tempInt)) { Width = tempInt; } else { Width = null; } break; case "Height": if (int.TryParse(productAttribute.Value, out tempInt)) { Height = tempInt; } else { Height = null; } break; case "EnableTarget": { bool temp; if (Boolean.TryParse(productAttribute.Value, out temp)) { EnableTarget = temp; } } break; case "EnableLocation": { bool temp; if (Boolean.TryParse(productAttribute.Value, out temp)) { EnableLocation = temp; } } break; case "EnableRichMedia": { bool temp; if (Boolean.TryParse(productAttribute.Value, out temp)) { EnableRichMedia = temp; } } break; #endregion #region Additional Properties case "UserDefinedName": UserDefinedName = productAttribute.Value; break; case "DurationType": DurationType = productAttribute.Value; break; case "DurationValue": if (int.TryParse(productAttribute.Value, out tempInt)) { DurationValue = tempInt; } else { DurationValue = null; } break; case "Strength1": Strength1 = productAttribute.Value; break; case "Strength2": Strength2 = productAttribute.Value; break; case "MonthlyInvestment": if (Decimal.TryParse(productAttribute.Value, out tempDecimal)) { MonthlyInvestment = tempDecimal; } else { MonthlyInvestment = null; } break; case "MonthlyImpressions": if (Decimal.TryParse(productAttribute.Value, out tempDecimal)) { MonthlyImpressions = tempDecimal; } else { MonthlyImpressions = null; } break; case "MonthlyCPM": if (Decimal.TryParse(productAttribute.Value, out tempDecimal)) { MonthlyCPM = tempDecimal; } else { MonthlyCPM = null; } break; case "TotalInvestment": if (Decimal.TryParse(productAttribute.Value, out tempDecimal)) { TotalInvestment = tempDecimal; } else { TotalInvestment = null; } break; case "TotalImpressions": if (Decimal.TryParse(productAttribute.Value, out tempDecimal)) { TotalImpressions = tempDecimal; } else { TotalImpressions = null; } break; case "TotalCPM": if (Decimal.TryParse(productAttribute.Value, out tempDecimal)) { TotalCPM = tempDecimal; } else { TotalCPM = null; } break; case "DefaultRate": if (Decimal.TryParse(productAttribute.Value, out tempDecimal)) { DefaultRate = tempDecimal; } else { DefaultRate = null; } break; case "Formula": if (int.TryParse(productAttribute.Value, out tempInt)) { Formula = (FormulaType)tempInt; } break; case "InvestmentDetails": InvestmentDetails = productAttribute.Value; break; case "EnableComment": { bool tempBool; if (bool.TryParse(productAttribute.Value, out tempBool)) { EnableComment = tempBool; } } break; case "CommentManualEdit": { bool tempBool; if (bool.TryParse(productAttribute.Value, out tempBool)) { CommentManualEdit = tempBool; } } break; case "ShowCommentTargeting": { bool temp; if (Boolean.TryParse(productAttribute.Value, out temp)) { ShowCommentTargeting = temp; } } break; case "ShowCommentRichMedia": { bool temp; if (Boolean.TryParse(productAttribute.Value, out temp)) { ShowCommentRichMedia = temp; } } break; case "Comment": _userComment = productAttribute.Value; break; case "DescriptionManualEdit": { bool tempBool; if (bool.TryParse(productAttribute.Value, out tempBool)) { DescriptionManualEdit = tempBool; } } break; case "ShowDimensions": { bool temp; if (Boolean.TryParse(productAttribute.Value, out temp)) { ShowDimensions = temp; } } break; case "ShowDescriptionTargeting": { bool temp; if (Boolean.TryParse(productAttribute.Value, out temp)) { ShowDescriptionTargeting = temp; } } break; case "ShowDescriptionRichMedia": { bool temp; if (Boolean.TryParse(productAttribute.Value, out temp)) { ShowDescriptionRichMedia = temp; } } break; case "Description": Description = productAttribute.Value; break; case "UserDescription": _userDescription = productAttribute.Value; break; #endregion #region Show Properties case "ShowFlightDates": { bool tempBool; if (bool.TryParse(productAttribute.Value, out tempBool)) { ShowFlightDates = tempBool; } } break; case "ShowDuration": { bool tempBool; if (bool.TryParse(productAttribute.Value, out tempBool)) { ShowDuration = tempBool; } } break; case "ShowAllPricingMonthly": { bool tempBool; if (bool.TryParse(productAttribute.Value, out tempBool)) { ShowAllPricingMonthly = tempBool; } } break; case "ShowAllPricingTotal": { bool tempBool; if (bool.TryParse(productAttribute.Value, out tempBool)) { ShowAllPricingTotal = tempBool; } } break; case "ShowMonthlyInvestments": { bool tempBool; if (bool.TryParse(productAttribute.Value, out tempBool)) { ShowMonthlyInvestments = tempBool; } } break; case "ShowMonthlyImpressions": { bool tempBool; if (bool.TryParse(productAttribute.Value, out tempBool)) { ShowMonthlyImpressions = tempBool; } } break; case "ShowTotalInvestments": { bool tempBool; if (bool.TryParse(productAttribute.Value, out tempBool)) { ShowTotalInvestments = tempBool; } } break; case "ShowTotalImpressions": { bool tempBool; if (bool.TryParse(productAttribute.Value, out tempBool)) { ShowTotalImpressions = tempBool; } } break; #endregion } } Websites.Clear(); foreach (XmlNode childNode in node.ChildNodes) { switch (childNode.Name) { case "Website": Websites.Add(childNode.InnerText); break; case "PackageRecord": PackageRecord.Deserialize(childNode); break; case "SummaryItem": SummaryItem.Deserialize(childNode); break; case "ProductInfo": var productInfo = new ProductInfo(); productInfo.Deserialize(childNode); AddtionalInfo.Add(productInfo); break; } } }