public override void OnEditorRefresh() { List <STransform> newHeadstonePoints = new List <STransform>(); StructureBuilder sb = null; foreach (Transform child in transform) { if (child.name == "Headstone") { newHeadstonePoints.Add(child); } else if (child.gameObject.HasComponent <StructureBuilder>(out sb)) { State.GraveyardStructure.TemplateName = StructureBuilder.GetTemplateName(child.name); State.GraveyardStructure.Position = child.localPosition; State.GraveyardStructure.Rotation = child.localRotation.eulerAngles; } } if (newHeadstonePoints.Count > 0) { State.HeadstoneSpawnPoints.Clear(); State.HeadstoneSpawnPoints.AddRange(newHeadstonePoints); } State.CreatedHeadstones = false; }
public void CreateStructure_WhenDictionary_ReturnsOneIndexPerElementInCorrectOrder() { Builder = StructureBuilder.Create(c => c.Register <TestItemWithDictionary>()); var item = new TestItemWithDictionary { KeyValues = new Dictionary <string, int> { { "Key1", 5 }, { "Key2", 6 }, { "Key3", 7 } } }; var structure = Builder.CreateStructure(item); var indices = structure.Indexes.Where(i => i.Path.StartsWith("KeyValues")).ToList(); Assert.AreEqual(6, indices.Count); Assert.AreEqual("KeyValues[0].Key", indices[0].Path); Assert.AreEqual("Key1", indices[0].Value); Assert.AreEqual("KeyValues[1].Key", indices[1].Path); Assert.AreEqual("Key2", indices[1].Value); Assert.AreEqual("KeyValues[2].Key", indices[2].Path); Assert.AreEqual("Key3", indices[2].Value); Assert.AreEqual("KeyValues[0].Value", indices[3].Path); Assert.AreEqual(5, indices[3].Value); Assert.AreEqual("KeyValues[1].Value", indices[4].Path); Assert.AreEqual(6, indices[4].Value); Assert.AreEqual("KeyValues[2].Value", indices[5].Path); Assert.AreEqual(7, indices[5].Value); }
public LocationPair TryToBuild(Int2 buildingSize) { if (!IsAvailableToBuild() || !IsAvailableToGrow()) { return(null); } List <Direction> availableDirs = CanSplitIn(); if (availableDirs.Count <= 0) { return(null); } LocationPair buildingBounds = null; foreach (Direction dir in availableDirs) { Tile toConsider = ground.getDirection(dir); buildingBounds = StructureBuilder.BoundsForStructure(toConsider, dir, buildingSize.x, buildingSize.y); if (buildingBounds != null) { availableDepths[(int)(dir)] = buildingBounds.SpaceInDirection(dir); break; } } return(buildingBounds); }
public UrbanPlanningOffice(City givenCity, RoadBuilder roadB = null, StructureBuilder structureB = null) : base(givenCity) { roader = (roadB == null) ? new RoadBuilder(city) : roadB; structurer = (structureB == null) ? new StructureBuilder(city) : structureB; roadSpaceAvailable = city.startRoad != null && city.startRoad.HasRoad() && city.startRoad.Neighbors().FindIndex(elem => elem.IsBuildable()) >= 0; buildingSpaceAvailable = roadSpaceAvailable; expandableRoads = new List <RoadNode>(); List <Direction> must = new List <Direction>(); must.Add(Direction.East); must.Add(Direction.West); List <Direction> can = new List <Direction>(); int[] depths = new int[4] { -1, -1, -1, -1 }; RoadNode firstNode = new RoadNode((Road)city.startRoad.Surface, must, can, depths); if (firstNode.IsAvailable()) { expandableRoads.Add(firstNode); } }
public IStructure <TSchema> Build() { var builder = new StructureBuilder <TSchema>(_schema); var graph = new DependencyGraph <Type>(); foreach (var specification in _specifications) { foreach (var layoutType in specification.Value.GetReferencedLayoutTypes()) { graph.Add(specification.Key, layoutType); } } var orderedSpecifications = graph.GetItemsInDependencyOrder() .Concat(_specifications.Keys) .Distinct() .Select(type => _specifications[type]); foreach (var specification in orderedSpecifications) { specification.Apply(builder); } return(builder.Build()); }
public City(World givenWorld) { world = givenWorld; startRoad = new Tile(); List <Int2> tried = new List <Int2>(); while (startRoad == null || tried.Count < (int)(world.Width * world.Height) || startRoad.IsUnBuildable()) { Int2 attempt = new Int2(Random.Range(0, world.Width), Random.Range(0, world.Height)); if (tried.FindIndex(elem => (elem.x == attempt.x && elem.y == attempt.y)) < 0) { startRoad = world.GetTileAt(attempt.x, attempt.y); tried.Add(attempt); } } Road built = new Road(startRoad); builders = new List <Builder>(); RoadBuilder roadie = new RoadBuilder(this); StructureBuilder houser = new StructureBuilder(this); offices = new List <CityOffice>(); offices.Add(new UrbanPlanningOffice(this, roadB: roadie, structureB: houser)); }
public void CreateStructure_WhenHashSetOfComplex_ReturnsOneIndexPerElementInCorrectOrder() { Builder = StructureBuilder.Create(c => c.Register <TestItemWithHashSetOfComplex>()); var item = new TestItemWithHashSetOfComplex { HashSetOfComplex = new HashSet <Value> { new Value { Is = 5 }, new Value { Is = 6 }, new Value { Is = 7 } } }; var structure = Builder.CreateStructure(item); var indices = structure.Indexes.Where(i => i.Path.StartsWith("HashSetOfComplex[")).ToList(); Assert.AreEqual(5, indices[0].Value); Assert.AreEqual(6, indices[1].Value); Assert.AreEqual(7, indices[2].Value); }
public void OpenPanel(BuildingData data, StructureBuilder builder) { currentData = data; currentBuilder = builder; InteractPanel.OpenPanel(currentData, currentBuilder); ViewPanel.OpenPanel(currentData); gameObject.SetActive(true); }
public void CreateStructure_WhenChildItemWithInheritedNullablesHasNullValues_NoIndexesAreCreated() { Builder = StructureBuilder.Create(c => c.Register <ChildWithNullables>()); var item = ChildWithNullables.CreateWithNullValues(); var structure = Builder.CreateStructure(item); structure.Indexes.Should().BeEmpty(); }
private static void OnInitialDirectoryChanged(DependencyObject depO, DependencyPropertyChangedEventArgs e) { if (depO is FilePicker filePicker) { string path = Convert.ToString(e.NewValue); StructureBuilder structure = (filePicker.DataContext as FilePickerViewModel).SetCurrentDirectory(path); JumpToNodeAsync(filePicker, filePicker.tree.Items, structure); } }
public void CreateStructure_WhenItemWithEnumerableWithTwoEqualElements_ReturnsIndexWithStringsAsOneValuedDelimitedString() { var schema = new AutoSchemaBuilder<WithArray>().CreateSchema(); var item = new WithArray { Values = new[] { "A", "A" } }; var builder = new StructureBuilder(); var structure = builder.CreateStructure(item, schema); var indexes = structure.Indexes.ToList(); Assert.AreEqual("<$A$>", indexes[0].Value); }
public void StructureBuilderTest() { var log = A.Fake<ILog>(); var readableRepository = A.Fake<IReadableRepository<FakeClass>>(); var writableRepository = A.Fake<IWritableRepository<FakeClass>>(); var validator = A.Fake<IValidator<FakeClass>>(); var builder = new StructureBuilder<FakeClass>(log, readableRepository, writableRepository, validator); Assert.IsNotNull(builder); }
public void CreateStructure_WhenItemWithByteArray_NoIndexShouldBeCreatedForByteArray() { var schema = new AutoSchemaBuilder<WithBytes>().CreateSchema(); var item = new WithBytes { Bytes1 = BitConverter.GetBytes(242) }; var builder = new StructureBuilder(); var structure = builder.CreateStructure(item, schema); var indexes = structure.Indexes.ToList(); Assert.AreEqual(1, indexes.Count); Assert.IsTrue(indexes[0].Name.StartsWith("DummyMember_")); }
public void CreateStructure_When_structure_has_null_collection_It_should_create_structure_with_index_for_other_members() { Builder = StructureBuilder.Create(c => c.Register <WithNullCollection>()); var item = new WithNullCollection { Temp = "Foo", Values = null }; var structure = Builder.CreateStructure(item); Assert.AreEqual(1, structure.Indexes.Count); Assert.AreEqual("Temp", structure.Indexes[0].Path); }
internal static DurationValue Build <T1>(IDictionary <T1> input) where T1 : Org.Neo4j.Values.AnyValue { StructureBuilder <AnyValue, DurationValue> builder = builder(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (java.util.Map.Entry<String,? extends org.neo4j.values.AnyValue> entry : input.entrySet()) foreach (KeyValuePair <string, ? extends AnyValue> entry in input.SetOfKeyValuePairs()) { builder.Add(entry.Key, entry.Value); } return(builder.Build()); }
public void CreateStructure_WhenUIntOnFirstLevel_ReturnsSimpleValue() { Builder = StructureBuilder.Create(c => c.Register <TestItemForFirstLevel>()); var item = new TestItemForFirstLevel { UIntValue = 42 }; var structure = Builder.CreateStructure(item); var actual = structure.Indexes.Single(si => si.Path == "UIntValue").Value; actual.Should().Be((uint)42); }
public void CreateStructure_WhenIntOnFirstLevel_ReturnsSimpleValue() { Builder = StructureBuilder.Create(c => c.Register <TestItemForFirstLevel>()); var item = new TestItemForFirstLevel { IntValue = 42 }; var structure = Builder.CreateStructure(item); var actual = structure.Indexes.Single(si => si.Path == "IntValue").Value; Assert.AreEqual(42, actual); }
public void CreateStructure_WhenEnumerableIntsOnFirstLevelAreNull_ReturnsNoIndex() { Builder = StructureBuilder.Create(c => c.Register <TestItemForFirstLevel>()); var item = new TestItemForFirstLevel { IntArray = null }; var structure = Builder.CreateStructure(item); var actual = structure.Indexes.SingleOrDefault(si => si.Path.StartsWith("IntArray")); Assert.IsNull(actual); }
public void CreateStructure_WhenSetOfIntsIsNull_ReturnsNoIndex() { Builder = StructureBuilder.Create(c => c.Register <TestItemWithISet>()); var item = new TestItemWithISet { SetOfInts = null }; var structure = Builder.CreateStructure(item); var actual = structure.Indexes.SingleOrDefault(si => si.Path.StartsWith("SetOfInts")); Assert.IsNull(actual); }
public void CreateStructure_WhenItemWithEnumerable_WillConsumeStringConverter() { var stringConverterFake = new Mock<IStringConverter>(); SisoDbEnvironment.StringConverter = stringConverterFake.Object; var schema = new AutoSchemaBuilder<WithArray>().CreateSchema(); var item = new WithArray { Values = new[] { "A", "B" } }; var builder = new StructureBuilder(); builder.CreateStructure(item, schema); stringConverterFake.Verify(s => s.AsString<object>("A"), Times.Once()); stringConverterFake.Verify(s => s.AsString<object>("B"), Times.Once()); }
public void WriteStructureTest() { var log = A.Fake<ILog>(); var readableRepository = A.Fake<IReadableRepository<FakeClass>>(); var writableRepository = A.Fake<IWritableRepository<FakeClass>>(); var validator = A.Fake<IValidator<FakeClass>>(); var builder = new StructureBuilder<FakeClass>(log, readableRepository, writableRepository, validator); builder.WriteStructure(); A.CallTo(() => writableRepository.Write(A<FakeClass>.Ignored)).MustHaveHappened(); }
public void CreateStructure_WhenStructureContainsStructWithValue_ValueOfStructIsRepresentedInIndex() { Builder = StructureBuilder.Create(c => c.Register <IHaveStruct>()); var item = new IHaveStruct { Content = "My content" }; var structure = Builder.CreateStructure(item); Assert.AreEqual(1, structure.Indexes.Count); Assert.AreEqual("Content", structure.Indexes[0].Path); Assert.AreEqual(typeof(MyText), structure.Indexes[0].DataType); Assert.AreEqual(new MyText("My content"), structure.Indexes[0].Value); }
internal override void Receive() { if (!Config.IsSinglePlayer) { lock (TcpClient) { base.Receive(); var bytes = ReadStream(DataLength); Position = new Position(bytes, 0); StructureType = (StructureType)BitConverter.ToUInt16(bytes, Position.SIZE); FrontFace = (Facing)BitConverter.ToUInt16(bytes, Position.SIZE + sizeof(ushort)); } } switch (StructureType) { case StructureType.Tree: StructureBuilder.BuildTree(Position); break; case StructureType.Tower: StructureBuilder.BuildCastle(Position, Radius, 6, Block.BlockType.Cobble, FrontFace); break; case StructureType.SmallKeep: StructureBuilder.BuildCastle(Position, Radius, 8, Block.BlockType.Cobble, FrontFace); break; case StructureType.LargeKeep: StructureBuilder.BuildCastle(Position, Radius, 10, Block.BlockType.SteelPlate, FrontFace); break; } if (Config.IsServer) { foreach (var player in Controller.Players.Values) { new AddStructure(Position, StructureType, FrontFace) { ConnectedPlayer = player }.Send(); } } else { //determine the corner coords for this structure; pass them for light calc and chunk queueing (note: the Y doesnt matter so use 0 for both) WorldData.ModifyLightAndQueueChunksForCuboidChange(new Position(Position.X - Radius, 0, Position.Z - Radius), new Position(Position.X + Radius, 0, Position.Z + Radius)); Sounds.Audio.PlaySound(Sounds.SoundType.AddBlock); } }
public void Should_be_able_to_index_nested_child_by_registrating_child_only() { Builder = StructureBuilder.Create(c => c.Register <MyRoot>(cfg => cfg .UsingIndexMode(IndexMode.Inclusive) .Members(e => e.OneChild.GrandChild.SomeInt))); var item = new MyRoot { SomeString = "Foo Bar", SomeInt = 1, OneChild = new MyChild { SomeString = "One child", SomeInt = 2, GrandChild = new MyGrandChild { SomeString = "Grand child 2.1", SomeInt = 21 } }, ManyChildren = new List <MyChild> { new MyChild { SomeString = "List Child1", SomeInt = 3, GrandChild = new MyGrandChild { SomeString = "Grand child 3.1", SomeInt = 31 } }, new MyChild { SomeString = "List Child2", SomeInt = 4, GrandChild = new MyGrandChild { SomeString = "Grand child 4.1", SomeInt = 41 } } } }; var structure = Builder.CreateStructure(item); Assert.AreEqual(1, structure.Indexes.Count); }
public void CreateStructure_WhenHashSetOfComplex_HasThreeNullItems_ReturnsNoIndex() { Builder = StructureBuilder.Create(c => c.Register <TestItemWithHashSetOfComplex>()); var item = new TestItemWithHashSetOfComplex { HashSetOfComplex = new HashSet <Value> { null, null, null } }; var structure = Builder.CreateStructure(item); var actual = structure.Indexes.SingleOrDefault(si => si.Path.StartsWith("HashSetOfComplex.Is")); Assert.IsNull(actual); }
public void CreateStructure_WhenEnumerableIntsOnFirstLevel_ReturnsOneIndexPerElementInCorrectOrder() { Builder = StructureBuilder.Create(c => c.Register <TestItemForFirstLevel>()); var item = new TestItemForFirstLevel { IntArray = new[] { 5, 6, 7 } }; var structure = Builder.CreateStructure(item); var indices = structure.Indexes.Where(i => i.Path.StartsWith("IntArray[")).ToList(); Assert.AreEqual(5, indices[0].Value); Assert.AreEqual(6, indices[1].Value); Assert.AreEqual(7, indices[2].Value); }
public override void OnEditorRefresh() { foreach (Transform child in transform) { if (child.name.Contains("-STR")) { //this is our structure template State.EntranceStructure.TemplateName = StructureBuilder.GetTemplateName(child.name); State.EntranceStructure.Position = child.localPosition; State.EntranceStructure.Rotation = child.localRotation.eulerAngles; UnityEditor.EditorUtility.SetDirty(this); UnityEditor.EditorUtility.SetDirty(gameObject); break; } } }
public void CreateStructure_WhenChildItemWithInheritedNullablesHasValues_IndexesAreCreated() { Builder = StructureBuilder.Create(c => c.Register <ChildWithNullables>()); var item = ChildWithNullables.CreatePopulated(); var structure = Builder.CreateStructure(item); Assert.AreEqual(2, structure.Indexes.Count); Assert.AreEqual("NullableInt", structure.Indexes[0].Path); Assert.AreEqual(typeof(int?), structure.Indexes[0].DataType); Assert.AreEqual(item.NullableInt, structure.Indexes[0].Value); Assert.AreEqual("NullableGuid", structure.Indexes[1].Path); Assert.AreEqual(typeof(Guid?), structure.Indexes[1].DataType); Assert.AreEqual(item.NullableGuid, structure.Indexes[1].Value); }
public void CreateStructure_WhenISetOfInts_ReturnsOneIndexPerElementInCorrectOrder() { Builder = StructureBuilder.Create(c => c.Register <TestItemWithISet>()); var item = new TestItemWithISet { SetOfInts = new HashSet <int> { 5, 6, 7 } }; var structure = Builder.CreateStructure(item); var indices = structure.Indexes.Where(i => i.Path.StartsWith("SetOfInts[")).ToList(); Assert.AreEqual(5, indices[0].Value); Assert.AreEqual(6, indices[1].Value); Assert.AreEqual(7, indices[2].Value); }
public PonyTextStructureBase Parse(string source) { builder = new StructureBuilder(); builder.StartTextStructure(PonyToken.Empty); bool result = tokenGenerator.RunGenerator(source); if (context.Count != 0) { errorListener.OnParserErrorReported("Unexpected termination", currentState, string.Empty); } if (result) { return(builder.BuildStructure()); } return(null); }
public void CreateStructure_When_5thLevel_has_null_values_It_should_create_structure_with_index_for_other_members() { Builder = StructureBuilder.Create(c => c.Register <TestItemForFifthLevel>()); var item = new TestItemForFifthLevel { Containers = new List <Container>() { new Container() { IntValue = 27, MyItem = new Item() } } }; var structure = Builder.CreateStructure(item); Assert.AreEqual(1, structure.Indexes.Count); Assert.AreEqual("Containers[0].IntValue", structure.Indexes[0].Path); }
public TreeStructure(BlockManager blocks, BiomeManager biomes) { Name = "Base/Structures/Trees"; _air = blocks.GetBlockOrDefault("Base/Block/Air"); Block grass = blocks.GetBlockOrDefault("Base/Block/Grass"); VarientConditions deepForest = new VarientConditions() { Below = grass, Biome = biomes.GetBiomeOrDefault("Deep Forest") }; Conditions = new VarientConditions[] { deepForest, deepForest }; Block wood = blocks.GetBlockOrDefault("Base/Block/Oak Wood"); Block leaves = blocks.GetBlockOrDefault("Base/Block/Oak Leaves"); Varients = new Varient[] { new Varient() { Entries = StructureBuilder.Start() .Add(new StructureBuilder.Box(Vector3Int.zero, Vector3Int.up * 6), wood, true) .Add(new StructureBuilder.Box(new Vector3Int(-2, 4, -3), new Vector3Int(2, 6, 3)), leaves, false, false) .Add(new StructureBuilder.Box(new Vector3Int(-3, 4, -2), new Vector3Int(3, 6, 2)), leaves, false, false) .Add(new StructureBuilder.Box(new Vector3Int(-2, 7, -2), new Vector3Int(2, 7, 2)), leaves, false, false).Finish(), ChanceToSpawn = 0.025f }, new Varient() { Entries = StructureBuilder.Start() .Add(new StructureBuilder.Box(Vector3Int.zero, Vector3Int.up * 3), wood, true) .Add(new StructureBuilder.Box(new Vector3Int(-1, 2, -2), new Vector3Int(1, 3, 2)), leaves, false, false) .Add(new StructureBuilder.Box(new Vector3Int(-2, 2, -1), new Vector3Int(2, 3, 1)), leaves, false, false) .Add(new StructureBuilder.Box(new Vector3Int(-1, 4, -1), new Vector3Int(1, 4, 1)), leaves, false, false).Finish(), ChanceToSpawn = 0.075f } }; }
public void CreateStructure_WhenCustomNonGenericEnumerableWithComplexElement_ReturnsIndexesForElements() { Builder = StructureBuilder.Create(c => c.Register <ModelForMyCustomNonGenericEnumerable>()); var item = new ModelForMyCustomNonGenericEnumerable(); item.Items.Add(new MyElement { IntValue = 1, StringValue = "A" }); item.Items.Add(new MyElement { IntValue = 2, StringValue = "B" }); var structure = Builder.CreateStructure(item); var indices = structure.Indexes; Assert.AreEqual("A", indices[0].Value); Assert.AreEqual("B", indices[1].Value); Assert.AreEqual(1, indices[2].Value); Assert.AreEqual(2, indices[3].Value); }
public override void OnEditorRefresh() { bool foundStructure = false; foreach (Transform child in transform) { StructureBuilder builder = child.GetComponent <StructureBuilder>(); if (builder != null) { State.DenStructure.TemplateName = StructureBuilder.GetTemplateName(builder.name); State.DenStructure.Position = child.localPosition; State.DenStructure.Rotation = child.localRotation.eulerAngles; foundStructure = true; break; } } if (!foundStructure) { State.DenStructure.TemplateName = string.Empty; } }
private void Awake() { foreach (var structureType in builders) { // Create a new instance of structure Structure structure = new Structure(); // Fancy way of creating a builder using reflection StructureBuilder builder = (StructureBuilder)Activator.CreateInstance(structureType); builder.SetStructure(structure); // Fancy builder Syntax builder .BuildFirstFloor() .BuildSecondFloor() .BuildThirdFloor() .BuildFourthFloor(); myStructures.Add(structure); } }
internal string GetStrucutreForHeader(int Header, bool searchInOldFile) { HabboClass Class; HabboClass ParserClass; if (searchInOldFile) { if (_FileOne.HabboClassManager.CachedMessageEvents.TryGetValue(Header, out Class)) { if (Class.ParserClass != string.Empty) { ParserClass = _FileOne.HabboClassManager.GetClassByName(Class.ParserClass); if (ParserClass != null) { StructureBuilder builder = new StructureBuilder(Header, _FileOne.HabboClassManager, Class, ParserClass); builder.CreateStructure(); return builder.ToString(); } } else { Console.WriteLine("There is no parser class for class {0}", Class.ClassId); } } else { Console.WriteLine("Can't find header {0} in file {1}", Header, _FileOne.File); } } else { if (_FileTwo.HabboClassManager.CachedMessageEvents.TryGetValue(Header, out Class)) { if (Class.ParserClass != string.Empty) { ParserClass = _FileTwo.HabboClassManager.GetClassByName(Class.ParserClass); if (ParserClass != null) { StructureBuilder builder = new StructureBuilder(Header, _FileTwo.HabboClassManager, Class, ParserClass); builder.CreateStructure(); return builder.ToString(); } } else { Console.WriteLine("There is no parser class for class {0}", Class.ClassId); } } else { Console.WriteLine("Can't find header {0} in file {1}", Header, _FileOne.File); } } return string.Empty; }
/// <summary> /// Builds the query structure for REST for the specified <paramref name="schema"/>. /// </summary> /// <param name="schema"> /// The SDMX schema version. /// </param> /// <param name="principal"> /// The principal. /// </param> /// <returns> /// The <see cref="IController{IRestStructureQuery,XmlWriter}"/>. /// </returns> public IController<IRestStructureQuery, XmlWriter> BuildQueryStructureRest(SdmxSchema schema, DataflowPrincipal principal) { IWriterBuilder<IStructureWriterManager, XmlWriter> structureManagerBuilder = new StructureBuilder(WebServiceEndpoint.StandardEndpoint, schema); StructureOutputFormatEnumType outputFormat; IAuthMutableStructureSearchManager authMutableStructureSearchManager; IMutableStructureSearchManager mutableStructureSearchManager; switch (schema.EnumType) { case SdmxSchemaEnumType.VersionTwo: authMutableStructureSearchManager = this._authMutableStructureSearchManagerV20; mutableStructureSearchManager = this._mutableStructureSearchManagerV20; outputFormat = StructureOutputFormatEnumType.SdmxV2StructureDocument; break; default: authMutableStructureSearchManager = this._authMutableStructureSearchManagerV21; mutableStructureSearchManager = this._mutableStructureSearchManagerV21; outputFormat = StructureOutputFormatEnumType.SdmxV21StructureDocument; break; } IResponseGenerator<XmlWriter, ISdmxObjects> responseGenerator = new StructureResponseGenerator(structureManagerBuilder, outputFormat); var structureRequestController = new StructureRequestRestController<XmlWriter>(responseGenerator, mutableStructureSearchManager, authMutableStructureSearchManager, principal); return structureRequestController; }
protected override void OnTestInitialize() { Builder = new StructureBuilder(); }
public void CreateStructure_WhenItemWithNoEnumerable_ReturnsIndexWithStringValue() { var schema = new AutoSchemaBuilder<WithNoArray>().CreateSchema(); var item = new WithNoArray { Value = "A" }; var builder = new StructureBuilder(); var structure = builder.CreateStructure(item, schema); var indexes = structure.Indexes.ToList(); Assert.AreEqual("A", indexes[0].Value); }
/// <summary> /// Builds the Advanced Structure controller for SDMX V21 SOAP. /// </summary> /// <param name="principal"> /// The principal. /// </param> /// <param name="soapOperation"> /// The SOAP operation. /// </param> /// <returns> /// The <see cref="IController{XmlNode,XmlWriter}"/>. /// </returns> public IController<Message, XmlWriter> BuildAdvancedQueryStructureV21(DataflowPrincipal principal, SoapOperation soapOperation) { IWriterBuilder<IStructureWriterManager, XmlWriter> structureManagerBuilder = new StructureBuilder(WebServiceEndpoint.StandardEndpoint, _sdmxSchemaV21); IResponseGenerator<XmlWriter, ISdmxObjects> responseGenerator = new StructureResponseGenerator(structureManagerBuilder, StructureOutputFormatEnumType.SdmxV21StructureDocument); var structureRequestController = new StructureRequestV21AdvancedController<XmlWriter>( responseGenerator, this._authAdvancedMutableStructureSearchManager, this._advancedMutableStructureSearchManager, principal, soapOperation); return structureRequestController; }
/// <summary> /// Builds the query structure for SDMX v20 SOAP requests /// </summary> /// <param name="endpoint"> /// The endpoint. /// </param> /// <param name="principal"> /// The principal. /// </param> /// <returns> /// The <see cref="IController{XElement,XmlWriter}"/>. /// </returns> public IController<Message, XmlWriter> BuildQueryStructureV20FromMessage(WebServiceEndpoint endpoint, DataflowPrincipal principal) { IWriterBuilder<IStructureWriterManager, XmlWriter> structureManagerBuilder = new StructureBuilder(endpoint, _sdmxSchemaV20); IResponseGenerator<XmlWriter, ISdmxObjects> responseGenerator = new StructureResponseGenerator(structureManagerBuilder, StructureOutputFormatEnumType.SdmxV2RegistryQueryResponseDocument); var structureRequestController = new StructureRequestV20Controller<XmlWriter>( responseGenerator, this._mutableStructureSearchManagerV20, this._authMutableStructureSearchManagerV20, principal); return structureRequestController; }
internal void UpdateMessageEvent(int OldHeader) { Console.WriteLine("Please wait while searching for matches..\n"); HabboClass Class = null; HabboClass ParserClass = null; if (_FileOne.HabboClassManager.CachedMessageEvents.TryGetValue(OldHeader, out Class)) { ParserClass = _FileOne.HabboClassManager.GetClassByName(Class.ParserClass); if (ParserClass != null) { StructureBuilder builder = new StructureBuilder(OldHeader, _FileOne.HabboClassManager, Class, ParserClass); builder.CreateStructure(); string structure = builder.ToString().Split(':')[1]; // split out the header id ArrayList SearchResults = new ArrayList(); // Maybe it's faster with Parallel Parallel.ForEach(_FileTwo.HabboClassManager.CachedMessageEvents.Values, (NewClass, option) => { if (NewClass != null) { HabboClass NewParserClass = _FileTwo.HabboClassManager.GetClassByName(NewClass.ParserClass); if (NewParserClass != null) { StructureBuilder structBuild = new StructureBuilder(_FileTwo.HabboClassManager.GetMessageEventHeaderByClassName(NewClass.ClassId), _FileTwo.HabboClassManager, NewClass, NewParserClass); structBuild.CreateStructure(); string newstructure = structBuild.ToString().Split(':')[1]; double Result = Math.Round(Compare(ParserClass.ClassLines, NewParserClass.ClassLines), 3); int structResult = Compute(structure, newstructure); if (structResult < 2 && Result > 0.5) { SearchResult searchResult = new SearchResult() { Header = _FileTwo.HabboClassManager.GetMessageEventHeaderByClassName(NewClass.ClassId), MethodResult = Result, StructureDifference = structResult, OldStructure = structure, NewStructure = newstructure, ParserClassName = NewParserClass.ClassId }; SearchResults.Add(searchResult); } } } }); SearchResults.Sort(new SearchResultComparer()); Console.WriteLine("\nFound {0} results, sorted by structure difference.", SearchResults.Count); foreach (SearchResult Result in SearchResults) { Console.WriteLine(); Console.WriteLine("Found new header: {0}", Result.Header); Console.WriteLine("CalcSimilarity {0}% : {1}", Result.MethodResult, Result.ParserClassName); Console.WriteLine("Structure diff: {0}", Result.StructureDifference); Console.WriteLine("New structure: {0}", Result.NewStructure); Console.WriteLine("Old structure: {0}", Result.OldStructure); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine("Finished.."); } else { Console.WriteLine("Can't find the ParserClass {0} for the MessageEvent {1}", Class.ParserClass, OldHeader); } } else { Console.WriteLine("Can't find header {0} in CachedMessageEvents in {1}", OldHeader, _FileOne.File); } }