public override object readObject(ImportContext ctx, TypeData[] typeArgs = null) { object value = (_type == null) ? null : Activator.CreateInstance(_type); int fieldCount = ctx.readLength(); this.logInfo("Reading " + fieldCount + " fields..."); for (int ii = 0; ii < fieldCount; ii++) { int fieldId = ctx.readId(); FieldData field; if (fieldId < _fields.Count) { field = _fields[fieldId]; } else { // ASSERT the fieldId // TODO if (fieldId != _fields.Count) { this.logWarning("Unexpected field id!", "expected", _fields.Count, "got", fieldId); throw new Exception("Unexpected field id!"); } // new field string name = ctx.readString(); TypeData type = ctx.readType(); FieldInfo fieldInfo; if (_fieldInfo != null) { _fieldInfo.TryGetValue(name, out fieldInfo); if (_fieldInfo == null) { ctx.warn("Importing class no longer has field: " + name); } } else { fieldInfo = null; } // fieldInfo can now be null field = new FieldData(type, fieldInfo); _fields.Add(field); } field.readField(ctx, value); } return value; }
public reflectedData ___getReflectedFields_internal(object objectToReflect) { Type objType = objectToReflect.GetType(); reflectedData objReflectedData = new reflectedData(); objReflectedData.groupTypeOfReflectedData = "Fields"; objReflectedData.typeOfReflectedData = "Field"; objReflectedData.arrayReflectedData = new ArrayList(); FieldInfo[] objFieldsInfo = objType.GetFields(___getCurrentSelectedBindingFlags()); foreach (FieldInfo objFieldrInfo in objFieldsInfo) { object reflectedObject = objFieldrInfo.GetValue(objectToReflect); if (reflectedObject != null) { FieldData objFieldData = new FieldData(); objFieldData.fieldName = objFieldrInfo.Name.ToString(); objFieldData.fieldValue = reflectedObject.ToString(); objReflectedData.arrayReflectedData.Add(@"<name><td class=""td_verySmall_font""><b>"+ objFieldData.fieldName +@"</b></td></name><value><td class=""td_verySmall_font""><i>" + objFieldData.fieldValue+"</i></td></value>"); } } return objReflectedData; }
// 필드 데이터 설정 public void SetFieldData(FieldData fieldData) => this.fieldData = fieldData;
public float DrawWindow(float offset, List <SerializedProperty> properties, string title) { var spacing = 24; var padding = 1 * spacing; var elementHeight = 24; var startPoint = offset * spacing + padding; var endPoint = properties.Count + padding / spacing; GUILayout.Space((elementHeight * endPoint) + endPoint); GUILayout.BeginArea(new Rect(0, startPoint - padding, Screen.width, elementHeight), titleStyle); GUILayout.Label(title, titleTextStyle, GUILayout.Width(Screen.width)); GUILayout.EndArea(); serializedObject.Update(); for (int i = 0; i < properties.Count; i++) { var property = properties[i]; if (property == null) { continue; } var tooltip = FieldData.GetValue(property.name, typeof(GameConfigSO), FieldData.ValueType.Tooltip); GUILayout.BeginArea(new Rect(0, startPoint + i * spacing, Screen.width, elementHeight), new GUIContent("", tooltip), EditorStyles.helpBox); GUILayout.BeginHorizontal(); var name = FieldData.GetValue(property.name, typeof(GameConfigSO), FieldData.ValueType.Description); if (name == null) { name = property.displayName; } //if (property.type == "bool") if (property.propertyType == SerializedPropertyType.Boolean) { DrawLabel(name, property.type); EditorGUILayout.PropertyField(property, GUIContent.none, true, GUILayout.Width(74)); } //else if (property.type == "int") else if (property.propertyType == SerializedPropertyType.Integer) { //EditorGUILayout.LabelField(name); DrawLabel(name, property.type); EditorGUILayout.PropertyField(property, GUIContent.none, true, GUILayout.Width(74)); } //else if (property.type == "string") else if (property.propertyType == SerializedPropertyType.String) { //EditorGUILayout.LabelField(name, GUILayout.Width(230)); DrawLabel(name, property.type); //EditorGUILayout.PropertyField(property, GUIContent.none, true, GUILayout.Width(Screen.width - 250)); EditorGUILayout.PropertyField(property, GUIContent.none, true, GUILayout.Width(334)); } else if (property.propertyType == SerializedPropertyType.ObjectReference) { DrawLabel(name, property.type); EditorGUILayout.PropertyField(property, GUIContent.none, true, GUILayout.Width(184)); } GUILayout.EndHorizontal(); GUILayout.EndArea(); } serializedObject.ApplyModifiedProperties(); return(endPoint); }
public async Task <ActionResult <Phase> > PutField([FromBody] Phase model) { var item = await _context.Phase.FirstOrDefaultAsync(x => x.Id.Equals(model.Id)); if (item == null) { return(NotFound()); } foreach (var a in model.FieldData) { // tim cai field id nay da ton tai chua var fieldItem = await _context.FieldData.FindAsync(a.Id); // kiem tra da ton tai thi update if (fieldItem != null) { // update fieldItem.FieldName = a.FieldName; fieldItem.Description = a.Description; fieldItem.Type = a.Type; fieldItem.Required = a.Required; foreach (var b in a.Option) { var optionItem = await _context.Option.FindAsync(b.Id); if (optionItem != null) { optionItem.Value = b.Value; } else { var newOption = new Models.Option { Id = b.Id, Value = b.Value, FieldDataId = b.FieldDataId }; _context.Option.AddRange(newOption); } } } else { // create new var newField = new FieldData { Id = a.Id, FieldName = a.FieldName, Description = a.Description, Type = a.Type, Required = a.Required, PhaseId = a.PhaseId, }; foreach (var c in a.Option) { var newOption = new Models.Option { Id = c.Id, Value = c.Value, FieldDataId = c.FieldDataId }; _context.Option.AddRange(newOption); } _context.FieldData.AddRange(newField); } } await _context.SaveChangesAsync(); return(item); }
public override void AddFields(FieldData fields) { base.AddFields(fields); name = fields.add(name, "name"); disableWhenDone = fields.add(disableWhenDone, "disableWhenDone"); }
public void ReadFromExcel(string sheetName, IExcelDataReader dataTable) { this.sheetName = sheetName; filedList = new List <FieldData>(); for (int i = 0; i < dataTable.FieldCount; i++) { filedList.Add(new FieldData()); } for (int rowIndex = 0; rowIndex < dataTable.RowCount; rowIndex++) { dataTable.Read(); for (int columnIndex = 0; columnIndex < dataTable.FieldCount; columnIndex++) { FieldData fieldData = filedList[columnIndex]; //根据有效数据的第一行决定本行的实际类型 也就是第一行数据一定不能为空 if (rowIndex == DATA_START_ROW_INDEX) { var type = dataTable.GetFieldType(columnIndex); if (type != null) { fieldData.fieldType = type; } } var data = dataTable.GetValue(columnIndex); if (data != null) { fieldData.dataList.Add(data.ToString()); } else { fieldData.dataList.Add(""); } } } var exportSchema = GetCellString(0, 1); isNeedExprot = true; if (exportSchema != "base" && exportSchema != "tiny") { isNeedExprot = false; return; } InitExportBaseInfo(); DeleteNoneDateCell(); //删掉非数据行的字段 CheckSetDefalutValue(); //给与为空的字段默认值 MergeArrayField(); DoItemFields(); DoIntArrayFields(); }
public override IPacketWriter BuildUpdate() { MaskSize = ((int)Fields.MAX + 31) / 32; FieldData.Clear(); MaskArray = new byte[MaskSize * 4]; PacketWriter writer = new PacketWriter(Sandbox.Instance.Opcodes[global::Opcodes.SMSG_UPDATE_OBJECT], "SMSG_UPDATE_OBJECT"); writer.WriteUInt32(1); // Number of transactions writer.WriteUInt8(0); writer.WriteUInt8(2); // UpdateType writer.WriteUInt64(Guid); writer.WriteUInt8(4); // ObjectType, 4 = Player writer.WriteUInt32(0); // MovementFlagMask writer.WriteUInt32((uint)Environment.TickCount); writer.WriteFloat(Location.X); // x writer.WriteFloat(Location.Y); // y writer.WriteFloat(Location.Z); // z writer.WriteFloat(Location.O); // w (o) writer.WriteFloat(2.5f); // WalkSpeed writer.WriteFloat(7.0f); // RunSpeed writer.WriteFloat(2.5f); // Backwards WalkSpeed writer.WriteFloat(4.7222f); // SwimSpeed writer.WriteFloat(4.7222f); // Backwards SwimSpeed writer.WriteFloat(3.14f); // TurnSpeed writer.WriteUInt32(1); // Flags, 1 - Player writer.WriteUInt32(1); // AttackCycle writer.WriteUInt32(0); // TimerId writer.WriteUInt64(0); // VictimGuid SetField(Fields.OBJECT_FIELD_GUID, Guid); SetField(Fields.OBJECT_FIELD_TYPE, (uint)0x19); SetField(Fields.OBJECT_FIELD_ENTRY, 0); SetField(Fields.OBJECT_FIELD_SCALE_X, Scale); SetField(Fields.OBJECT_FIELD_PADDING, 0); SetField(Fields.UNIT_FIELD_TARGET, (ulong)0); SetField(Fields.UNIT_FIELD_HEALTH, Health); SetField(Fields.UNIT_FIELD_POWER1, Mana); SetField(Fields.UNIT_FIELD_POWER2, 0); SetField(Fields.UNIT_FIELD_POWER3, Focus); SetField(Fields.UNIT_FIELD_POWER4, Energy); SetField(Fields.UNIT_FIELD_MAXHEALTH, Health); SetField(Fields.UNIT_FIELD_MAXPOWER1, Mana); SetField(Fields.UNIT_FIELD_MAXPOWER2, Rage); SetField(Fields.UNIT_FIELD_MAXPOWER3, Focus); SetField(Fields.UNIT_FIELD_MAXPOWER4, Energy); SetField(Fields.UNIT_FIELD_LEVEL, Level); SetField(Fields.UNIT_FIELD_BYTES_0, ToUInt32(Race, Class, Gender, PowerType)); SetField(Fields.PLAYER_FIELD_STAT0, Strength); SetField(Fields.PLAYER_FIELD_STAT1, Agility); SetField(Fields.PLAYER_FIELD_STAT2, Stamina); SetField(Fields.PLAYER_FIELD_STAT3, Intellect); SetField(Fields.PLAYER_FIELD_STAT4, Spirit); SetField(Fields.UNIT_FIELD_FLAGS, 0); SetField(Fields.PLAYER_BASE_MANA, Mana); SetField(Fields.UNIT_FIELD_DISPLAYID, DisplayId); SetField(Fields.UNIT_FIELD_MOUNTDISPLAYID, MountDisplayId); SetField(Fields.UNIT_FIELD_BYTES_1, ToUInt32((byte)StandState)); SetField(Fields.PLAYER_SELECTION, (ulong)0); SetField(Fields.PLAYER_BYTES, ToUInt32(Skin, Face, HairStyle, HairColor)); SetField(Fields.PLAYER_BYTES_2, ToUInt32(b2: FacialHair, b4: RestedState)); SetField(Fields.PLAYER_XP, 47); SetField(Fields.PLAYER_NEXT_LEVEL_XP, 200); SetField(Fields.PLAYER_FIELD_ATTACKPOWER, 10); SetField(Fields.PLAYER_FIELD_BYTES, 0xEEEE0000); SetField(Fields.UNIT_DYNAMIC_FLAGS, 0x1); SetField(Fields.UNIT_FIELD_BASEATTACKTIME, 1f); SetField(Fields.UNIT_FIELD_FACTIONTEMPLATE, 35); for (int i = 0; i < 32; i++) { SetField(Fields.PLAYER_EXPLORED_ZONES_1 + i, 0xFFFFFFFF); } // FillInPartialObjectData writer.WriteUInt8(MaskSize); // UpdateMaskBlocks writer.Write(MaskArray); foreach (var kvp in FieldData) { writer.Write(kvp.Value); // Data } return(writer); }
public void RemoveSceneary() { if (fieldSetting != null) { foreach (var entity in fieldSetting.GetScenery()) { int depth = entity.Key; RemoveLayer(depth); } } fieldSetting = null; }
public override void AddFields(FieldData fields) { base.AddFields(fields); resource = fields.addEnum(resource, "resource"); }
public override void AddFields(FieldData fields) { base.AddFields(fields); value = fields.add(value, "value"); }
/// <summary>Initializes shared state for this new document </summary> internal void Init(Document doc, int docID) { System.Diagnostics.Debug.Assert(!isIdle); System.Diagnostics.Debug.Assert(Enclosing_Instance.writer.TestPoint("DocumentsWriter.ThreadState.init start")); this.docID = docID; docBoost = doc.GetBoost(); numStoredFields = 0; numFieldData = 0; numVectorFields = 0; maxTermPrefix = null; System.Diagnostics.Debug.Assert(0 == fdtLocal.Length()); System.Diagnostics.Debug.Assert(0 == fdtLocal.GetFilePointer()); System.Diagnostics.Debug.Assert(0 == tvfLocal.Length()); System.Diagnostics.Debug.Assert(0 == tvfLocal.GetFilePointer()); int thisFieldGen = fieldGen++; System.Collections.IList docFields = doc.GetFields(); int numDocFields = docFields.Count; bool docHasVectors = false; // Absorb any new fields first seen in this document. // Also absorb any changes to fields we had already // seen before (eg suddenly turning on norms or // vectors, etc.): for (int i = 0; i < numDocFields; i++) { Fieldable field = (Fieldable) docFields[i]; FieldInfo fi = Enclosing_Instance.fieldInfos.Add(field.Name(), field.IsIndexed(), field.IsTermVectorStored(), field.IsStorePositionWithTermVector(), field.IsStoreOffsetWithTermVector(), field.GetOmitNorms(), false); if (fi.isIndexed && !fi.omitNorms) { // Maybe grow our buffered norms if (Enclosing_Instance.norms.Length <= fi.number) { int newSize = (int) ((1 + fi.number) * 1.25); BufferedNorms[] newNorms = new BufferedNorms[newSize]; Array.Copy(Enclosing_Instance.norms, 0, newNorms, 0, Enclosing_Instance.norms.Length); Enclosing_Instance.norms = newNorms; } if (Enclosing_Instance.norms[fi.number] == null) Enclosing_Instance.norms[fi.number] = new BufferedNorms(); Enclosing_Instance.hasNorms = true; } // Make sure we have a FieldData allocated int hashPos = fi.name.GetHashCode() & fieldDataHashMask; FieldData fp = fieldDataHash[hashPos]; while (fp != null && !fp.fieldInfo.name.Equals(fi.name)) fp = fp.next; if (fp == null) { fp = new FieldData(this, fi); fp.next = fieldDataHash[hashPos]; fieldDataHash[hashPos] = fp; if (numAllFieldData == allFieldDataArray.Length) { int newSize = (int) (allFieldDataArray.Length * 1.5); int newHashSize = fieldDataHash.Length * 2; FieldData[] newArray = new FieldData[newSize]; FieldData[] newHashArray = new FieldData[newHashSize]; Array.Copy(allFieldDataArray, 0, newArray, 0, numAllFieldData); // Rehash fieldDataHashMask = newSize - 1; for (int j = 0; j < fieldDataHash.Length; j++) { FieldData fp0 = fieldDataHash[j]; while (fp0 != null) { hashPos = fp0.fieldInfo.name.GetHashCode() & fieldDataHashMask; FieldData nextFP0 = fp0.next; fp0.next = newHashArray[hashPos]; newHashArray[hashPos] = fp0; fp0 = nextFP0; } } allFieldDataArray = newArray; fieldDataHash = newHashArray; } allFieldDataArray[numAllFieldData++] = fp; } else { System.Diagnostics.Debug.Assert(fp.fieldInfo == fi); } if (thisFieldGen != fp.lastGen) { // First time we're seeing this field for this doc fp.lastGen = thisFieldGen; fp.fieldCount = 0; fp.doVectors = fp.doVectorPositions = fp.doVectorOffsets = false; fp.doNorms = fi.isIndexed && !fi.omitNorms; if (numFieldData == fieldDataArray.Length) { int newSize = fieldDataArray.Length * 2; FieldData[] newArray = new FieldData[newSize]; Array.Copy(fieldDataArray, 0, newArray, 0, numFieldData); fieldDataArray = newArray; } fieldDataArray[numFieldData++] = fp; } if (field.IsTermVectorStored()) { if (!fp.doVectors && numVectorFields++ == vectorFieldPointers.Length) { int newSize = (int) (numVectorFields * 1.5); vectorFieldPointers = new long[newSize]; vectorFieldNumbers = new int[newSize]; } fp.doVectors = true; docHasVectors = true; fp.doVectorPositions |= field.IsStorePositionWithTermVector(); fp.doVectorOffsets |= field.IsStoreOffsetWithTermVector(); } if (fp.fieldCount == fp.docFields.Length) { Fieldable[] newArray = new Fieldable[fp.docFields.Length * 2]; Array.Copy(fp.docFields, 0, newArray, 0, fp.docFields.Length); fp.docFields = newArray; } // Lazily allocate arrays for postings: if (field.IsIndexed() && fp.postingsHash == null) fp.InitPostingArrays(); fp.docFields[fp.fieldCount++] = field; } // Maybe init the local & global fieldsWriter if (localFieldsWriter == null) { if (Enclosing_Instance.fieldsWriter == null) { System.Diagnostics.Debug.Assert(Enclosing_Instance.docStoreSegment == null); System.Diagnostics.Debug.Assert(Enclosing_Instance.segment != null); Enclosing_Instance.docStoreSegment = Enclosing_Instance.segment; // If we hit an exception while init'ing the // fieldsWriter, we must abort this segment // because those files will be in an unknown // state: try { Enclosing_Instance.fieldsWriter = new FieldsWriter(Enclosing_Instance.directory, Enclosing_Instance.docStoreSegment, Enclosing_Instance.fieldInfos); } catch (System.Exception t) { throw new AbortException(t, Enclosing_Instance); } Enclosing_Instance.files = null; } localFieldsWriter = new FieldsWriter(null, fdtLocal, Enclosing_Instance.fieldInfos); } // First time we see a doc that has field(s) with // stored vectors, we init our tvx writer if (docHasVectors) { if (Enclosing_Instance.tvx == null) { System.Diagnostics.Debug.Assert(Enclosing_Instance.docStoreSegment != null); // If we hit an exception while init'ing the term // vector output files, we must abort this segment // because those files will be in an unknown // state: try { Enclosing_Instance.tvx = Enclosing_Instance.directory.CreateOutput(Enclosing_Instance.docStoreSegment + "." + IndexFileNames.VECTORS_INDEX_EXTENSION); Enclosing_Instance.tvx.WriteInt(TermVectorsReader.FORMAT_VERSION); Enclosing_Instance.tvd = Enclosing_Instance.directory.CreateOutput(Enclosing_Instance.docStoreSegment + "." + IndexFileNames.VECTORS_DOCUMENTS_EXTENSION); Enclosing_Instance.tvd.WriteInt(TermVectorsReader.FORMAT_VERSION); Enclosing_Instance.tvf = Enclosing_Instance.directory.CreateOutput(Enclosing_Instance.docStoreSegment + "." + IndexFileNames.VECTORS_FIELDS_EXTENSION); Enclosing_Instance.tvf.WriteInt(TermVectorsReader.FORMAT_VERSION); // We must "catch up" for all docs before us // that had no vectors: for (int i = 0; i < Enclosing_Instance.numDocsInStore; i++) { Enclosing_Instance.tvx.WriteLong(Enclosing_Instance.tvd.GetFilePointer()); Enclosing_Instance.tvd.WriteVInt(0); } } catch (System.Exception t) { throw new AbortException(t, Enclosing_Instance); } Enclosing_Instance.files = null; } numVectorFields = 0; } }
public virtual void AddFields(FieldData fields) { }
private void InitBlock(DocumentsWriter enclosingInstance) { this.enclosingInstance = enclosingInstance; allFieldDataArray = new FieldData[10]; postingsPool = new ByteBlockPool(true, enclosingInstance); vectorsPool = new ByteBlockPool(false, enclosingInstance); charPool = new CharBlockPool(enclosingInstance); }
private void Flush() { int chunkDocs = PendingDocs.Count; Debug.Assert(chunkDocs > 0, chunkDocs.ToString()); // write the index file IndexWriter.WriteIndex(chunkDocs, VectorsStream.FilePointer); int docBase = NumDocs - chunkDocs; VectorsStream.WriteVInt(docBase); VectorsStream.WriteVInt(chunkDocs); // total number of fields of the chunk int totalFields = FlushNumFields(chunkDocs); if (totalFields > 0) { // unique field numbers (sorted) int[] fieldNums = FlushFieldNums(); // offsets in the array of unique field numbers FlushFields(totalFields, fieldNums); // flags (does the field have positions, offsets, payloads?) FlushFlags(totalFields, fieldNums); // number of terms of each field FlushNumTerms(totalFields); // prefix and suffix lengths for each field FlushTermLengths(); // term freqs - 1 (because termFreq is always >=1) for each term FlushTermFreqs(); // positions for all terms, when enabled FlushPositions(); // offsets for all terms, when enabled FlushOffsets(fieldNums); // payload lengths for all terms, when enabled FlushPayloadLengths(); // compress terms and payloads and write them to the output Compressor.Compress(TermSuffixes.Bytes, 0, TermSuffixes.Length, VectorsStream); } // reset PendingDocs.Clear(); CurDoc = null; CurField = null; TermSuffixes.Length = 0; }
public override void FinishField() { CurField = null; }
public IndexableFieldTypeAnonymousInnerClassHelper(FieldData outerInstance, bool omitTF) { this.OuterInstance = outerInstance; this.OmitTF = omitTF; }
public override void AddFields(FieldData fields) { base.AddFields(fields); fields.addReference(variable, "variable"); }
public virtual void _run() { for (int iter = 0; iter < NUM_TEST_ITER; iter++) { FieldData field = Fields[Random.Next(Fields.Length)]; TermsEnum termsEnum = TermsDict.GetTerms(field.FieldInfo.Name).GetIterator(null); #pragma warning disable 612, 618 if (Si.Codec is Lucene3xCodec) #pragma warning restore 612, 618 { // code below expects unicode sort order continue; } int upto = 0; // Test straight enum of the terms: while (true) { BytesRef term = termsEnum.Next(); if (term == null) { break; } BytesRef expected = new BytesRef(field.Terms[upto++].Text2); Assert.IsTrue(expected.BytesEquals(term), "expected=" + expected + " vs actual " + term); } Assert.AreEqual(upto, field.Terms.Length); // Test random seek: TermData term2 = field.Terms[Random.Next(field.Terms.Length)]; TermsEnum.SeekStatus status = termsEnum.SeekCeil(new BytesRef(term2.Text2)); Assert.AreEqual(status, TermsEnum.SeekStatus.FOUND); Assert.AreEqual(term2.Docs.Length, termsEnum.DocFreq); if (field.OmitTF) { this.VerifyDocs(term2.Docs, term2.Positions, TestUtil.Docs(Random, termsEnum, null, null, DocsFlags.NONE), false); } else { this.VerifyDocs(term2.Docs, term2.Positions, termsEnum.DocsAndPositions(null, null), true); } // Test random seek by ord: int idx = Random.Next(field.Terms.Length); term2 = field.Terms[idx]; bool success = false; try { termsEnum.SeekExact(idx); success = true; } #pragma warning disable 168 catch (System.NotSupportedException uoe) #pragma warning restore 168 { // ok -- skip it } if (success) { Assert.AreEqual(status, TermsEnum.SeekStatus.FOUND); Assert.IsTrue(termsEnum.Term.BytesEquals(new BytesRef(term2.Text2))); Assert.AreEqual(term2.Docs.Length, termsEnum.DocFreq); if (field.OmitTF) { this.VerifyDocs(term2.Docs, term2.Positions, TestUtil.Docs(Random, termsEnum, null, null, DocsFlags.NONE), false); } else { this.VerifyDocs(term2.Docs, term2.Positions, termsEnum.DocsAndPositions(null, null), true); } } // Test seek to non-existent terms: if (VERBOSE) { Console.WriteLine("TEST: seek non-exist terms"); } for (int i = 0; i < 100; i++) { string text2 = TestUtil.RandomUnicodeString(Random) + "."; status = termsEnum.SeekCeil(new BytesRef(text2)); Assert.IsTrue(status == TermsEnum.SeekStatus.NOT_FOUND || status == TermsEnum.SeekStatus.END); } // Seek to each term, backwards: if (VERBOSE) { Console.WriteLine("TEST: seek terms backwards"); } for (int i = field.Terms.Length - 1; i >= 0; i--) { Assert.AreEqual(TermsEnum.SeekStatus.FOUND, termsEnum.SeekCeil(new BytesRef(field.Terms[i].Text2)), Thread.CurrentThread.Name + ": field=" + field.FieldInfo.Name + " term=" + field.Terms[i].Text2); Assert.AreEqual(field.Terms[i].Docs.Length, termsEnum.DocFreq); } // Seek to each term by ord, backwards for (int i = field.Terms.Length - 1; i >= 0; i--) { try { termsEnum.SeekExact(i); Assert.AreEqual(field.Terms[i].Docs.Length, termsEnum.DocFreq); Assert.IsTrue(termsEnum.Term.BytesEquals(new BytesRef(field.Terms[i].Text2))); } #pragma warning disable 168 catch (System.NotSupportedException uoe) #pragma warning restore 168 { } } // Seek to non-existent empty-string term status = termsEnum.SeekCeil(new BytesRef("")); Assert.IsNotNull(status); //Assert.AreEqual(TermsEnum.SeekStatus.NOT_FOUND, status); // Make sure we're now pointing to first term Assert.IsTrue(termsEnum.Term.BytesEquals(new BytesRef(field.Terms[0].Text2))); // Test docs enum termsEnum.SeekCeil(new BytesRef("")); upto = 0; do { term2 = field.Terms[upto]; if (Random.Next(3) == 1) { DocsEnum docs; DocsEnum docsAndFreqs; DocsAndPositionsEnum postings; if (!field.OmitTF) { postings = termsEnum.DocsAndPositions(null, null); if (postings != null) { docs = docsAndFreqs = postings; } else { docs = docsAndFreqs = TestUtil.Docs(Random, termsEnum, null, null, DocsFlags.FREQS); } } else { postings = null; docsAndFreqs = null; docs = TestUtil.Docs(Random, termsEnum, null, null, DocsFlags.NONE); } Assert.IsNotNull(docs); int upto2 = -1; bool ended = false; while (upto2 < term2.Docs.Length - 1) { // Maybe skip: int left = term2.Docs.Length - upto2; int doc; if (Random.Next(3) == 1 && left >= 1) { int inc = 1 + Random.Next(left - 1); upto2 += inc; if (Random.Next(2) == 1) { doc = docs.Advance(term2.Docs[upto2]); Assert.AreEqual(term2.Docs[upto2], doc); } else { doc = docs.Advance(1 + term2.Docs[upto2]); if (doc == DocIdSetIterator.NO_MORE_DOCS) { // skipped past last doc Debug.Assert(upto2 == term2.Docs.Length - 1); ended = true; break; } else { // skipped to next doc Debug.Assert(upto2 < term2.Docs.Length - 1); if (doc >= term2.Docs[1 + upto2]) { upto2++; } } } } else { doc = docs.NextDoc(); Assert.IsTrue(doc != -1); upto2++; } Assert.AreEqual(term2.Docs[upto2], doc); if (!field.OmitTF) { Assert.AreEqual(term2.Positions[upto2].Length, postings.Freq); if (Random.Next(2) == 1) { this.VerifyPositions(term2.Positions[upto2], postings); } } } if (!ended) { Assert.AreEqual(DocIdSetIterator.NO_MORE_DOCS, docs.NextDoc()); } } upto++; } while (termsEnum.Next() != null); Assert.AreEqual(upto, field.Terms.Length); } }
public override void AddFields(FieldData fields) { base.AddFields(fields); min = fields.add(min, "min"); max = fields.add(max, "max"); }
///------------------------------------------------------------------------------------------------------------- /// <summary> /// Returns field names in the specified class using code model. /// If publicOnly is true only public fields are returned. /// </summary> ///------------------------------------------------------------------------------------------------------------- public /*protected, but public for FSharp.Project.dll*/ void GetFieldNames(CodeClass codeClass, bool caseSensitive, bool onlyBaseClasses, int depth, int maxDepth, ref FieldDataDictionary fields) { if (codeClass != null && depth <= maxDepth) { if (!(onlyBaseClasses && depth == 0)) { foreach (CodeElement codeElement in codeClass.Members) { //vsCMElement kind = codeElement.Kind; //vsCMElementVariable CodeVariable codeVariable = codeElement as CodeVariable; if (codeVariable != null) { FieldData field = new FieldData(codeClass, codeVariable, depth); if (field != null && !string.IsNullOrEmpty(field.Name)) { if (fields == null) { fields = new FieldDataDictionary(caseSensitive); } try { if (!fields.ContainsKey(field.Name)) { fields.Add(field.Name, field); } } catch { } } } } } foreach (CodeElement baseCodeElement in codeClass.Bases) { CodeClass baseCodeClass = baseCodeElement as CodeClass; if (baseCodeClass != null) { CodeElements partCodeElements = null; CodeClass2 baseCodeClass2 = baseCodeClass as CodeClass2; if (baseCodeClass2 != null) { vsCMClassKind classKind = baseCodeClass2.ClassKind; if ((classKind | vsCMClassKind.vsCMClassKindPartialClass) == vsCMClassKind.vsCMClassKindPartialClass) { try { partCodeElements = baseCodeClass2.Parts; } catch { } } } if (partCodeElements != null && partCodeElements.Count > 1) { foreach (CodeElement partCodeElement in partCodeElements) { CodeClass partCodeClass = partCodeElement as CodeClass; if (partCodeClass != null) { GetFieldNames(partCodeClass, caseSensitive, onlyBaseClasses, depth + 1, maxDepth, ref fields); } } } else { GetFieldNames(baseCodeClass, caseSensitive, onlyBaseClasses, depth + 1, maxDepth, ref fields); } } } } }
public static void RecursiveSearchData(ClassData ClassData, string Prefix, object PrefabInstance, object SpawnedInstance, bool UseInstance = false) { var TypeMono = PrefabInstance.GetType(); var coolFields = TypeMono.GetFields( BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy ).ToList(); foreach (var Field in coolFields) { if (Field.IsPrivate || Field.IsAssembly || Field.IsFamily) { var attribute = Field.GetCustomAttributes(typeof(SerializeField), true); if (attribute.Length == 0) { continue; } attribute = Field.GetCustomAttributes(typeof(HideInInspector), true); if (attribute.Length > 0) { continue; } attribute = Field.GetCustomAttributes(typeof(NaughtyAttributes.ReadOnlyAttribute), true); if (attribute.Length > 0) { continue; } } else if (Field.IsPublic) { if (Field.IsNotSerialized) { continue; } var attribute = Field.GetCustomAttributes(typeof(HideInInspector), true); if (attribute.Length > 0) { continue; } attribute = Field.GetCustomAttributes(typeof(NaughtyAttributes.ReadOnlyAttribute), true); if (attribute.Length > 0) { continue; } } if (!Field.FieldType.IsValueType && !(Field.FieldType == typeof(string))) { var APrefabDefault = Field.GetValue(PrefabInstance); var AMonoSet = Field.GetValue(SpawnedInstance); IEnumerable list = null; var Coolattribute = Field.GetCustomAttributes(typeof(SceneObjectReference), true); if (Coolattribute.Length > 0) { if (Field.FieldType.IsGenericType) { list = AMonoSet as IEnumerable; if (list != null) { bool isListCompatible = false; foreach (var Item in list) { if (Item == null) { continue; } if (Item.GetType().IsSubclassOf(typeof(UnityEngine.Object)) && Item is MonoBehaviour) { isListCompatible = true; } break; } if (isListCompatible) { var fieldData = new FieldData(); fieldData.Name = Prefix + Field.Name; foreach (var Item in list) { var mono = Item as MonoBehaviour; if (mono == null) { continue; } PopulateIDRelation(ClassData, fieldData, mono, UseInstance); } } continue; } } if (Field.FieldType.IsSubclassOf(typeof(UnityEngine.Object))) { var mono = Field.GetValue(SpawnedInstance) as MonoBehaviour; if (mono == null) { continue; } var fieldData = new FieldData(); fieldData.Name = Prefix + Field.Name; PopulateIDRelation(ClassData, fieldData, mono, UseInstance); } continue; } //if Field is a class and is not related to unity engine.object Serialise it if (Field.FieldType.IsSubclassOf(typeof(UnityEngine.Object))) { continue; } if (APrefabDefault != null && AMonoSet != null) { RecursiveSearchData(ClassData, Prefix + Field.Name + "@", APrefabDefault, AMonoSet, UseInstance); continue; } } if (Field.FieldType.IsGenericType && Field.FieldType.GetGenericTypeDefinition() == typeof(Dictionary <,>) ) { continue; //skipping all dictionaries For now } if (Field.FieldType == typeof(System.Action)) { continue; } var PrefabDefault = Field.GetValue(PrefabInstance); var MonoSet = Field.GetValue(SpawnedInstance); var selfValueComparer = PrefabDefault as IComparable; bool areSame; if (PrefabDefault == null && MonoSet == null) { areSame = true; } else if ((PrefabDefault == null && MonoSet != null) || (PrefabDefault != null && MonoSet == null)) { areSame = false; //One is null and the other wasn't } else if (selfValueComparer != null && selfValueComparer.CompareTo(MonoSet) != 0) { areSame = false; //the comparison using IComparable failed } else if (PrefabDefault.Equals(MonoSet) == false) { areSame = false; //Using the overridden one } else if (!object.Equals(PrefabDefault, MonoSet)) { areSame = false; //Using the Inbuilt one } else { areSame = true; // match } if (areSame == false) { FieldData fieldData = new FieldData(); fieldData.Name = Prefix + Field.Name; fieldData.Data = MonoSet.ToString(); ClassData.Data.Add(fieldData); } //if is a Variables inside of the class will be flattened with field name of class@Field name //Better if recursiveThrough the class //Don't do sub- variables in struct //If it is a class, //Is class Is thing thing, //and then Just repeat the loop but within that class with the added notation } }
public override void StartField(FieldInfo info, int numTerms, bool positions, bool offsets, bool payloads) { CurField = CurDoc.AddField(info.Number, numTerms, positions, offsets, payloads); LastTerm.Length = 0; }
public void RemoveField() { FieldData field = fields.Last(); fields.Remove(field); }
protected override void ExportBase(ExcelSheetData data, StreamWriter writer) { FieldData fieldData = null; var rowCount = data.filedList[0].RowCount; for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) { //处理keyCount string key = ""; for (var i = 0; i < data.keyCount; i++) { key += string.Format("\"{0}\" : ", data.filedList[i].dataList[rowIndex]) + "{"; } writer.WriteLine(key); for (var i = 0; i < data.filedList.Count; i++) { fieldData = data.filedList[i]; //数组列表 if (fieldData.objType == FieldObjectType.ARRAY) { string str = " \"" + fieldData.fieldName + "\" : {"; for (var arrayIndex = 0; arrayIndex < fieldData.ObjListCount(); arrayIndex++) { AraryFieldData afd = fieldData.GetArrayFieldByIndex(arrayIndex); str = str + string.Format("\"{0}\" : {1}", afd.keyName, afd.values[rowIndex]); if (arrayIndex != fieldData.ObjListCount() - 1) { str = str + ","; } } str += "}"; writer.Write(str); } else if (fieldData.objType == FieldObjectType.ITEM) { string str = " \"" + fieldData.fieldName + "\" : ["; List <ItemData> itemList = fieldData.GetItemDataListByIndex(rowIndex); for (var itemIndex = 0; itemIndex < itemList.Count; itemIndex++) { ItemData item = itemList[itemIndex]; str = str + "{" + string.Format("\"type\":{0},\"id\":{1},\"count\":{2}", item.type, item.id, item.count) + "}"; if (itemIndex != itemList.Count - 1) { str = str + ","; } } str += "]"; writer.Write(str); } else { //普通字段 if (fieldData.fieldType == typeof(string)) { string str = string.Format(" \"{0}\":\"{1}\"", fieldData.fieldName, fieldData.dataList[rowIndex]); writer.Write(str); } else if (fieldData.fieldType == typeof(Boolean)) { //读取出来的true 和 false 都是大写开头的这里要单独处理一下 string str = string.Format(" \"{0}\":{1}", fieldData.fieldName, fieldData.dataList[rowIndex].ToLower()); writer.Write(str); } else { string str = string.Format(" \"{0}\":{1}", fieldData.fieldName, fieldData.dataList[rowIndex]); writer.Write(str); } } //最后一行不给逗号分隔 if (i != data.filedList.Count - 1) { writer.WriteLine(","); } else { writer.WriteLine(" "); } } if (rowIndex == rowCount - 1) { writer.WriteLine(" }"); } else { writer.WriteLine(" },"); } } }
/***************** * Core UI Method * *****************/ public void OnGUI() { bool error = false; EditorGUILayout.BeginVertical("box"); { m_MainScroll = EditorGUILayout.BeginScrollView(m_MainScroll); //---- Info ----// // Type Name EditorGUILayout.LabelField("Type Info", EditorStyles.boldLabel); m_TypeName = EditorGUILayout.TextField("Type Name", m_TypeName); if (!Regex.IsMatch(m_TypeName, TYPE_REGEXP)) { error = true; EditorGUILayout.HelpBox("Type Name must start with an uppercase letter and can only contain alphanumeric characters and '-' '_'", MessageType.Error); } EditorGUILayout.Space(); m_MenuPath = EditorGUILayout.TextField("Menu Access", m_MenuPath); //---- Folders ----// EditorGUILayout.LabelField("Folders Info", EditorStyles.boldLabel); // Objects EditorGUILayout.BeginHorizontal(); { m_ObjectsFolder = EditorGUILayout.TextField("Objects Folder", m_ObjectsFolder); if (GUILayout.Button("...", GUILayout.Width(50))) { m_ObjectsFolder = string.Concat("Assets", EditorUtility.OpenFolderPanel("Choose folder", "Assets", null).Replace(Application.dataPath, "")); } } EditorGUILayout.EndHorizontal(); // Scripts EditorGUILayout.BeginHorizontal(); { m_ScriptsFolder = EditorGUILayout.TextField("Scripts Folder", m_ScriptsFolder); if (GUILayout.Button("...", GUILayout.Width(50))) { m_ScriptsFolder = string.Concat("Assets", EditorUtility.OpenFolderPanel("Choose folder", "Assets", null).Replace(Application.dataPath, "")); } } EditorGUILayout.EndHorizontal(); string objectClassFile = string.Concat(m_ScriptsFolder, "/", m_TypeName, ".cs"); string windowClassFile = string.Concat(m_ScriptsFolder, "/Editor/", m_TypeName, "Window.cs"); if (File.Exists(string.Concat(Application.dataPath, "/", objectClassFile.Substring(6)))) { EditorGUILayout.HelpBox(string.Concat("File ", objectClassFile, " already exists"), MessageType.Error); error = true; } else if (File.Exists(string.Concat(Application.dataPath, "/", windowClassFile.Substring(6)))) { EditorGUILayout.HelpBox(string.Concat("File ", windowClassFile, " already exists"), MessageType.Error); error = true; } else { string scriptsInfo = string.Concat("The following scripts will be created:\n- ", objectClassFile, "\n- ", windowClassFile); EditorGUILayout.HelpBox(scriptsInfo, MessageType.Info); } EditorGUILayout.Space(); //---- Fields ----// EditorGUILayout.BeginVertical("box"); { EditorGUILayout.LabelField("Fields", EditorStyles.boldLabel); float width = EditorGUIUtility.currentViewWidth * 0.9f; float flexibleWidth = width - FIELDS_CUSTOMTYPE_WIDTH - FIELDS_LOD_WIDTH - FIELDS_REMOVEFIELD_WIDTH; if (m_Fields.Count > 0) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Cust. Type", EditorStyles.boldLabel, GUILayout.Width(FIELDS_CUSTOMTYPE_WIDTH)); EditorGUILayout.LabelField("Type", EditorStyles.boldLabel, GUILayout.Width(flexibleWidth * FIELDS_TYPE_WIDTH)); EditorGUILayout.LabelField("Name", EditorStyles.boldLabel, GUILayout.Width(flexibleWidth * FIELDS_NAME_WIDTH)); EditorGUILayout.LabelField("Load on D.", EditorStyles.boldLabel, GUILayout.Width(FIELDS_LOD_WIDTH)); EditorGUILayout.EndHorizontal(); } // Field enum for (int i = 0; i < m_Fields.Count; i++) { FieldData fd = m_Fields[i]; EditorGUILayout.BeginHorizontal(); { GUILayout.Space((FIELDS_CUSTOMTYPE_WIDTH - FIELDS_TOGGLE_WIDTH) * 0.5f); fd.IsCustomFieldType = EditorGUILayout.Toggle(fd.IsCustomFieldType, GUILayout.Width(FIELDS_TOGGLE_WIDTH)); GUILayout.Space((FIELDS_CUSTOMTYPE_WIDTH - FIELDS_TOGGLE_WIDTH) * 0.5f); if (fd.IsCustomFieldType) { fd.FieldType = EditorGUILayout.TextField(fd.FieldType, GUILayout.Width(flexibleWidth * FIELDS_TYPE_WIDTH)); } else { if (COMMON_FIELD_TYPES.IndexOf(fd.FieldType) < 0) { fd.FieldType = COMMON_FIELD_TYPES[0]; } fd.FieldType = COMMON_FIELD_TYPES[EditorGUILayout.Popup(COMMON_FIELD_TYPES.IndexOf(fd.FieldType), COMMON_FIELD_TYPES.ToArray(), GUILayout.Width(flexibleWidth * FIELDS_TYPE_WIDTH))]; } fd.FieldName = EditorGUILayout.TextField(fd.FieldName, GUILayout.Width(flexibleWidth * FIELDS_NAME_WIDTH)); GUILayout.Space((FIELDS_LOD_WIDTH - FIELDS_TOGGLE_WIDTH) * 0.5f); fd.LoadOnDemand = EditorGUILayout.Toggle(fd.LoadOnDemand, GUILayout.Width(FIELDS_TOGGLE_WIDTH)); GUILayout.Space((FIELDS_LOD_WIDTH - FIELDS_TOGGLE_WIDTH) * 0.5f); if (GUILayout.Button("-", GUILayout.Width(FIELDS_REMOVEFIELD_WIDTH))) { m_Fields.RemoveAt(i); } } EditorGUILayout.EndHorizontal(); } // Field buttons EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("Add Field")) { m_Fields.Add(new FieldData()); } if (GUILayout.Button("Clear Fields")) { m_Fields.Clear(); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } //---- Preview ----// m_PreviewRollout = EditorGUILayout.Foldout(m_PreviewRollout, "Class Preview"); if (m_PreviewRollout) { GUI.enabled = false; EditorGUILayout.TextArea(GenerateObjectScriptFile()); GUI.enabled = true; } EditorGUILayout.Space(); //---- Final button ----// GUI.enabled = !error; if (GUILayout.Button("Generate")) { // Objects folder string pathOnDisk = string.Concat(Application.dataPath, "/", m_ObjectsFolder.Substring(6)); if (!Directory.Exists(pathOnDisk)) { Directory.CreateDirectory(pathOnDisk); } // Object class file pathOnDisk = string.Concat(Application.dataPath, "/", m_ScriptsFolder.Substring(6)); if (!Directory.Exists(pathOnDisk)) { Directory.CreateDirectory(pathOnDisk); } pathOnDisk = string.Concat(pathOnDisk, "/", m_TypeName, ".cs"); StreamWriter fileStream = File.CreateText(pathOnDisk); fileStream.Write(GenerateObjectScriptFile()); fileStream.Close(); // Editor window file pathOnDisk = string.Concat(Application.dataPath, "/", m_ScriptsFolder.Substring(6), "/Editor"); if (!Directory.Exists(pathOnDisk)) { Directory.CreateDirectory(pathOnDisk); } pathOnDisk = string.Concat(pathOnDisk, "/", m_TypeName, "Window.cs"); fileStream = File.CreateText(pathOnDisk); fileStream.Write(GenerateWindowScriptFile()); fileStream.Close(); m_TypeName = "MyScriptableObject"; m_MenuPath = string.Concat("MyGame/MyObjectEditorWindow"); m_ObjectsFolder = ""; m_ScriptsFolder = ""; m_Fields.Clear(); EditorUtility.DisplayDialog("Generation successful", "Your files have been correctly created", "OK"); AssetDatabase.Refresh(); } GUI.enabled = true; EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
public void UpdateFieldOnRelatedInstance( ) { // Define a new entity var data = new EntityData { Fields = new List <FieldData>( ), TypeIds = new EntityRef("test", "person").ToEnumerable().ToList() }; data.Fields.Add(new FieldData { FieldId = new EntityRef("name"), Value = new TypedValue("Isaac Newton") }); // Define a new related entity var data2 = new EntityData { Fields = new List <FieldData>( ), TypeIds = new EntityRef("test", "employee").ToEnumerable().ToList() }; data2.Fields.Add(new FieldData { FieldId = new EntityRef("name"), Value = new TypedValue("Isaac Newtons Emmployer") }); data2.DataState = DataState.Create; data.Relationships = new List <RelationshipData> { new RelationshipData { RelationshipTypeId = new EntityRef("test", "reportsTo"), IsReverse = false, Instances = new List <RelationshipInstanceData> { new RelationshipInstanceData { Entity = data2, DataState = DataState.Create } }, } }; // Create it var svc = new EntityInfoService( ); EntityRef id = svc.CreateEntity(data); // Verify it was created Assert.IsTrue(id.Id > 0, "Positive Id"); // Select the data EntityMemberRequest request = EntityRequestHelper.BuildRequest("name, test:reportsTo.name"); EntityData result = svc.GetEntityData(id, request); // Verify results Assert.AreEqual("Isaac Newton", result.Fields[0].Value.Value); EntityData employee = result.Relationships[0].Instances[0].Entity; FieldData employersNameField = employee.Fields[0]; Assert.AreEqual("Isaac Newtons Emmployer", employersNameField.Value.Value); // Update employees name employersNameField.Value.Value = "bob"; employee.DataState = DataState.Update; svc.UpdateEntity(result); // comfirm it changed EntityData resultAfterUpdate = svc.GetEntityData(id, request); employee = resultAfterUpdate.Relationships[0].Instances[0].Entity; employersNameField = employee.Fields[0]; Assert.AreEqual("bob", employersNameField.Value.Value); // delete the referenced Entity leaving the data state of the top entity unchanged employee.DataState = DataState.Delete; svc.UpdateEntity(resultAfterUpdate); // comfirm it deleted EntityData resultAfterDelete = svc.GetEntityData(id, request); Assert.AreEqual(0, resultAfterDelete.Relationships[0].Instances.Count, "There should be no manager"); // clean up svc.DeleteEntity(id); }
public override void StartField(FieldInfo info, int numTerms, bool positions, bool offsets, bool payloads) { curField = curDoc.AddField(info.Number, numTerms, positions, offsets, payloads); lastTerm.Length = 0; }
public override void VisitFieldData(FieldData item) { WriteMemberHeader(item); _owner._writer.Write(_owner.GetTypeId(item.Type)); _owner._writer.Write(item.IsReadOnly); }
public override void FinishField() { curField = null; }
/// <summary> /// 청크 맵을 생성한다. /// </summary> /// <param name="map_size"></param> /// <returns></returns> public FieldData GenerateChunkMap(int map_size = 3, bool isAttacked = false) { TileChunkData[,] chunkMap = new TileChunkData[map_size, map_size]; //청크 맵 초기화 InitChunkMap(chunkMap); //미로 데이터 생성 GenerateMazeData(chunkMap); //생성된 미로 데이터를 기반으로 벽의 다양성을 부여. MakeRoughWall(chunkMap); //생성된 미로 데이터를 기반으로 필드 채우기 for (int i = 0; i < map_size; i++) { for (int j = 0; j < map_size; j++) { TileChunkData tile = chunkMap[i, j]; /// 여기서 파일 불러와서 아이디 적용. tile.SetFieldData(MakeWallChunk(15 - tile.wall_ID)); } } FieldData wallData = MergeChunkDatasToFieldData(chunkMap); int fieldSize = map_size * 4; FieldData fieldData = new FieldData(fieldSize, fieldSize); StringBuilder sb = new StringBuilder(); Vector2Int pos = new Vector2Int(Random.Range(0, 100), Random.Range(0, 100)); float scale = Random.Range(0.1f, 0.3f); float intensity = GetPerlinNoiseIntensity(fieldSize, pos, scale, 20); List <string> tiles = new List <string>() { "TN", "HL", "PW", "WT" }; string tile1 = tiles[Random.Range(0, tiles.Count)]; tiles.Remove(tile1); string tile2 = tiles[Random.Range(0, tiles.Count)]; // 가시 타일 생성 for (int y = 0; y < fieldSize; y++) { for (int x = 0; x < fieldSize; x++) { if ((Mathf.PerlinNoise((x + pos.x) * scale, (y + pos.y) * scale)) < intensity) { sb.Append(tile1); } else { sb.Append("FL"); } } } fieldData.fieldStrData = sb.ToString(); char[] temp = wallData.fieldStrData.ToCharArray(); for (int i = 0; i < fieldSize * fieldSize; i++) { // char wc1 = wallData.fieldStrData[i*2]; // char wc2 = wallData.fieldStrData[i*2+1]; char fc1 = fieldData.fieldStrData[i * 2]; char fc2 = fieldData.fieldStrData[i * 2 + 1]; if ($"{fc1}{fc2}" != "FL") { temp[i * 2] = fc1; temp[i * 2 + 1] = fc2; } } #region 워 타일 생성 sb = new StringBuilder(); pos = new Vector2Int(Random.Range(0, 100), Random.Range(0, 100)); scale = Random.Range(0.1f, 0.3f); intensity = GetPerlinNoiseIntensity(fieldSize, pos, scale, 20); for (int y = 0; y < fieldSize; y++) { for (int x = 0; x < fieldSize; x++) { if ((Mathf.PerlinNoise((x + pos.x) * scale, (y + pos.y) * scale)) < intensity) { sb.Append(tile2); } else { sb.Append("FL"); } } } fieldData.fieldStrData = sb.ToString(); for (int i = 0; i < fieldSize * fieldSize; i++) { // char wc1 = wallData.fieldStrData[i*2]; // char wc2 = wallData.fieldStrData[i*2+1]; char fc1 = fieldData.fieldStrData[i * 2]; char fc2 = fieldData.fieldStrData[i * 2 + 1]; if ($"{fc1}{fc2}" != "FL") { temp[i * 2] = fc1; temp[i * 2 + 1] = fc2; } } #endregion #region Void 타일 생성 sb = new StringBuilder(); pos = new Vector2Int(Random.Range(0, 100), Random.Range(0, 100)); scale = Random.Range(0.1f, 0.3f); intensity = GetPerlinNoiseIntensity(fieldSize, pos, scale, 20); for (int y = 0; y < fieldSize; y++) { for (int x = 0; x < fieldSize; x++) { if ((Mathf.PerlinNoise((x + pos.x) * scale, (y + pos.y) * scale)) < intensity) { sb.Append("HO"); } else { sb.Append("FL"); } } } fieldData.fieldStrData = sb.ToString(); for (int i = 0; i < fieldSize * fieldSize; i++) { char wc1 = wallData.fieldStrData[i * 2]; char wc2 = wallData.fieldStrData[i * 2 + 1]; char fc1 = fieldData.fieldStrData[i * 2]; char fc2 = fieldData.fieldStrData[i * 2 + 1]; if ($"{wc1}{wc2}" == "WL" && $"{fc1}{fc2}" == "HO") { temp[i * 2] = fc1; temp[i * 2 + 1] = fc2; } } #endregion // 기습당하면 랜덤 위치에서 시작 if (isAttacked) { List <Vector2Int> randomPositions = new List <Vector2Int>(); while (randomPositions.Count < 4) { Vector2Int tempPosition = new Vector2Int(Random.Range(0, fieldSize), Random.Range(0, fieldSize)); if (!randomPositions.Contains(tempPosition)) { randomPositions.Add(tempPosition); temp[(tempPosition.x + tempPosition.y * fieldSize) * 2 + 0] = 'S'; temp[(tempPosition.x + tempPosition.y * fieldSize) * 2 + 1] = 'T'; } } } // 기습 안당하면 왼쪽 아래에서 시작 else { // 계단생성. temp[fieldSize * (fieldSize - 2) * 2 + 0] = 'S'; temp[fieldSize * (fieldSize - 2) * 2 + 1] = 'T'; temp[fieldSize * (fieldSize - 2) * 2 + 2] = 'S'; temp[fieldSize * (fieldSize - 2) * 2 + 3] = 'T'; temp[fieldSize * (fieldSize - 1) * 2 + 0] = 'S'; temp[fieldSize * (fieldSize - 1) * 2 + 1] = 'T'; temp[fieldSize * (fieldSize - 1) * 2 + 2] = 'S'; temp[fieldSize * (fieldSize - 1) * 2 + 3] = 'T'; } wallData.fieldStrData = new string(temp); return(wallData); }
public string WriteFieldSyntax(FieldData fieldData, AssemblyData assemblyData) { throw new NotImplementedException(); }
public override void AddFields(FieldData fields) { base.AddFields(fields); name = fields.add(name, "name"); description = fields.add(description, "description"); }
public override void AddFields(FieldData fields) { base.AddFields(fields); fields.addReference(character, "character"); position = fields.addEnum(position, "position"); }
public virtual void TestFixedPostings() { const int NUM_TERMS = 100; TermData[] terms = new TermData[NUM_TERMS]; for (int i = 0; i < NUM_TERMS; i++) { int[] docs = new int[] { i }; string text = Convert.ToString(i); terms[i] = new TermData(this, text, docs, null); } FieldInfos.Builder builder = new FieldInfos.Builder(); FieldData field = new FieldData(this, "field", builder, terms, true, false); FieldData[] fields = new FieldData[] { field }; FieldInfos fieldInfos = builder.Finish(); // LUCENENET specific - BUG: we must wrap this in a using block in case anything in the below loop throws using (Directory dir = NewDirectory()) { this.Write(fieldInfos, dir, fields, true); Codec codec = Codec.Default; SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, false, codec, null); // LUCENENET specific - BUG: we must wrap this in a using block in case anything in the below loop throws using (FieldsProducer reader = codec.PostingsFormat.FieldsProducer(new SegmentReadState(dir, si, fieldInfos, NewIOContext(Random), DirectoryReader.DEFAULT_TERMS_INDEX_DIVISOR))) { IEnumerator <string> fieldsEnum = reader.GetEnumerator(); fieldsEnum.MoveNext(); string fieldName = fieldsEnum.Current; Assert.IsNotNull(fieldName); Terms terms2 = reader.GetTerms(fieldName); Assert.IsNotNull(terms2); TermsEnum termsEnum = terms2.GetIterator(null); DocsEnum docsEnum = null; for (int i = 0; i < NUM_TERMS; i++) { BytesRef term = termsEnum.Next(); Assert.IsNotNull(term); Assert.AreEqual(terms[i].Text2, term.Utf8ToString()); // do this twice to stress test the codec's reuse, ie, // make sure it properly fully resets (rewinds) its // internal state: for (int iter = 0; iter < 2; iter++) { docsEnum = TestUtil.Docs(Random, termsEnum, null, docsEnum, DocsFlags.NONE); Assert.AreEqual(terms[i].Docs[0], docsEnum.NextDoc()); Assert.AreEqual(DocIdSetIterator.NO_MORE_DOCS, docsEnum.NextDoc()); } } Assert.IsNull(termsEnum.Next()); for (int i = 0; i < NUM_TERMS; i++) { Assert.AreEqual(termsEnum.SeekCeil(new BytesRef(terms[i].Text2)), TermsEnum.SeekStatus.FOUND); } Assert.IsFalse(fieldsEnum.MoveNext()); } } }
public override void AddFields(FieldData fields) { base.AddFields(fields); waitForAction = fields.addEnum(waitForAction, "waitForAction"); timeout = fields.add(timeout, "timeout"); }
public void AddFields(FieldData fields) { fields.addList(this, "objects"); }
public override bool Read() { if (!hasRows) { return false; } else { if (values != null) values = null; values = new FieldData[this.FieldCount]; } bool f = !rs.atEnd(); if (f) { for (int i = 0; i < this.FieldCount; i++) { FieldData fd = new FieldData(); fd.Data = rs.getRecord().getValue(i); fd.IsNull = rs.getRecord().isNull(i); values[i] = fd; } _recordsAffected++; rs.moveNext(); return true; } return false; }
///------------------------------------------------------------------------------------------------------------- /// <summary> /// Returns public field names in dictionary /// </summary> ///------------------------------------------------------------------------------------------------------------- public /*protected, but public for FSharp.Project.dll*/ FieldDataDictionary GetFieldNames(string[] publicFields, bool caseSensitive) { FieldDataDictionary fields = null; if (publicFields != null) { foreach (string name in publicFields) { if (!string.IsNullOrEmpty(name)) { FieldData field = new FieldData(name); if (field != null) { if (fields == null) { fields = new FieldDataDictionary(caseSensitive); } try { if (!fields.ContainsKey(field.Name)) { fields.Add(field.Name, field); } } catch { } } } } } return fields; }
internal FieldData AddField(TzdbStreamFieldId fieldNumber, IList<string> stringPool) { FieldData ret = new FieldData(fieldNumber, stringPool); fields.Add(ret); return ret; }
public void SetSceneary(FieldData fieldSetting) { this.fieldSetting = fieldSetting; foreach (var entity in fieldSetting.GetScenery()) { int layer = entity.Key; AddTileLayer(layer, entity.Value); } }
public void AddRadialData(RadialData RadialData) { if (RadialData == null) return; if (((Depths_meters == null) || (Ranges_meters == null)) && ((RadialData.Depths_meters != null) && (RadialData.Ranges_meters != null))) { Depths_meters = RadialData.Depths_meters; Ranges_meters = RadialData.Ranges_meters; } else { if ((Depths_meters != null) && (RadialData.Depths_meters != null)) ValidateDepths(RadialData.Depths_meters); if ((Ranges_meters != null) && (RadialData.Ranges_meters != null)) ValidateRanges(RadialData.Ranges_meters); } if (FieldData == null) { FieldData = new FieldData(this); FieldData.Filename = Path.Combine(DataDirectoryPath, BinaryFileName); } RadialData.ClearAxisData(); lock (FieldData) { FieldData.AddRadial(RadialData); FieldData.Save(true); } }
public IndexableFieldTypeAnonymousClass(FieldData outerInstance, bool omitTF) { this.outerInstance = outerInstance; this.omitTF = omitTF; }
internal virtual FieldData AddField(int fieldNum, int numTerms, bool positions, bool offsets, bool payloads) { FieldData field; if (Fields.Count == 0) { field = new FieldData(OuterInstance, fieldNum, numTerms, positions, offsets, payloads, PosStart, OffStart, PayStart); } else { FieldData last = Fields.Last.Value; int posStart = last.PosStart + (last.HasPositions ? last.TotalPositions : 0); int offStart = last.OffStart + (last.HasOffsets ? last.TotalPositions : 0); int payStart = last.PayStart + (last.HasPayloads ? last.TotalPositions : 0); field = new FieldData(OuterInstance, fieldNum, numTerms, positions, offsets, payloads, posStart, offStart, payStart); } Fields.AddLast(field); return field; }
public override void AddFields(FieldData fields) { base.AddFields(fields); fields.addReference(scenario, "scenario"); enabled = fields.add(enabled, "enabled"); }
public void Compute(object sender, DoWorkEventArgs e) { int CurRadial; bool CancellationPending = false; ImprovedBackgroundWorker MainWorker = (ImprovedBackgroundWorker)sender; ImprovedBackgroundWorker[] RadialWorkers = new ImprovedBackgroundWorker[Radials.Count]; MainWorker.WorkerReportsProgress = true; MainWorker.WorkerSupportsCancellation = true; IsComputing = true; BinaryFileName = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".tlf"; for (CurRadial = 0; CurRadial < Radials.Count; CurRadial++) RadialWorkers[CurRadial] = new ImprovedBackgroundWorker("radial " + CurRadial, new DoWorkEventHandler(Radials[CurRadial].Compute), new DoWorkEventHandler(Radials[CurRadial].Complete), null); for (CurRadial = 0; CurRadial < Radials.Count; CurRadial++) { // This loop will launch all the threads needed to compute the radials for this TL Field. // The maximum number of threads that will run at one time is limited by the number of processors on // the host system. CancellationPending = TrackProgress(MainWorker, RadialWorkers, System.Environment.ProcessorCount); if (CancellationPending) break; RadialWorkers[CurRadial].Priority = ThreadPriority.BelowNormal; RadialWorkers[CurRadial].RunWorkerAsync(null); Thread.Sleep(1000); } if (!CancellationPending) CancellationPending = TrackProgress(MainWorker, RadialWorkers, 1); if ((CancellationPending) && (FieldData != null) && (File.Exists(FieldData.Filename))) { File.Delete(FieldData.Filename); FieldData = null; } }