public void FindAllOccurrences(SymbolInfo symbol) { List <FindAllOccurrenceResult> results = new List <FindAllOccurrenceResult>(); List <ReferenceInfo> references = _symbolProvider.GetSymbolReferences(symbol); ReferenceInfo definition = _symbolProvider.GetSymbolDefinition(symbol); if (definition != null) { references.Insert(0, definition); } foreach (ReferenceInfo reference in references) { results.Add(new FindAllOccurrenceResult() { MatchedLine = reference.LineContent.Trim(), Location = Path.GetFileName(reference.FileName) + ":" + (reference.LineNumber + 1).ToString(), Destination = new GoToDestination() { CpuAddress = -1, Line = reference.LineNumber, File = reference.FileName, } }); } ctrlFindOccurrences.FindAllOccurrences(symbol.Name, results); this.splitContainer.Panel2Collapsed = false; }
private void AddGetterSetterPreview(List <ReferenceInfo> refInfos, ASResult target, string prefix, string name, bool supportInsideComment, bool supportInsideString) { target = RenamingHelper.FindGetterSetter(target, prefix + name); if (target == null) { return; } var results = new FRRunner().SearchSync(GetConfig(prefix + name))[currentDoc.FileName]; int offset = prefix.Length; foreach (var match in results) { int index = match.Index + offset; int length = match.Length - offset; string value = match.Value.Substring(offset); int style = sci.BaseStyleAt(index); bool insideComment = supportInsideComment && RefactoringHelper.IsCommentStyle(style); bool insideString = supportInsideString && RefactoringHelper.IsStringStyle(style); if (RefactoringHelper.DoesMatchPointToTarget(sci, match, target, null) || insideComment || insideString) { var @ref = new ReferenceInfo() { Index = index, Length = length, Value = value }; refInfos.Add(@ref); if (previewChanges && (!insideComment || includeComments) && (!insideString || includeStrings)) { Highlight(index, value.Length); } } } }
private void CollectReferences_ProcessAnchor(XmlElement element) { if (bodyType == BookBodyType.Main) { // Collect a ref info. ReferenceInfo refInfo = new ReferenceInfo(); refInfo.Href = element.GetAttribute("l:href"); refInfo.Type = element.GetAttribute("type"); // Make sure the href is set. if (string.IsNullOrWhiteSpace(refInfo.Href)) { throw new Exception(string.Format(errRefWithoutHref, sourceFileName)); } // Make sure the href is local. if (refInfo.Href[0] != '#') { throw new Exception(string.Format(errRefNotLocal, sourceFileName)); } // Remove '#' at the href's start. refInfo.Href = refInfo.Href.Remove(0, 1); // Remember the reference. references.Add(refInfo.Href, refInfo); } }
/// <summary> /// 获取引用 /// </summary> /// <param name="node">节点</param> public ReferenceInfo GetReference(XmlNode node) { var reference = new ReferenceInfo(); var xe = (XmlElement)node; reference.ReferenceId = xe.GetAttribute(Const.Id); foreach (XmlNode property in xe.ChildNodes) { property.CommonInfoHandle(reference); switch (property.Name) { case Const.ACardinality: reference.Cardinality = property.InnerText; break; case Const.CParentTable: break; case Const.CChildTable: break; case Const.CParentKey: break; case Const.CJoins: InitJoins(property, reference); break; } } return(reference); }
/// <summary> /// 初始化引用关联信息 /// </summary> /// <param name="joins">引用关联节点集合</param> /// <param name="reference">引用信息</param> private void InitJoins(XmlNode joins, ReferenceInfo reference) { foreach (XmlNode join in joins) { reference.Joins.Add(GetReferenceJoin(join)); } }
public void UpdateSettings_UpdatesRecentLibrariesBasedOnFlag(bool updating) { var settings = AddRemoveReferencesSetup.GetNonDefaultReferenceSettings(); var reconciler = AddRemoveReferencesSetup.ArrangeReferenceReconciler(settings); var input = settings.GetRecentReferencesForHost(null).Select(info => new ReferenceModel(info, ReferenceKind.TypeLibrary) { IsRecent = true }).ToList(); var added = new ReferenceInfo(AddRemoveReferencesSetup.DummyGuidOne, "Reference", @"C:\Windows\System32\reference.dll", 1, 0); var output = input.Union(new [] { new ReferenceModel(added, ReferenceKind.TypeLibrary) { IsReferenced = true } }).ToList(); var model = AddRemoveReferencesSetup.ArrangeAddRemoveReferencesModel(output, null, settings); reconciler.UpdateSettings(model.Object, updating); var actual = settings.GetRecentReferencesForHost(null); var expected = (updating ? output : input).Select(reference => reference.ToReferenceInfo()).ToList(); Assert.AreEqual(expected.Count, actual.Count); Assert.IsTrue(expected.All(info => actual.Contains(info))); }
private void OnDeleteRecipe(object sender, EventArgs e) { if (this.lstRecipes.SelectedItems.Count != 1) { return; } if (MessageBox.Show(this, Configuration.Resources.PackageManager_ConfirmDeleteReference, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { try { ReferenceInfo refinfo = (ReferenceInfo)lstRecipes.SelectedItems[0].Tag; IAssetReferenceService refsvc = (IAssetReferenceService) ServiceHelper.GetService(refinfo.Reference, typeof(IAssetReferenceService)); refsvc.Remove(refinfo.Reference); this.lstRecipes.Items.Remove(lstRecipes.SelectedItems[0]); if (this.lstRecipes.Items.Count != 0) { this.lstRecipes.SelectedIndices.Clear(); this.lstRecipes.SelectedIndices.Add(0); } else { this.txtDescription.Clear(); } } catch (Exception ex) { ErrorHelper.Show((IUIService)GetService(typeof(IUIService)), ex); } } }
private void WriteReference(ReferenceInfo referenceInfo, ref int offset) { if (EngageType == EngageType.Event) { rom[offset] = (byte)((NPCID - referenceInfo.BaseNPCID)); rom[offset] |= (byte)((Action - referenceInfo.BaseAction) << 3); rom[offset] |= (byte)((Event - referenceInfo.BaseEvent) << 5); } else if (EngageType == EngageType.Treasure) { rom[offset] = Mem70A7; } else if (EngageType == EngageType.Battle) { rom[offset] = (byte)(Pack - referenceInfo.BasePack); rom[offset] |= (byte)((Action - referenceInfo.BaseAction) << 4); } offset++; // rom[offset] = X; Bits.SetBit(rom, offset++, 7, ShowNPC); rom[offset] = Y; Bits.SetBit(rom, offset++, 7, ZHalf); rom[offset] = Z; Bits.SetBitsByByte(rom, offset++, (byte)(F << 5), true); }
/// <summary> /// Метод получения патента /// </summary> /// <param name="gosNumber">Гос. Номер</param> /// <param name="patentType">Тип патента</param> /// <param name="responce">Данные для ответа</param> /// <returns></returns> public CustomerPatentValidityResponce Get(string gosNumber, ReferenceInfo patentType, CustomerPatentValidityResponce responce) { //Полуаем типа патента if (!(_dictionaryHelper.GetDictionaryByExternalId(nameof(DicProtectionDocType), patentType.Id) is DicProtectionDocType type)) { throw new NotSupportedException($"Тип с идентефикатором {patentType.Id} не найден"); } //Достаем инфрмация о патенте var patent = _niisWebContext .ProtectionDocs .Where(d => d.GosNumber == gosNumber && d.Request.ProtectionDocTypeId == type.Id) //Тип берется из заявки из за конфликта справочников и несоответсвия Id .Select(d => new { d.Barcode, d.NameRu, d.NameEn, d.NameKz, d.ValidDate, RequestBarcode = d.Request.Barcode, Owners = d.ProtectionDocCustomers.Select(c => new PatentOwner { Xin = c.Customer.Xin ?? string.Empty, AddressEn = c.AddressEn ?? c.Customer.AddressEn ?? string.Empty, AddressKz = c.AddressKz ?? c.Customer.AddressKz ?? string.Empty, AddressRu = c.Address ?? c.Customer.Address ?? string.Empty, AddressPostCode = string.Empty, OwnerNameEn = c.Customer.NameEn ?? string.Empty, OwnerNameKz = c.Customer.NameKz ?? string.Empty, OwnerNameRu = c.Customer.NameRu ?? string.Empty, CustomerType = c.CustomerRole.ExternalId ?? d.Id, Location = new ReferenceInfo { Id = c.Customer.Country != null ? c.Customer.Country.ExternalId ?? c.Customer.Country.Id : int.MinValue, Note = c.Customer.Country != null ? c.Customer.Country.NameRu : string.Empty } }) }) .FirstOrDefault(); if (patent == null) { throw new NotSupportedException($"Патент с номером {gosNumber} и типом {type.NameRu}({patentType.Id}) не найден"); } responce.PatentId = patent.Barcode; responce.DocumentId = patent.RequestBarcode.ToString(); responce.PatentNameRu = patent.NameRu ?? string.Empty; responce.PatentNameEn = patent.NameEn ?? string.Empty; responce.PatentNameKz = patent.NameKz ?? string.Empty; if (patent.ValidDate.HasValue) { responce.ValidityDate = patent.ValidDate.Value.DateTime; } responce.Owners = patent.Owners.ToArray(); return(responce); }
public bool SerializedVersionExists(ReferenceInfo reference) { lock (_lockObject) { return(CachedReferences.TryGetValue(reference, out _) || _baseDeserializer.SerializedVersionExists(reference)); } }
private void ReadReference(ref int offset, ReferenceInfo referenceInfo) { byte temp = rom[offset++]; if (EngageType == EngageType.Event) { NPCID = (ushort)(referenceInfo.BaseNPCID + (temp & 0x07)); // NPC ID+ Action = (ushort)(referenceInfo.BaseAction + ((temp & 0x18) >> 3)); // Action+ Event = (ushort)(referenceInfo.BaseEvent + ((temp & 0xE0) >> 5)); // Event+ } else if (EngageType == EngageType.Treasure) { NPCID = (ushort)referenceInfo.BaseNPCID; Action = (ushort)referenceInfo.BaseAction; Event = (ushort)referenceInfo.BaseEvent; Mem70A7 = temp; // $70A7 } else if (EngageType == EngageType.Battle) { NPCID = (ushort)referenceInfo.BaseNPCID; Action = (ushort)(referenceInfo.BaseAction + (temp & 0x0F)); // Action+ Pack = (byte)(referenceInfo.BasePack + ((temp & 0xF0) >> 4)); // Pack+ } // temp = rom[offset++]; X = (byte)(temp & 0x7F); ShowNPC = (temp & 0x80) == 0x80; temp = rom[offset++]; Y = (byte)(temp & 0x7F); ZHalf = (temp & 0x80) == 0x80; temp = rom[offset++]; Z = (byte)(temp & 0x1F); F = (byte)((temp & 0xF0) >> 5); }
private void lstRecipes_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { try { ListViewHitTestInfo info = lstRecipes.HitTest(e.X, e.Y); if (info != null) { ListViewItem itemSelected = info.Item; if (itemSelected != null) { if (!itemSelected.Selected) { foreach (int oldSelected in this.lstRecipes.SelectedIndices) { this.lstRecipes.Items[oldSelected].Selected = false; } itemSelected.Selected = true; itemSelected.Focused = true; } ReferenceInfo referenceInfo = (ReferenceInfo)itemSelected.Tag; contextMenuRecipe.MenuItems[0].Enabled = referenceInfo.IsEnabled; contextMenuRecipe.Show((Control)sender, e.Location); } } } catch (Exception ex) { ErrorHelper.Show((IUIService)GetService(typeof(IUIService)), ex); } } }
private DependencyContext BuildDependencyContextWithReferenceAssemblies(bool useCompilationOptions) { string mainProjectName = "simple.dependencies"; LockFile lockFile = TestLockFiles.GetLockFile(mainProjectName); SingleProjectInfo mainProject = SingleProjectInfo.Create( "/usr/Path", mainProjectName, ".dll", "1.0.0", new ITaskItem[] { }); ITaskItem[] referencePaths = new ITaskItem[] { new MockTaskItem( "/usr/Path/System.NotConflicting.dll", new Dictionary <string, string> { { "CopyLocal", "false" }, { "FusionName", "System.NotConflicting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" }, { "Version", "" }, }), new MockTaskItem( "/usr/Path/System.Collections.NonGeneric.dll", new Dictionary <string, string> { { "CopyLocal", "false" }, { "FusionName", "System.Collections.NonGeneric, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" }, { "Version", "" }, }), new MockTaskItem( "/usr/Path/System.Collections.NonGeneric.Reference.dll", new Dictionary <string, string> { { "CopyLocal", "false" }, { "FusionName", "System.Collections.NonGeneric.Reference, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" }, { "Version", "" }, }), }; ProjectContext projectContext = lockFile.CreateProjectContext( FrameworkConstants.CommonFrameworks.NetCoreApp10, runtime: null, platformLibraryName: Constants.DefaultPlatformLibrary, isSelfContained: false); CompilationOptions compilationOptions = useCompilationOptions ? CreateCompilationOptions() : null; DependencyContext dependencyContext = new DependencyContextBuilder(mainProject, projectContext, includeRuntimeFileVersions: false) .WithReferenceAssemblies(ReferenceInfo.CreateReferenceInfos(referencePaths)) .WithCompilationOptions(compilationOptions) .Build(); // ensure the DependencyContext can be written out successfully - it has no duplicate dependency names Save(dependencyContext); return(dependencyContext); }
public static ProjectSystemReferenceInfo ToProjectSystemReferenceInfo(this ReferenceInfo reference) { return(new ProjectSystemReferenceInfo( (ProjectSystemReferenceType)reference.ReferenceType, reference.ItemSpecification, reference.TreatAsUsed)); }
public void ItBuildsDependencyContextsFromProjectLockFiles( string mainProjectName, string mainProjectVersion, CompilationOptions compilationOptions, string baselineFileName, string runtime, ITaskItem[] assemblySatelliteAssemblies, ITaskItem[] referencePaths, ITaskItem[] referenceSatellitePaths) { LockFile lockFile = TestLockFiles.GetLockFile(mainProjectName); SingleProjectInfo mainProject = SingleProjectInfo.Create( "/usr/Path", mainProjectName, ".dll", mainProjectVersion, assemblySatelliteAssemblies ?? new ITaskItem[] { }); IEnumerable <ReferenceInfo> directReferences = ReferenceInfo.CreateDirectReferenceInfos( referencePaths ?? new ITaskItem[] { }, referenceSatellitePaths ?? new ITaskItem[] { }); ProjectContext projectContext = lockFile.CreateProjectContext( FrameworkConstants.CommonFrameworks.NetCoreApp10, runtime, Constants.DefaultPlatformLibrary, runtimeFrameworks: null, isSelfContained: !string.IsNullOrEmpty(runtime)); DependencyContext dependencyContext = new DependencyContextBuilder(mainProject, projectContext, includeRuntimeFileVersions: false) .WithDirectReferences(directReferences) .WithCompilationOptions(compilationOptions) .Build(); JObject result = Save(dependencyContext); JObject baseline = ReadJson($"{baselineFileName}.deps.json"); try { baseline .Should() .BeEquivalentTo(result); } catch { // write the result file out on failure for easy comparison using (JsonTextWriter writer = new JsonTextWriter(File.CreateText($"result-{baselineFileName}.deps.json"))) { JsonSerializer serializer = new JsonSerializer(); serializer.Formatting = Formatting.Indented; serializer.Serialize(writer, result); } throw; } }
public static ReferenceInfo GetReferenceInfoByOrderId(int orderId) { ReferenceInfo referenceInfo = new ReferenceInfo(); Repository <ReferenceInfo> referenceInfoRepository = new Repository <ReferenceInfo>("OrderId"); referenceInfo = referenceInfoRepository.SelectByKey(orderId.ToString()); return(referenceInfo); }
public IReadOnlyCollection <Declaration> LoadDeclarationsFromXml(ReferenceInfo reference) { var file = FilePath(reference); var reader = new XmlPersistableDeclarations(); var deserialized = reader.Load(file); return(deserialized.Unwrap()); }
public void GetObjectReference() { ObjectInfo objectInfo = CreateSimpleInfo(); ReferenceInfo referenceInfo = new ReferenceInfo(0); var expected = (SampleClass)_target.CreateObject(objectInfo); var result = _target.GetObjectReference(referenceInfo); Assert.AreSame(expected, result); }
public IReadOnlyCollection <Declaration> CollectedDeclarations(ReferenceInfo reference) { if (!SerializedVersionExists(reference)) { return(new List <Declaration>()); } return(LoadDeclarationsFromXml(reference)); }
private void SetParams(Object targetAsset, AssetReferenceInfo assetReferenceInfo) { this.targetAsset = targetAsset; referenceInfo = assetReferenceInfo != null ? new ReferenceInfo(assetReferenceInfo) : null; displayType = DisplayType.Asset; scrollPosition = Vector2.zero; }
//private static ClassObject _Class_NonConsumableResources; ///// <summary> ///// класс Нерасходуемые ресурсы ///// </summary> //public static ClassObject Class_NonConsumableResources //{ // get // { // if (_Class_NonConsumableResources == null) // _Class_NonConsumableResources = UsedResources.Classes.Find(UR_class_NonConsumableResources_Guid); // return _Class_NonConsumableResources; // } //} #endregion private static ReferenceInfo GetReferenceInfo(ref ReferenceInfo referenceInfo, Guid referenceGuid) { if (referenceInfo == null) { referenceInfo = Connection.ReferenceCatalog.Find(referenceGuid); } return(referenceInfo); }
private bool writePropertyHeaderWithReferenceId(byte elementId, ReferenceInfo info, string name, Type valueType) { if (info.Count < 2) // no need to write id return false; writePropertyHeader(elementId, name, valueType); _writer.WriteNumber(info.Id); return true; }
public override IReadOnlyCollection <Declaration> CollectedDeclarations(ReferenceInfo reference) { if (!_deserializer.SerializedVersionExists(reference)) { return(new List <Declaration>()); } return(LoadDeclarationsFromProvider(reference)); }
private object CreateProxy(TableInfo tableInfo, ReferenceInfo referenceInfo, object foreignKeyValue) { var proxy = proxyGenerator.CreateClassProxy(referenceInfo.ReferenceType, new[] { new LazyLoadingInterceptor(tableInfo, session) }); var referencePrimaryKey = metaDataStore.GetTableInfoFor(referenceInfo.ReferenceType).PrimaryKey; referencePrimaryKey.PropertyInfo.SetValue(proxy, foreignKeyValue, null); return(proxy); }
private CodeAttributeArgument[] GenerateReferenceArguments(ReferenceInfo reference) { var attrList = new List <CodeAttributeArgument>(); attrList.Add(new CodeAttributeArgument(new CodeSnippetExpression(string.Format("typeof({0})", reference.ReferenceTable)))); attrList.Add(new CodeAttributeArgument(new CodeSnippetExpression(string.Format("\"{0}\"", reference.LocalFieldName)))); attrList.Add(new CodeAttributeArgument(new CodeSnippetExpression("ReferenceType=ReferenceType.ManyToOne"))); return(attrList.ToArray()); }
private static Reference GetReference(ref Reference reference, ReferenceInfo referenceInfo) { if (reference == null) { reference = referenceInfo.CreateReference(); } return(reference); }
/// <summary> /// 合同保存 /// </summary> /// yand 16.05.16 /// <param name="FinanceId">融资ID</param> public bool SaveFile(int FinanceId) { bool result = true; List <ApplicantInfo> Applicant = applicantInfoMapper.Find(FinanceId); using (TransactionScope scope = new TransactionScope()) { var mainApplicant = Applicant.Find(m => m.Type == ApplicantInfo.TypeEnum.主要申请人); if (mainApplicant != null) { string hz = contractsCalc.GetContractNum("HZ", FinanceId, mainApplicant.ApplicantId.Value); //融资租赁合同编号代码 ReferenceInfo referenceInfo = reference.Apply(FinanceId, 4, 1); //合同模块为4,1为融资租赁合同 int refid = referenceInfo.ReferenceId; if (result) { result &= InsertFile(hz, refid, "融资租赁合同"); } referenceInfo = reference.Apply(FinanceId, 4, 2);//合同模块为4,2为车辆抵押 refid = referenceInfo.ReferenceId; List <Models.Sys.FileInfo> filelist = fileMapper.FindByReference(refid); string dy = contractsCalc.GetContractNum("DY", FinanceId, mainApplicant.ApplicantId.Value);//融资租赁合同编号代码 if (filelist.Count > 0) { dy += (filelist.Count + 1); } else { dy += 1; } if (result) { result &= InsertFile(dy, refid, "车辆抵押合同"); } } var guarantee = Applicant.FindAll(m => m.Type == ApplicantInfo.TypeEnum.担保人); for (int i = 1; i <= guarantee.Count; i++) { string bz = contractsCalc.GetContractNum("BZ", FinanceId, guarantee[i - 1].ApplicantId.Value); //保证合同编号代码 ReferenceInfo referenceInfo = reference.Apply(FinanceId, 4, 3); //合同模块为4,3保证合同 int refid = referenceInfo.ReferenceId; if (result) { result &= InsertFile(bz, refid, "保证合同" + i); } } if (result) { scope.Complete(); } } return(result); }
/// <summary> /// Set up required variables for live preview features. /// </summary> /// <param name="supportInsideComment">Whether searching inside comments are enabled.</param> /// <param name="supportInsideString">Whether searching inside strings are enabled.</param> /// <param name="supportPreviewChanges">Whether live preview is enabled.</param> /// <param name="target">Current target to rename.</param> private void SetupLivePreview(bool supportInsideComment, bool supportInsideString, bool supportPreviewChanges, ASResult target) { if (!supportPreviewChanges) { return; } var results = new FRRunner().SearchSync(GetConfig(oldName))[currentDoc.FileName]; var tempRefs = new List <ReferenceInfo>(); foreach (var match in results) { int index = match.Index; int length = match.Length; string value = match.Value; int style = sci.BaseStyleAt(index); bool insideComment = supportInsideComment && RefactoringHelper.IsCommentStyle(style); bool insideString = supportInsideString && RefactoringHelper.IsStringStyle(style); if (RefactoringHelper.DoesMatchPointToTarget(sci, match, target, null) || insideComment || insideString) { var @ref = new ReferenceInfo() { Index = index, Length = length, Value = value }; tempRefs.Add(@ref); if (currentRef == null && match.Index == start) { currentRef = @ref; } else if (previewChanges && (!insideComment || includeComments) && (!insideString || includeStrings)) { Highlight(index, length); } } } if (RenamingHelper.HasGetterSetter(target)) { var list = target.Member.Parameters; if (list[0].Name == RenamingHelper.ParamGetter) { AddGetterSetterPreview(tempRefs, target, RenamingHelper.PrefixGetter, oldName, supportInsideComment, supportInsideString); } if (list[1].Name == RenamingHelper.ParamSetter) { AddGetterSetterPreview(tempRefs, target, RenamingHelper.PrefixSetter, oldName, supportInsideComment, supportInsideString); } tempRefs.Sort(); } refs = tempRefs.ToArray(); }
private bool writePropertyHeaderWithReferenceId(byte elementId, ReferenceInfo info, string name, Type valueType) { if (info.Count < 2) { // no need to write id return(false); } this.writePropertyHeader(elementId, name, valueType); this._writer.WriteNumber(info.Id); return(true); }
public void PinReference_RejectsDuplicateLibraries() { var library = new ReferenceInfo(AddRemoveReferencesSetup.DummyGuidOne, "Reference", @"C:\Windows\System32\reference.dll", 1, 0); var settings = new ReferenceSettings(); settings.PinReference(library); settings.PinReference(library); Assert.AreEqual(1, settings.GetPinnedReferencesForHost(null).Count); }
public void CreateNewRefernce() { Mock <IObjectCreator> creatorMock = new Mock <IObjectCreator>(); var target = new ReferenceInfo(5); SampleClass sampleObject = new SampleClass(); creatorMock.Setup(o => o.GetObjectReference(target)).Returns(sampleObject); var result = target.GetInstance(creatorMock.Object); Assert.IsInstanceOfType(result, typeof(SampleClass)); }
public override void Read(BinaryReader reader, Resource resource) { reader.BaseStream.Position = Offset; for (var i = 0; i < Size; i++) { var dep = new ReferenceInfo(); dep.Id = reader.ReadUInt64(); dep.ResourceName = reader.ReadOffsetString(Encoding.UTF8); reader.ReadBytes(4); // TODO: ???? List.Add(dep); } }
public Expression HandleReference(object value, JsonPath CurrentPath) { if (!IsReferenceable(value)) return null; ReferenceInfo refInfo = null; if (_refs.ContainsKey(value)) { /* * This object has already been seen by the serializer so * determine what to do with it. If its part of the current path * then its a circular reference and an error needs to be thrown or it should * be ignored depending on the option. Otherwise write a reference to it */ refInfo = _refs[value]; JsonPath refPath = refInfo.Path; switch (_context.ReferenceWritingType) { case SerializationContext.ReferenceOption.WriteIdentifier: if (!refInfo.CanReference) throw new InvalidOperationException("Can't reference object: " + refPath + " from " + CurrentPath + ", either it is a collection, or it has not been converted yet"); return new ReferenceExpression(refPath); case SerializationContext.ReferenceOption.IgnoreCircularReferences: if (CurrentPath.StartsWith(refPath)) { return new NullExpression(); } break; case SerializationContext.ReferenceOption.ErrorCircularReferences: if (CurrentPath.StartsWith(refPath)) { throw new InvalidOperationException("Circular reference detected. Current path: " + CurrentPath + ", reference to: " + refPath); } break; } } else { refInfo = new ReferenceInfo(CurrentPath); _refs[value] = refInfo; } return null; }
private void ReadObject(BinaryReader reader) { uint num3; uint num = reader.ReadUInt32(); uint key = reader.ReadUInt32(); ObjectInfo item = new ObjectInfo { code = num, size = reader.ReadUInt32() }; if (!this.types.ContainsKey(key)) { throw new Exception(string.Format("Failed to find type info {0} for object {1}!!!", key, num)); } item.typeInfo = this.types[key]; while ((num3 = reader.ReadUInt32()) != 0) { ReferenceInfo info2 = new ReferenceInfo { code = num3 }; uint num4 = reader.ReadUInt32(); if (num4 == 0) { info2.fieldInfo = null; } else if (item.typeInfo.fields.ContainsKey(num4)) { info2.fieldInfo = item.typeInfo.fields[num4]; } else { info2.fieldInfo = null; } item.references.Add(info2); } if (this.objects.ContainsKey(num)) { throw new Exception(string.Format("Object {0} was already loaded?!", num)); } item.type = (num != key) ? ObjectType.Managed : ObjectType.Root; this.objects[num] = item; this.allObjects.Add(item); }