public static YamlNode GetNodes(Asset source)
        {
            var root = new YamlMappingNode();
            var assetType = source.AssetType;
            root.Add("asset", assetType);
            JObject obj = JObject.FromObject(source.GetChangesDto());
            obj.Remove("AssetType");

            YamlMappingNode attributes = new YamlMappingNode();

            var tuples = (from prop in
                            (
                                from token in JToken.FromObject(obj)
                                where token.Type == JTokenType.Property
                                select token as JProperty
                             )
                          select GetUpdateAttribute(prop)
                        );
            foreach (var tuple in tuples)
            {
                attributes.Add(tuple.Item1, tuple.Item2);
            }

            root.Add("attributes", attributes);

            return root;
        }
        public YamlNode ToYaml()
        {
            var node = new YamlMappingNode();

            node.Add("logger-name", LoggerName);
            node.Add("console", new YamlMappingNode(new YamlScalarNode("enabled"), new YamlScalarNode(ConsoleEnable.ToString().ToLower())));

            node.Add("rotating-file", new YamlMappingNode(
                         new YamlScalarNode("enabled"), new YamlScalarNode(RotatingFileEnable.ToString().ToLower()),
                         new YamlScalarNode("path"), new YamlScalarNode(RotatingFilePath),
                         new YamlScalarNode("max-size"), new YamlScalarNode(RotatingFileMaxSize.ToString()),
                         new YamlScalarNode("max-files"), new YamlScalarNode(RotatingFileMaxFiles.ToString()))
                     );

            return(node);
        }
        private static YamlMappingNode CreateDefaultLoggingConfig()
        {
            var node = new YamlMappingNode();

            node.Add("logger-name", "application");
            node.Add("console", new YamlMappingNode(new YamlScalarNode("enabled"), new YamlScalarNode("true")));

            node.Add("rotating-file", new YamlMappingNode(
                         new YamlScalarNode("enabled"), new YamlScalarNode("false"),
                         new YamlScalarNode("path"), new YamlScalarNode("adapter.log"),
                         new YamlScalarNode("max-size"), new YamlScalarNode("1048576"),
                         new YamlScalarNode("max-files"), new YamlScalarNode("3"))
                     );

            return(node);
        }
        public void ParsesTeamCityServerCorrectly()
        {
            var kernel = new StandardKernel();

            var parser = kernel.Get<TeamCityConfigParser>();

            kernel.Bind<ITimer>().ToConstant(new Mock<ITimer>().Object);
            kernel.Bind<IParser>().ToConstant(new Mock<IParser>().Object).Named("TeamCity");

            var config = new YamlMappingNode
                             {
                                 {"url", "http://localhost"},
                                 {"username", "ci"},
                                 {"password", "secret"}
                             };
            var pipeline1 = new YamlMappingNode {{"name", "bt1"}};
            var pipeline2 = new YamlMappingNode { { "name", "bt2" } };
            var pipelines = new YamlSequenceNode {pipeline1, pipeline2};
            config.Add("pipelines",pipelines);

            var teamCityServer = parser.Parse(config) as TeamCityServer;
            Assert.IsNotNull(teamCityServer);
            Assert.IsNotNull(teamCityServer.Config);
            var teamCityServerConfig = teamCityServer.Config;
            Assert.AreEqual("http://localhost", teamCityServerConfig.URL);
            Assert.AreEqual("ci", teamCityServerConfig.Username);
            Assert.AreEqual("secret", teamCityServerConfig.Password);
            Assert.IsNotNull(teamCityServerConfig.Pipelines);
            Assert.AreEqual(2, teamCityServerConfig.Pipelines.Count());
        }
Beispiel #5
0
        public string SerializeTemplate(ViewPointOfSaleViewModel.Item[] items)
        {
            var mappingNode = new YamlMappingNode();

            foreach (var item in items)
            {
                var itemNode = new YamlMappingNode();
                itemNode.Add("title", new YamlScalarNode(item.Title));
                itemNode.Add("price", new YamlScalarNode(item.Price.Value.ToStringInvariant()));
                if (!string.IsNullOrEmpty(item.Description))
                {
                    itemNode.Add("description", new YamlScalarNode(item.Description));
                }
                if (!string.IsNullOrEmpty(item.Image))
                {
                    itemNode.Add("image", new YamlScalarNode(item.Image));
                }
                itemNode.Add("custom", new YamlScalarNode(item.Custom.ToStringLowerInvariant()));
                if (item.Inventory.HasValue)
                {
                    itemNode.Add("inventory", new YamlScalarNode(item.Inventory.ToString()));
                }
                mappingNode.Add(item.Id, itemNode);
            }

            var serializer = new SerializerBuilder().Build();

            return(serializer.Serialize(mappingNode));
        }
        private YamlMappingNode CreateRssMap(IDictionary <YamlNode, YamlNode> nodes)
        {
            var map = new YamlMappingNode();

            map.Add("QueryTime", (!nodes.IsNull() && nodes.ContainsKey("QueryTime")) ? nodes["QueryTime".ToYamlNode()].ToString() : d_querytime.ToString());
            return(map);
        }
Beispiel #7
0
        internal void GenerateNewConfig(Stream outputStream)
        {
            var outputWriter = new StreamWriter(outputStream);

            var rootNodeName = Data.ElementAt(0).Key;

            var docMapping = new YamlMappingNode();
            foreach (var item in Data.Skip(1))
            {
                docMapping.Add(item.Key.Replace((rootNodeName + ":"), string.Empty), (item.Value ?? EmptyValue));
                // TODO: If contains ":" then Mapping node etc
            }
            
            var yamlStream = new YamlStream(
                new YamlDocument(
                    new YamlMappingNode(
                        new YamlScalarNode(rootNodeName),
                        docMapping
                    )
                )
            );
            
            yamlStream.Save(outputWriter);
            outputWriter.Flush();
        }
Beispiel #8
0
            public override YamlNode TypeToNode(object obj, YamlObjectSerializer serializer)
            {
                var node   = new YamlMappingNode();
                var type   = obj.GetType();
                var fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

                foreach (var field in fields)
                {
                    if (field.IsNotSerialized)
                    {
                        continue;
                    }

                    var fVal = field.GetValue(obj);

                    if (fVal == null)
                    {
                        throw new ArgumentException("Cannot serialize null value inside struct field.");
                    }

                    // Potential recursive infinite loop?
                    var fTypeNode = serializer.TypeToNode(fVal);
                    node.Add(field.Name, fTypeNode);
                }

                return(node);
            }
        private static YamlNode SerializeChunk(IMapChunk chunk)
        {
            var root  = new YamlMappingNode();
            var value = new YamlScalarNode($"{chunk.X},{chunk.Y}");

            value.Style = ScalarStyle.DoubleQuoted;
            root.Add("ind", value);

            var gridNode = new YamlScalarNode();

            root.Add("tiles", gridNode);

            gridNode.Value = SerializeTiles(chunk);

            return(root);
        }
        public static YamlMappingNode SerializeGrid(IMapGrid grid)
        {
            var gridn    = new YamlMappingNode();
            var info     = new YamlMappingNode();
            var chunkSeq = new YamlSequenceNode();

            gridn.Add("settings", info);
            gridn.Add("chunks", chunkSeq);

            info.Add("csz", grid.ChunkSize.ToString(CultureInfo.InvariantCulture));
            info.Add("tsz", grid.TileSize.ToString(CultureInfo.InvariantCulture));
            info.Add("sgsz", grid.SnapSize.ToString(CultureInfo.InvariantCulture));

            var chunks = grid.GetMapChunks();

            foreach (var chunk in chunks)
            {
                var chunkNode = SerializeChunk(chunk);
                chunkSeq.Add(chunkNode);
            }

            var root = new YamlMappingNode();

            root.Add("grid", gridn);
            return(root);
        }
        public void ParsesCruiseControlServerCorrectly()
        {
            var kernel = new StandardKernel();

            var parser = kernel.Get<CruiseControlConfigParser>();

            kernel.Bind<ITimer>().ToConstant(new Mock<ITimer>().Object);
            kernel.Bind<IParser>().ToConstant(new Mock<IParser>().Object).Named("CruiseControl");

            var config = new YamlMappingNode
                             {
                                 {"url", "http://goserver.localdomain:8153/go/cctray.xml"},
                                 {"username", "ci"},
                                 {"password", "secret"}
                             };
            var pipeline1 = new YamlMappingNode {{"name", "Cosby-Kid"}};
            var pipeline2 = new YamlMappingNode { { "name", "Family-Tieman" } };
            var pipelines = new YamlSequenceNode {pipeline1, pipeline2};
            config.Add("pipelines",pipelines);

            var cruiseControlServer = parser.Parse(config) as CruiseControlServer;
            Assert.IsNotNull(cruiseControlServer);
            Assert.IsNotNull(cruiseControlServer.Config);
            var cruiseControlServerconfig = cruiseControlServer.Config;
            Assert.AreEqual("http://goserver.localdomain:8153/go/cctray.xml", cruiseControlServerconfig.URL);
            Assert.AreEqual("ci", cruiseControlServerconfig.Username);
            Assert.AreEqual("secret", cruiseControlServerconfig.Password);
            Assert.IsNotNull(cruiseControlServerconfig.Pipelines);
            Assert.AreEqual(2, cruiseControlServerconfig.Pipelines.Count());
        }
Beispiel #12
0
            protected override void UpgradeAsset(AssetMigrationContext context, PackageVersion currentVersion, PackageVersion targetVersion, dynamic asset, PackageLoadingAssetFile assetFile, OverrideUpgraderHint overrideHint)
            {
                var hierarchy = asset.Hierarchy;
                var entities  = (DynamicYamlArray)hierarchy.Entities;

                foreach (dynamic entity in entities)
                {
                    var components    = entity.Components;
                    var physComponent = components["PhysicsComponent.Key"];
                    if (physComponent != null)
                    {
                        foreach (dynamic element in physComponent.Elements)
                        {
                            var index = element.IndexOf("Shape");
                            if (index == -1)
                            {
                                continue;
                            }

                            dynamic shapeId = element.Shape;
                            element.ColliderShapes = new DynamicYamlArray(new YamlSequenceNode());
                            dynamic subnode = new YamlMappingNode {
                                Tag = "!ColliderShapeAssetDesc"
                            };
                            subnode.Add("Shape", shapeId.Node.Value);
                            element.ColliderShapes.Add(subnode);

                            element.RemoveChild("Shape");
                        }
                    }
                }
            }
        public static ServiceOutput CreateService(OutputContext output, Application application, ServiceEntry service)
        {
            if (output is null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            if (application is null)
            {
                throw new ArgumentNullException(nameof(application));
            }

            if (service is null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            var root = new YamlMappingNode();

            root.Add("kind", "Service");
            root.Add("apiVersion", "v1");

            var metadata = new YamlMappingNode();

            root.Add("metadata", metadata);
            metadata.Add("name", service.Service.Name);

            var labels = new YamlMappingNode();

            metadata.Add("labels", labels);
            labels.Add("app.kubernetes.io/name", service.Service.Name);
            labels.Add("app.kubernetes.io/part-of", application.Globals.Name);

            var spec = new YamlMappingNode();

            root.Add("spec", spec);

            var selector = new YamlMappingNode();

            spec.Add("selector", selector);
            selector.Add("app.kubernetes.io/name", service.Service.Name);

            spec.Add("type", "ClusterIP");

            var ports = new YamlSequenceNode();

            spec.Add("ports", ports);

            var port = new YamlMappingNode();

            ports.Add(port);

            port.Add("name", "web");
            port.Add("protocol", "TCP");
            port.Add("port", "80");
            port.Add("targetPort", "80");

            return(new KubernetesServiceOutput(service.Service.Name, new YamlDocument(root)));
        }
Beispiel #14
0
            private void WriteEntitySection()
            {
                var entities = new YamlSequenceNode();

                RootNode.Add("entities", entities);

                foreach (var entity in Entities)
                {
                    CurrentWritingEntity = entity;
                    var mapping = new YamlMappingNode
                    {
                        { "uid", EntityUidMap[entity.Uid].ToString(CultureInfo.InvariantCulture) }
                    };

                    if (entity.Prototype != null)
                    {
                        mapping.Add("type", entity.Prototype.ID);
                    }

                    var components = new YamlSequenceNode();
                    // See engine#636 for why the Distinct() call.
                    foreach (var component in entity.GetAllComponents())
                    {
                        var compMapping = new YamlMappingNode();
                        CurrentWritingComponent = component.Name;
                        var compSerializer = YamlObjectSerializer.NewWriter(compMapping, this);

                        component.ExposeData(compSerializer);

                        // Don't need to write it if nothing was written!
                        if (compMapping.Children.Count != 0)
                        {
                            // Something actually got written!
                            compMapping.Add("type", component.Name);
                            components.Add(compMapping);
                        }
                    }

                    if (components.Children.Count != 0)
                    {
                        mapping.Add("components", components);
                    }

                    entities.Add(mapping);
                }
            }
        public static string ToYaml(ByamlExt.Byaml.BymlFileData data)
        {
            /*var settings = new SerializerSettings()
             * {
             *  EmitTags = false,
             *  EmitAlias = false,
             *  DefaultStyle = SharpYaml.YamlStyle.Flow,
             *  SortKeyForMapping = false,
             *  EmitShortTypeName = true,
             *  EmitCapacityForList = false,
             *  LimitPrimitiveFlowSequence = 4,
             * };
             *
             * settings.RegisterTagMapping("!u", typeof(uint));
             * settings.RegisterTagMapping("!l", typeof(int));
             * settings.RegisterTagMapping("!d", typeof(double));
             * settings.RegisterTagMapping("!ul", typeof(ulong));
             * settings.RegisterTagMapping("!ll", typeof(long));
             *
             * var serializer = new Serializer(settings);
             * return serializer.Serialize(data);*/

            NodePaths.Clear();
            refNodeId = 0;

            YamlNode        root    = SaveNode("root", data.RootNode);
            YamlMappingNode mapping = new YamlMappingNode();

            mapping.Add("Version", data.Version.ToString());
            mapping.Add("IsBigEndian", (data.byteOrder == ByteOrder.BigEndian).ToString());
            mapping.Add("SupportPaths", data.SupportPaths.ToString());
            mapping.Add("HasReferenceNodes", (refNodeId != 0).ToString());
            mapping.Add("root", root);

            NodePaths.Clear();
            refNodeId = 0;
            var doc = new YamlDocument(mapping);

            YamlStream stream = new YamlStream(doc);
            var        buffer = new StringBuilder();

            using (var writer = new StringWriter(buffer)) {
                stream.Save(writer, true);
                return(writer.ToString());
            }
        }
Beispiel #16
0
            private void AddComponent(dynamic componentsNode, YamlMappingNode node, Guid id)
            {
                // New format (1.9)
                DynamicYamlMapping mapping = (DynamicYamlMapping)componentsNode;

                mapping.AddChild(new YamlScalarNode(Guid.NewGuid().ToString("N")), node);
                node.Add("Id", id.ToString("D"));
            }
Beispiel #17
0
        private static int AddLinks(YamlSequenceNode parent, Link[] links)
        {
            int count = 0;

            foreach (var link in links)
            {
                if (link.subfolderitems == null || link.subfolderitems.Length == 0)
                {
                    var node = new YamlMappingNode();
                    node.Add(link.name, GetHref(link));
                    parent.Children.Add(node);
                    count++;
                }
                else
                {
                    var node = new YamlMappingNode();
                    var s    = new YamlSequenceNode();
                    var href = GetHref(link);

                    node.Add(link.name, s);
                    parent.Children.Add(node);
                    var overview = new YamlMappingNode();
                    if (href.EndsWith("Assembly.md"))
                    {
                        overview.Add("Assembly Overview", href);
                    }
                    else if (href.EndsWith("Namespace.md"))
                    {
                        overview.Add("Namespace Overview", href);
                    }
                    else if (href.EndsWith("Type.md"))
                    {
                        overview.Add("Type Overview", href);
                    }
                    else
                    {
                        overview.Add("Overview", href);
                    }

                    s.Add(overview);
                    count += AddLinks(s, link.subfolderitems) + 1;
                }
            }

            return(count);
        }
Beispiel #18
0
            public override YamlNode TypeToNode(object obj, YamlObjectSerializer serializer)
            {
                var specifier = (SpriteSpecifier)obj;

                switch (obj)
                {
                case SpriteSpecifier.Texture tex:
                    return(tex.TexturePath.ToString());

                case SpriteSpecifier.Rsi rsi:
                    var mapping = new YamlMappingNode();
                    mapping.Add("sprite", rsi.RsiPath.ToString());
                    mapping.Add("state", rsi.RsiState);
                    return(mapping);
                }
                throw new NotImplementedException();
            }
Beispiel #19
0
        private static void AddProbe(ServiceBuilder service, YamlMappingNode container, ProbeBuilder builder, string name)
        {
            var probe = new YamlMappingNode();

            container.Add(name, probe);

            if (builder.Http != null)
            {
                var builderHttp = builder.Http;
                var httpGet     = new YamlMappingNode();

                probe.Add("httpGet", httpGet);
                httpGet.Add("path", builderHttp.Path);

                if (builderHttp.Protocol != null)
                {
                    httpGet.Add("scheme", builderHttp.Protocol.ToUpper());
                }

                if (builderHttp.Port != null)
                {
                    httpGet.Add("port", builderHttp.Port.ToString() !);
                }
                else
                {
                    // If port is not given, we pull default port
                    var binding = service.Bindings.First(b => builderHttp.Protocol == null || b.Protocol == builderHttp.Protocol);
                    if (binding.Port != null)
                    {
                        httpGet.Add("port", binding.Port.Value.ToString());
                    }

                    if (builderHttp.Protocol == null && binding.Protocol != null)
                    {
                        httpGet.Add("scheme", binding.Protocol.ToUpper());
                    }
                }

                if (builderHttp.Headers.Count > 0)
                {
                    var headers = new YamlSequenceNode();
                    httpGet.Add("httpHeaders", headers);

                    foreach (var builderHeader in builderHttp.Headers)
                    {
                        var header = new YamlMappingNode();
                        header.Add("name", builderHeader.Key);
                        header.Add("value", builderHeader.Value.ToString() !);
                        headers.Add(header);
                    }
                }
            }

            probe.Add("initialDelaySeconds", builder.InitialDelay.ToString());
            probe.Add("periodSeconds", builder.Period.ToString() !);
            probe.Add("successThreshold", builder.SuccessThreshold.ToString() !);
            probe.Add("failureThreshold", builder.FailureThreshold.ToString() !);
        }
Beispiel #20
0
        private YamlMappingNode CreateWeatherMap(IDictionary <YamlNode, YamlNode> nodes)
        {
            var map  = new YamlMappingNode();
            var map2 = new YamlMappingNode();

            if (!nodes.IsNull() && nodes.ContainsKey("Home"))
            {
                var node2 = ((YamlMappingNode)nodes["Home".ToYamlNode()]).Children;
                map2.Add("City", (!node2.IsNull() && node2.ContainsKey("City")) ? node2["City".ToYamlNode()].ToString() : d_weatherhomecity);
            }
            else
            {
                map2.Add("City", d_weatherhomecity);
            }

            map.Add("Home", map2);
            return(map);
        }
Beispiel #21
0
        private YamlMappingNode CreateWolframAlphaMap(IDictionary <YamlNode, YamlNode> nodes)
        {
            var map  = new YamlMappingNode();
            var map2 = new YamlMappingNode();

            if (!nodes.IsNull() && nodes.ContainsKey("Api"))
            {
                var node2 = ((YamlMappingNode)nodes["Api".ToYamlNode()]).Children;
                map2.Add("Key", (!node2.IsNull() && node2.ContainsKey("Key")) ? node2["Key".ToYamlNode()].ToString() : d_wolframalphaapikey);
            }
            else
            {
                map2.Add("Key", d_wolframalphaapikey);
            }

            map.Add("Api", map2);
            return(map);
        }
Beispiel #22
0
        static YamlNode reifyDocumentation(EA.Repository Repository, EA.Element e, EA.Connector con, EA.Element client)
        {
            logger.log("Reify Documentation:" + e.Name + "-" + e.Version);
            YamlSequenceNode sn = new YamlSequenceNode();
            Dictionary <string, RunState> elementRS = ObjectManager.parseRunState(e.RunState);

            foreach (string key in elementRS.Keys)
            {
                YamlMappingNode docNode = new YamlMappingNode();
                sn.Add(docNode);
                YamlScalarNode docObjectAttribute = new YamlScalarNode(elementRS[key].value);
                docObjectAttribute.Style = ScalarStyle.Raw;
                docNode.Add("title", key);
                docNode.Add("content", docObjectAttribute);
            }

            return(sn);
        }
Beispiel #23
0
            void WriteEntitySection()
            {
                var entities = new YamlSequenceNode();

                RootNode.Add("entities", entities);

                foreach (var entity in Entities)
                {
                    CurrentWritingEntity = entity;
                    var mapping = new YamlMappingNode();
                    mapping.Add("type", entity.Prototype.ID);
                    if (entity.Name != entity.Prototype.Name)
                    {
                        // TODO: This shouldn't be hardcoded.
                        mapping.Add("name", entity.Prototype.Name);
                    }

                    var components = new YamlSequenceNode();
                    // See engine#636 for why the Distinct() call.
                    foreach (var component in entity.GetAllComponents().Distinct())
                    {
                        var compMapping = new YamlMappingNode();
                        CurrentWritingComponent = component.Name;
                        var compSerializer = YamlObjectSerializer.NewWriter(compMapping, this);

                        component.ExposeData(compSerializer);

                        // Don't need to write it if nothing was written!
                        if (compMapping.Children.Count != 0)
                        {
                            // Something actually got written!
                            compMapping.Add("type", component.Name);
                            components.Add(compMapping);
                        }
                    }

                    if (components.Children.Count != 0)
                    {
                        mapping.Add("components", components);
                    }

                    entities.Add(mapping);
                }
            }
        private static YamlMappingNode SaveTextureGlyph(TGLP texInfo)
        {
            YamlMappingNode mapping = new YamlMappingNode();

            mapping.Add("Cell_Height", texInfo.CellHeight.ToString());
            mapping.Add("Cell_Width", texInfo.CellWidth.ToString());
            mapping.Add("Format", texInfo.Format.ToString());
            mapping.Add("BaseLinePos", texInfo.BaseLinePos.ToString());
            mapping.Add("MaxCharWidth", texInfo.MaxCharWidth.ToString());
            mapping.Add("Sheet_Height", texInfo.SheetHeight.ToString());
            mapping.Add("Sheet_Width", texInfo.SheetWidth.ToString());
            mapping.Add("RowCount", texInfo.RowCount.ToString());
            mapping.Add("ColumnCount", texInfo.ColumnCount.ToString());
            return(mapping);
        }
        public static string ToYaml(FFNT header)
        {
            YamlMappingNode mapping = new YamlMappingNode();

            mapping.Add("Platform", header.Platform.ToString());
            mapping.Add("Version", header.Version.ToString("X"));
            mapping.Add("FontInfo", SaveFontInfo(header.FontSection));
            mapping.Add("KerningTable", SaveKerningTable(header.KerningTable));

            var doc = new YamlDocument(mapping);

            YamlStream stream = new YamlStream(doc);
            var        buffer = new StringBuilder();

            using (var writer = new StringWriter(buffer)) {
                stream.Save(writer, true);
                return(writer.ToString());
            }
        }
        public YamlMappingNode ToYaml()
        {
            var ss = new YamlMappingNode();

            ss.Add(PathKey, FileHelper.ConvertToForwardSlash(RuntimeFilePath));
            ss.Add(TemplateFilePathKey, LocalFilePath);
            ss.Add(SessionNameKey, Name);
            var overrides = new YamlSequenceNode();

            ss.Add(OverridesKey, overrides);
            foreach (var o in Overrides)
            {
                YamlMappingNode dic = new YamlMappingNode();
                dic.Add(KeyKey, o.Key);
                dic.Add(ValueKey, o.Value);
                overrides.Add(dic);
            }
            return(ss);
        }
Beispiel #27
0
        static YamlNode reifyExamples(EA.Repository Repository, EA.Element e, EA.Connector con, EA.Element client)
        {
            logger.log("ReifyExamples:" + fileManager.examplesPath(e.Name));

            YamlMappingNode example = new YamlMappingNode();

            if (e.Notes != null && e.Notes.Length > 0)
            {
                example.Add("description", e.Notes);
            }

            YamlScalarNode node = new YamlScalarNode("!include " + fileManager.examplesPath(e.Name));

            node.Style = ScalarStyle.Raw;

            example.Add("value", node);

            return(node);
        }
Beispiel #28
0
        private YamlMappingNode CreateServerMap(IDictionary <YamlNode, YamlNode> nodes)
        {
            var map  = new YamlMappingNode();
            var map2 = new YamlMappingNode();

            if (!nodes.IsNull() && nodes.ContainsKey("Listener"))
            {
                var node = ((YamlMappingNode)nodes["Listener".ToYamlNode()]).Children;
                map2.Add("Port", ((!node.IsNull() && node.ContainsKey("Port")) ? node["Port".ToYamlNode()].ToString() : d_listenerport.ToString()));
            }
            else
            {
                map2.Add("Port", d_listenerport.ToString());
            }

            map.Add("Listener", map2);
            map.Add("Password", (!nodes.IsNull() && nodes.ContainsKey("Password")) ? nodes["Password".ToYamlNode()].ToString() : d_password);
            return(map);
        }
Beispiel #29
0
            private void WriteTileMapSection()
            {
                var tileMap = new YamlMappingNode();

                RootNode.Add("tilemap", tileMap);
                foreach (var tileDefinition in _tileDefinitionManager)
                {
                    tileMap.Add(tileDefinition.TileId.ToString(CultureInfo.InvariantCulture), tileDefinition.Name);
                }
            }
Beispiel #30
0
        public YamlStream GetYamlStream()
        {
            var stream = new YamlStream();
            var root   = new YamlMappingNode();
            var doc    = new YamlDocument(root);

            stream.Add(doc);

            // file info
            root.Add(FileInformation.Name, FileInformation.ToYaml());

            // Logging
            root.Add(Logging.Name, Logging.ToYaml());

            // Plugins
            root.Add(Plugins.Name, Plugins.ToYaml());

            return(stream);
        }
        public static void WriteDefaultConfig(string filePath)
        {
            var stream = new YamlStream();
            var root   = new YamlMappingNode();
            var doc    = new YamlDocument(root);

            stream.Add(doc);

            // Logging
            root.Add("logging", CreateDefaultLoggingConfig());

            // Plugins
            root.Add("plugins", CreateDefaultPluginConfig());

            using (var writer = new StreamWriter(filePath))
            {
                stream.Save(writer, assignAnchors: false);
            }
        }
        public void Build()
        {
            Console.WriteLine($"Generating {GetFilePath()}");
            var deserializer = new DeserializerBuilder().Build();
            var serializer   = new SerializerBuilder().Build();

            Console.WriteLine($"With fragments:");
            foreach (var fragment in Fragments)
            {
                Console.WriteLine($"\t{fragment}");
            }
            var services = new List <KeyValuePair <YamlNode, YamlNode> >();
            var volumes  = new List <KeyValuePair <YamlNode, YamlNode> >();

            foreach (var doc in Fragments.Select(f => ParseDocument(f)))
            {
                if (doc.Children.ContainsKey("services") && doc.Children["services"] is YamlMappingNode fragmentServicesRoot)
                {
                    services.AddRange(fragmentServicesRoot.Children);
                }

                if (doc.Children.ContainsKey("volumes") && doc.Children["volumes"] is YamlMappingNode fragmentVolumesRoot)
                {
                    volumes.AddRange(fragmentVolumesRoot.Children);
                }
            }


            YamlMappingNode output = new YamlMappingNode();

            output.Add("version", new YamlScalarNode("3")
            {
                Style = YamlDotNet.Core.ScalarStyle.DoubleQuoted
            });
            output.Add("services", new YamlMappingNode(Merge(services)));
            output.Add("volumes", new YamlMappingNode(volumes));
            var result     = serializer.Serialize(output);
            var outputFile = GetFilePath();

            File.WriteAllText(outputFile, result.Replace("''", ""));
            Console.WriteLine($"Generated {outputFile}");
            Console.WriteLine();
        }
        public YamlNode ToYaml()
        {
            var node = new YamlMappingNode();

            node.Add("enabled", Enabled.ToString().ToLower());
            node.Add("database-url", DatabaseUrl);
            node.Add("store-measurement", StoreMeasurement.ToString().ToLower());
            node.Add("table-name", TableName);
            node.Add("store-raw-message", StoreRawMessage.ToString().ToLower());
            node.Add("raw-table-name", RawTableName);
            node.Add("raw-data-format", ((int)RawDataFormat).ToString());
            node.Add("max-queued-messages", MaxQueuedMessages.ToString());
            node.Add("connect-retry-seconds", ConnectRetrySeconds.ToString());

            return(node);
        }
Beispiel #34
0
 private YamlMappingNode CreateCrashMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Directory", (!nodes.IsNull() && nodes.ContainsKey("Directory")) ? nodes["Directory".ToYamlNode()].ToString() : d_crashdirectory);
     return map;
 }
Beispiel #35
0
 private YamlMappingNode CreateFloodingMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Seconds",          (!nodes.IsNull() && nodes.ContainsKey("Seconds")) ? nodes["Seconds".ToYamlNode()].ToString() : d_floodingseconds.ToString());
     map.Add("NumberOfCommands", (!nodes.IsNull() && nodes.ContainsKey("NumberOfCommands")) ? nodes["NumberOfCommands".ToYamlNode()].ToString() : d_floodingnumberofcommands.ToString());
     return map;
 }
Beispiel #36
0
        public bool CreateConfig(string ConfigDirectory, string ConfigFile, bool ColorBindMode)
        {
            try
            {
                string filename = Path.Combine(ConfigDirectory, ConfigFile);

                if(File.Exists(filename))
                    return true;
                else
                {
                    new LogConfig(d_logfilename, d_logdatefilename, d_logmaxfilesize, 3, d_logdirectory, d_irclogdirectory, d_irclog);
                    Log.Initialize(d_logfilename, ColorBindMode);
                    Log.Error("YamlConfig", sLConsole.GetString("No such config file!"));
                    Log.Debug("YamlConfig", sLConsole.GetString("Preparing..."));
                    var yaml = new YamlStream();
                    string filename2 = Path.Combine(ConfigDirectory, "_" + ConfigFile);

                    if(File.Exists(filename2))
                    {
                        Log.Notice("YamlConfig", sLConsole.GetString("The backup files will be used to renew the data."));
                        yaml.Load(File.OpenText(filename2));
                    }

                    try
                    {
                        var schumixmap = (yaml.Documents.Count > 0 && ((YamlMappingNode)yaml.Documents[0].RootNode).Children.ContainsKey("Schumix")) ? ((YamlMappingNode)((YamlMappingNode)yaml.Documents[0].RootNode).Children["Schumix".ToYamlNode()]).Children : YamlExtensions.NullYMap;
                        var nodes = new YamlMappingNode();
                        var nodes2 = new YamlMappingNode();
                        nodes2.Add("Server",       CreateServerMap(schumixmap.GetYamlChildren("Server")));
                        nodes2.Add("Listener",     CreateListenerMap(schumixmap.GetYamlChildren("Listener")));

                        if((!schumixmap.IsNull() && schumixmap.ContainsKey("Irc")))
                        {
                            foreach(var irc in schumixmap)
                            {
                                if(irc.Key.ToString().Contains("Irc"))
                                    nodes2.Add(irc.Key, CreateIrcMap(((YamlMappingNode)irc.Value).Children));
                            }
                        }
                        else
                            nodes2.Add("Irc",      CreateIrcMap(YamlExtensions.NullYMap));

                        nodes2.Add("Log",          CreateLogMap(schumixmap.GetYamlChildren("Log")));
                        nodes2.Add("MySql",        CreateMySqlMap(schumixmap.GetYamlChildren("MySql")));
                        nodes2.Add("SQLite",       CreateSQLiteMap(schumixmap.GetYamlChildren("SQLite")));
                        nodes2.Add("Addon",        CreateAddonsMap(schumixmap.GetYamlChildren("Addon")));
                        nodes2.Add("Scripts",      CreateScriptsMap(schumixmap.GetYamlChildren("Scripts")));
                        nodes2.Add("Crash",        CreateCrashMap(schumixmap.GetYamlChildren("Crash")));
                        nodes2.Add("Localization", CreateLocalizationMap(schumixmap.GetYamlChildren("Localization")));
                        nodes2.Add("Update",       CreateUpdateMap(schumixmap.GetYamlChildren("Update")));
                        nodes2.Add("Shutdown",     CreateShutdownMap(schumixmap.GetYamlChildren("Shutdown")));
                        nodes2.Add("Flooding",     CreateFloodingMap(schumixmap.GetYamlChildren("Flooding")));
                        nodes2.Add("Clean",        CreateCleanMap(schumixmap.GetYamlChildren("Clean")));
                        nodes2.Add("ShortUrl",     CreateShortUrlMap(schumixmap.GetYamlChildren("ShortUrl")));
                        nodes.Add("Schumix", nodes2);

                        sUtilities.CreateFile(filename);
                        var file = new StreamWriter(filename, true) { AutoFlush = true };
                        file.Write(nodes.Children.ToString("Schumix"));
                        file.Close();

                        if(File.Exists(filename2))
                        {
                            Log.Notice("YamlConfig", sLConsole.GetString("The backup has been deleted during the re-use."));
                            File.Delete(filename2);
                        }

                        Log.Success("YamlConfig", sLConsole.GetString("Config file is completed!"));
                    }
                    catch(Exception e)
                    {
                        Log.Error("YamlConfig", sLConsole.GetString("Failure was handled during the yml writing. Details: {0}"), e.Message);
                        errors = true;
                    }
                }
            }
            catch(DirectoryNotFoundException)
            {
                CreateConfig(ConfigDirectory, ConfigFile, ColorBindMode);
            }

            return false;
        }
Beispiel #37
0
        private YamlMappingNode CreateWolframAlphaMap(IDictionary<YamlNode, YamlNode> nodes)
        {
            var map = new YamlMappingNode();
            var map2 = new YamlMappingNode();

            if(!nodes.IsNull() && nodes.ContainsKey("Api"))
            {
                var node2 = ((YamlMappingNode)nodes["Api".ToYamlNode()]).Children;
                map2.Add("Key", (!node2.IsNull() && node2.ContainsKey("Key")) ? node2["Key".ToYamlNode()].ToString() : d_wolframalphaapikey);
            }
            else
                map2.Add("Key", d_wolframalphaapikey);

            map.Add("Api", map2);
            return map;
        }
Beispiel #38
0
 private YamlMappingNode CreateFloodingMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Seconds",          (!nodes.IsNull() && nodes.ContainsKey("Seconds")) ? nodes["Seconds".ToYamlNode()].ToString() : _seconds.ToString());
     map.Add("NumberOfMessages", (!nodes.IsNull() && nodes.ContainsKey("NumberOfMessages")) ? nodes["NumberOfMessages".ToYamlNode()].ToString() : _numberofmessages.ToString());
     map.Add("NumberOfFlooding", (!nodes.IsNull() && nodes.ContainsKey("NumberOfFlooding")) ? nodes["NumberOfFlooding".ToYamlNode()].ToString() : _numberofflooding.ToString());
     return map;
 }
Beispiel #39
0
        private YamlMappingNode CreateCompilerMap(IDictionary<YamlNode, YamlNode> nodes)
        {
            var map = new YamlMappingNode();
            map.Add("Enabled",               (!nodes.IsNull() && nodes.ContainsKey("Enabled")) ? nodes["Enabled".ToYamlNode()].ToString() : d_compilerenabled.ToString());

            var map2 = new YamlMappingNode();

            if(!nodes.IsNull() && nodes.ContainsKey("MaxAllocating"))
            {
                var node2 = ((YamlMappingNode)nodes["MaxAllocating".ToYamlNode()]).Children;
                map2.Add("Enabled", (!node2.IsNull() && node2.ContainsKey("Enabled")) ? node2["Enabled".ToYamlNode()].ToString() : d_enabled.ToString());
                map2.Add("Memory",  (!node2.IsNull() && node2.ContainsKey("Memory")) ? node2["Memory".ToYamlNode()].ToString() : d_memory.ToString());
            }
            else
            {
                map2.Add("Enabled", d_enabled.ToString());
                map2.Add("Memory",  d_memory.ToString());
            }

            map.Add("MaxAllocating",         map2);
            map.Add("CompilerOptions",       (!nodes.IsNull() && nodes.ContainsKey("CompilerOptions")) ? nodes["CompilerOptions".ToYamlNode()].ToString() : d_compileroptions);
            map.Add("WarningLevel",          (!nodes.IsNull() && nodes.ContainsKey("WarningLevel")) ? nodes["WarningLevel".ToYamlNode()].ToString() : d_warninglevel.ToString());
            map.Add("TreatWarningsAsErrors", (!nodes.IsNull() && nodes.ContainsKey("TreatWarningsAsErrors")) ? nodes["TreatWarningsAsErrors".ToYamlNode()].ToString() : d_treatwarningsaserrors.ToString());
            map.Add("Referenced",            (!nodes.IsNull() && nodes.ContainsKey("Referenced")) ? nodes["Referenced".ToYamlNode()].ToString() : d_referenced);
            map.Add("ReferencedAssemblies",  (!nodes.IsNull() && nodes.ContainsKey("ReferencedAssemblies")) ? nodes["ReferencedAssemblies".ToYamlNode()].ToString() : d_referencedassemblies);
            map.Add("MainClass",             (!nodes.IsNull() && nodes.ContainsKey("MainClass")) ? nodes["MainClass".ToYamlNode()].ToString() : d_mainclass);
            map.Add("MainConstructor",       (!nodes.IsNull() && nodes.ContainsKey("MainConstructor")) ? nodes["MainConstructor".ToYamlNode()].ToString() : d_mainconstructor);
            return map;
        }
Beispiel #40
0
 private YamlMappingNode CreateShutdownMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("MaxMemory", (!nodes.IsNull() && nodes.ContainsKey("MaxMemory")) ? nodes["MaxMemory".ToYamlNode()].ToString() : d_shutdownmaxmemory.ToString());
     return map;
 }
Beispiel #41
0
 private YamlMappingNode CreateShortUrlMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Name",   (!nodes.IsNull() && nodes.ContainsKey("Name")) ? nodes["Name".ToYamlNode()].ToString() : d_shorturlname);
     map.Add("ApiKey", (!nodes.IsNull() && nodes.ContainsKey("ApiKey")) ? nodes["ApiKey".ToYamlNode()].ToString() : d_shorturlapikey);
     return map;
 }
Beispiel #42
0
 private YamlMappingNode CreateServerMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Enabled",  (!nodes.IsNull() && nodes.ContainsKey("Enabled")) ? nodes["Enabled".ToYamlNode()].ToString() : d_serverenabled.ToString());
     map.Add("Host",     (!nodes.IsNull() && nodes.ContainsKey("Host")) ? nodes["Host".ToYamlNode()].ToString() : d_serverhost);
     map.Add("Port",     (!nodes.IsNull() && nodes.ContainsKey("Port")) ? nodes["Port".ToYamlNode()].ToString() : d_serverport.ToString());
     map.Add("Password", (!nodes.IsNull() && nodes.ContainsKey("Password")) ? nodes["Password".ToYamlNode()].ToString() : d_serverpassword);
     return map;
 }
Beispiel #43
0
        private YamlMappingNode CreateServerMap(IDictionary<YamlNode, YamlNode> nodes)
        {
            var map = new YamlMappingNode();
            var map2 = new YamlMappingNode();

            if(!nodes.IsNull() && nodes.ContainsKey("Listener"))
            {
                var node = ((YamlMappingNode)nodes["Listener".ToYamlNode()]).Children;
                map2.Add("Port", ((!node.IsNull() && node.ContainsKey("Port")) ? node["Port".ToYamlNode()].ToString() : d_listenerport.ToString()));
            }
            else
                map2.Add("Port", d_listenerport.ToString());

            map.Add("Listener", map2);
            map.Add("Password", (!nodes.IsNull() && nodes.ContainsKey("Password")) ? nodes["Password".ToYamlNode()].ToString() : d_password);
            return map;
        }
Beispiel #44
0
        private YamlMappingNode CreateModeMap(IDictionary<YamlNode, YamlNode> nodes)
        {
            var map = new YamlMappingNode();
            var map2 = new YamlMappingNode();

            if(!nodes.IsNull() && nodes.ContainsKey("Remove"))
            {
                var node2 = ((YamlMappingNode)nodes["Remove".ToYamlNode()]).Children;
                map2.Add("Enabled", (!node2.IsNull() && node2.ContainsKey("Enabled")) ? node2["Enabled".ToYamlNode()].ToString() : d_enabled.ToString());
                map2.Add("Type",    (!node2.IsNull() && node2.ContainsKey("Type")) ? node2["Type".ToYamlNode()].ToString() : d_type);
            }
            else
            {
                map2.Add("Enabled", d_enabled.ToString());
                map2.Add("Type",    d_type);
            }

            map.Add("Remove", map2);
            return map;
        }
Beispiel #45
0
        private YamlMappingNode CreateWeatherMap(IDictionary<YamlNode, YamlNode> nodes)
        {
            var map = new YamlMappingNode();
            var map2 = new YamlMappingNode();

            if(!nodes.IsNull() && nodes.ContainsKey("Home"))
            {
                var node2 = ((YamlMappingNode)nodes["Home".ToYamlNode()]).Children;
                map2.Add("Country", (!node2.IsNull() && node2.ContainsKey("Country")) ? node2["Country".ToYamlNode()].ToString() : d_weatherhomecountry);
                map2.Add("City", (!node2.IsNull() && node2.ContainsKey("City")) ? node2["City".ToYamlNode()].ToString() : d_weatherhomecity);
            }
            else
            {
                map2.Add("Country", d_weatherhomecountry);
                map2.Add("City", d_weatherhomecity);
            }

            map.Add("Home", map2);

            map2 = new YamlMappingNode();

            if(!nodes.IsNull() && nodes.ContainsKey("Wunderground"))
            {
                var node2 = ((YamlMappingNode)nodes["Wunderground".ToYamlNode()]).Children;
                map2.Add("Key", (!node2.IsNull() && node2.ContainsKey("Key")) ? node2["Key".ToYamlNode()].ToString() : d_wundergroundapikey);
            }
            else
                map2.Add("Key", d_wundergroundapikey);

            map.Add("Wunderground", map2);
            return map;
        }
        protected virtual void ConfigureCassandra()
        {
            string configRoot = Path.Combine(_CassandraRoot, "conf");
            if (!Directory.Exists(configRoot))
            {
                Directory.CreateDirectory(configRoot);
            }

            string configFile = Path.Combine(configRoot,CASSANDRA_CONFIG_FILE);

            using (var input = new StreamReader(_TemplateConfigFile))
            using (var output = new StreamWriter(configFile, false))
            {
                Trace.WriteLine("Loading Default Config");

                // Load the stream
                var yamlInput = new YamlStream();
                yamlInput.Load(input);

                var rootOutputNode = new YamlMappingNode();
                var outputDoc = new YamlDocument(rootOutputNode);
                var yamlOutput = new YamlStream(outputDoc);

                if (yamlInput.Documents.Count > 0)
                {
                    var mapping = (YamlMappingNode)yamlInput.Documents[0].RootNode;
                    var reservedConfigs = new string[] { "data_file_directories" };
                    foreach (var entry in mapping.Children.Where(m => !reservedConfigs.Contains(m.Key.ToString())))
                    {
                        rootOutputNode.Add(entry.Key, entry.Value);
                    }
                }

                Trace.WriteLine("Writing Critical Config values");
                //write important config values reglardless of what was provided in package

                rootOutputNode.Add(new YamlScalarNode("data_file_directories"), new YamlSequenceNode(new YamlScalarNode(_DataPath)));

                //Write seeds
                //rootOutputNode.Add(new YamlScalarNode("cloud.azureruntime.bridge"), new YamlScalarNode(_BridgePipeName));

                yamlOutput.Save(output,false);

                //Not sure why this is happening but let us clean out chas in end of file.

                Trace.TraceInformation("Saved cassandra config file {0}", configFile);

            }
        }
Beispiel #47
0
        public bool CreateConfig(string ConfigDirectory, string ConfigFile)
        {
            string filename = Path.Combine(ConfigDirectory, ConfigFile);

            if(File.Exists(filename))
                return true;
            else
            {
                Log.Error("ExtraAddonConfig", sLConsole.GetString("No such config file!"));
                Log.Debug("ExtraAddonConfig", sLConsole.GetString("Preparing..."));
                var yaml = new YamlStream();
                string filename2 = Path.Combine(ConfigDirectory, "_" + ConfigFile);

                if(File.Exists(filename2))
                {
                    Log.Notice("ExtraAddonConfig", sLConsole.GetString("The backup files will be used to renew the data."));
                    yaml.Load(File.OpenText(filename2));
                }

                try
                {
                    var extramap = (yaml.Documents.Count > 0 && ((YamlMappingNode)yaml.Documents[0].RootNode).Children.ContainsKey("ExtraAddon")) ? ((YamlMappingNode)((YamlMappingNode)yaml.Documents[0].RootNode).Children["ExtraAddon".ToYamlNode()]).Children : YamlExtensions.NullYMap;
                    var nodes = new YamlMappingNode();
                    var nodes2 = new YamlMappingNode();
                    nodes2.Add("Mode",         CreateModeMap(extramap.GetYamlChildren("Mode")));
                    nodes2.Add("Weather",      CreateWeatherMap(extramap.GetYamlChildren("Weather")));
                    nodes2.Add("WolframAlpha", CreateWolframAlphaMap(extramap.GetYamlChildren("WolframAlpha")));
                    nodes.Add("ExtraAddon",    nodes2);

                    sUtilities.CreateFile(filename);
                    var file = new StreamWriter(filename, true) { AutoFlush = true };
                    file.Write(nodes.Children.ToString("ExtraAddon"));
                    file.Close();

                    if(File.Exists(filename2))
                    {
                        Log.Notice("ExtraAddonConfig", sLConsole.GetString("The backup has been deleted during the re-use."));
                        File.Delete(filename2);
                    }

                    Log.Success("ExtraAddonConfig", sLConsole.GetString("Config file is completed!"));
                }
                catch(Exception e)
                {
                    Log.Error("ExtraAddonConfig", sLConsole.GetString("Failure was handled during the xml writing. Details: {0}"), e.Message);
                }
            }

            return false;
        }
        private YamlNode Build()
        {
            var root = new YamlMappingNode();

            root.Add("from", _assetType);

            if (SelectFields.Count > 0)
            {
                var select = new YamlSequenceNode();

                var attributes = SelectFields.Where(s => s is string);
                foreach(var attr in attributes)
                {
                    var val = attr as string;
                    select.Add(val);
                }

                var nestedBuilders = SelectFields.Where(s => s is QueryApiQueryBuilder);
                foreach (var item in nestedBuilders)
                {
                    var nestedBuilder = item as QueryApiQueryBuilder;
                    select.Add(nestedBuilder.Build());
                }

                root.Add("select", select);
            }

            if (WhereCriteria.Count > 0)
            {
                var whereNodes = new YamlMappingNode();

                foreach (var criterion in WhereCriteria)
                {
                    whereNodes.Add(criterion.AttributeName, criterion.MatchValue.ToString());
                }

                root.Add("where", whereNodes);
            }

            if (FilterCriteria.Count > 0)
            {
                var filterNodes = new YamlSequenceNode();

                foreach (var criterion in FilterCriteria)
                {
                    filterNodes.Add($"{criterion.AttributeName}{criterion.Operator.Token}\"{criterion.MatchValue.ToString()}\"");
                }

                root.Add("filter", filterNodes);
            }

            return root;
        }
Beispiel #49
0
 private YamlMappingNode CreateCleanMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Config",   (!nodes.IsNull() && nodes.ContainsKey("Config")) ? nodes["Config".ToYamlNode()].ToString() : d_cleanconfig.ToString());
     map.Add("Database", (!nodes.IsNull() && nodes.ContainsKey("Database")) ? nodes["Database".ToYamlNode()].ToString() : d_cleandatabase.ToString());
     return map;
 }
Beispiel #50
0
 private YamlMappingNode CreateRssMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("QueryTime", (!nodes.IsNull() && nodes.ContainsKey("QueryTime")) ? nodes["QueryTime".ToYamlNode()].ToString() : d_querytime.ToString());
     return map;
 }
Beispiel #51
0
 private YamlMappingNode CreateAddonsMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Enabled",   (!nodes.IsNull() && nodes.ContainsKey("Enabled")) ? nodes["Enabled".ToYamlNode()].ToString() : d_addonenabled.ToString());
     map.Add("Ignore",    (!nodes.IsNull() && nodes.ContainsKey("Ignore")) ? nodes["Ignore".ToYamlNode()].ToString() : d_addonignore);
     map.Add("Directory", (!nodes.IsNull() && nodes.ContainsKey("Directory")) ? nodes["Directory".ToYamlNode()].ToString() : d_addondirectory);
     return map;
 }
Beispiel #52
0
        private YamlMappingNode CreateIrcMap(IDictionary<YamlNode, YamlNode> nodes)
        {
            var map = new YamlMappingNode();

            if(nodes.IsNull())
            {
                map.Add("ServerName",      d_servername);
                map.Add("Server",          d_server);
                map.Add("Password",        d_ircserverpassword);
                map.Add("Port",            d_port.ToString());
                map.Add("ModeMask",        d_modemask.ToString());
                map.Add("Ssl",             d_ssl.ToString());
                map.Add("NickName",        d_nickname);
                map.Add("NickName2",       d_nickname2);
                map.Add("NickName3",       d_nickname3);
                map.Add("UserName",        d_username);
                map.Add("UserInfo",        d_userinfo);
                var map2 = new YamlMappingNode();
                map2.Add("Name",           "\"" + d_masterchannel + "\"");
                map2.Add("Password",       d_masterchannelpassword);
                map.Add("MasterChannel",   map2);
                map.Add("IgnoreChannels",  d_ignorechannels);
                map.Add("IgnoreNames",     d_ignorenames);
                map2 = new YamlMappingNode();
                map2.Add("Enabled",        d_usenickserv.ToString());
                map2.Add("Password",       d_nickservpassword);
                map.Add("NickServ",        map2);
                map2 = new YamlMappingNode();
                map2.Add("Enabled",        d_usehostserv.ToString());
                map2.Add("Vhost",          d_hostservstatus.ToString());
                map.Add("HostServ",        map2);
                map2 = new YamlMappingNode();
                map2.Add("MessageSending", d_messagesending.ToString());
                map.Add("Wait",            map2);
                map2 = new YamlMappingNode();
                map2.Add("Prefix",         "\"" + d_commandprefix + "\"");
                map.Add("Command",         map2);
                map.Add("MessageType",     d_messagetype);
            }
            else
            {
                var node = nodes;
                map.Add("ServerName", (!node.IsNull() && node.ContainsKey("ServerName")) ? node["ServerName".ToYamlNode()].ToString() : d_servername);
                map.Add("Server",     (!node.IsNull() && node.ContainsKey("Server")) ? node["Server".ToYamlNode()].ToString() : d_server);
                map.Add("Password",   (!node.IsNull() && node.ContainsKey("Password")) ? node["Password".ToYamlNode()].ToString() : d_ircserverpassword);
                map.Add("Port",       (!node.IsNull() && node.ContainsKey("Port")) ? node["Port".ToYamlNode()].ToString() : d_port.ToString());
                map.Add("ModeMask",   (!node.IsNull() && node.ContainsKey("ModeMask")) ? node["ModeMask".ToYamlNode()].ToString() : d_modemask.ToString());
                map.Add("Ssl",        (!node.IsNull() && node.ContainsKey("Ssl")) ? node["Ssl".ToYamlNode()].ToString() : d_ssl.ToString());
                map.Add("NickName",   (!node.IsNull() && node.ContainsKey("NickName")) ? node["NickName".ToYamlNode()].ToString() : d_nickname);
                map.Add("NickName2",  (!node.IsNull() && node.ContainsKey("NickName2")) ? node["NickName2".ToYamlNode()].ToString() : d_nickname2);
                map.Add("NickName3",  (!node.IsNull() && node.ContainsKey("NickName3")) ? node["NickName3".ToYamlNode()].ToString() : d_nickname3);
                map.Add("UserName",   (!node.IsNull() && node.ContainsKey("UserName")) ? node["UserName".ToYamlNode()].ToString() : d_username);
                map.Add("UserInfo",   (!node.IsNull() && node.ContainsKey("UserInfo")) ? node["UserInfo".ToYamlNode()].ToString() : d_userinfo);

                var map2 = new YamlMappingNode();

                if(!node.IsNull() && node.ContainsKey("MasterChannel"))
                {
                    var node2 = ((YamlMappingNode)node["MasterChannel".ToYamlNode()]).Children;
                    map2.Add("Name",     "\"" + ((!node2.IsNull() && node2.ContainsKey("Name")) ? node2["Name".ToYamlNode()].ToString() : d_masterchannel) + "\"");
                    map2.Add("Password", (!node2.IsNull() && node2.ContainsKey("Password")) ? node2["Password".ToYamlNode()].ToString() : d_masterchannelpassword);
                }
                else
                {
                    map2.Add("Name",     "\"" + d_masterchannel + "\"");
                    map2.Add("Password", d_masterchannelpassword);
                }

                map.Add("MasterChannel",  map2);
                map.Add("IgnoreChannels", (!node.IsNull() && node.ContainsKey("IgnoreChannels")) ? node["IgnoreChannels".ToYamlNode()].ToString() : d_ignorechannels);
                map.Add("IgnoreNames",    (!node.IsNull() && node.ContainsKey("IgnoreNames")) ? node["IgnoreNames".ToYamlNode()].ToString() : d_ignorenames);
                map2 = new YamlMappingNode();

                if(!node.IsNull() && node.ContainsKey("NickServ"))
                {
                    var node2 = ((YamlMappingNode)node["NickServ".ToYamlNode()]).Children;
                    map2.Add("Enabled",  (!node2.IsNull() && node2.ContainsKey("Enabled")) ? node2["Enabled".ToYamlNode()].ToString() : d_usenickserv.ToString());
                    map2.Add("Password", (!node2.IsNull() && node2.ContainsKey("Password")) ? node2["Password".ToYamlNode()].ToString() : d_nickservpassword);
                }
                else
                {
                    map2.Add("Enabled",  d_usenickserv.ToString());
                    map2.Add("Password", d_nickservpassword);
                }

                map.Add("NickServ", map2);
                map2 = new YamlMappingNode();

                if(!node.IsNull() && node.ContainsKey("HostServ"))
                {
                    var node2 = ((YamlMappingNode)node["HostServ".ToYamlNode()]).Children;
                    map2.Add("Enabled", (!node2.IsNull() && node2.ContainsKey("Enabled")) ? node2["Enabled".ToYamlNode()].ToString() : d_usehostserv.ToString());
                    map2.Add("Vhost",   (!node2.IsNull() && node2.ContainsKey("Vhost")) ? node2["Vhost".ToYamlNode()].ToString() : d_hostservstatus.ToString());
                }
                else
                {
                    map2.Add("Enabled", d_usehostserv.ToString());
                    map2.Add("Vhost",   d_hostservstatus.ToString());
                }

                map.Add("HostServ", map2);
                map2 = new YamlMappingNode();

                if(!node.IsNull() && node.ContainsKey("Wait"))
                {
                    var node2 = ((YamlMappingNode)node["Wait".ToYamlNode()]).Children;
                    map2.Add("MessageSending", (!node2.IsNull() && node2.ContainsKey("MessageSending")) ? node2["MessageSending".ToYamlNode()].ToString() : d_messagesending.ToString());
                }
                else
                    map2.Add("MessageSending", d_messagesending.ToString());

                map.Add("Wait", map2);
                map2 = new YamlMappingNode();

                if(!node.IsNull() && node.ContainsKey("Command"))
                {
                    var node2 = ((YamlMappingNode)node["Command".ToYamlNode()]).Children;
                    map2.Add("Prefix", "\"" + ((!node2.IsNull() && node2.ContainsKey("Prefix")) ? node2["Prefix".ToYamlNode()].ToString() : d_commandprefix) + "\"");
                }
                else
                    map2.Add("Prefix", "\"" + d_commandprefix + "\"");

                map.Add("Command",     map2);
                map.Add("MessageType", (!node.IsNull() && node.ContainsKey("MessageType")) ? node["MessageType".ToYamlNode()].ToString() : d_messagetype);
            }

            return map;
        }
Beispiel #53
0
 private YamlMappingNode CreateSQLiteMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Enabled",  (!nodes.IsNull() && nodes.ContainsKey("Enabled")) ? nodes["Enabled".ToYamlNode()].ToString() : d_sqliteenabled.ToString());
     map.Add("FileName", (!nodes.IsNull() && nodes.ContainsKey("FileName")) ? nodes["FileName".ToYamlNode()].ToString() : d_sqlitefilename);
     return map;
 }
Beispiel #54
0
 private YamlMappingNode CreateLocalizationMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Locale", (!nodes.IsNull() && nodes.ContainsKey("Locale")) ? nodes["Locale".ToYamlNode()].ToString() : d_locale);
     return map;
 }
Beispiel #55
0
 private YamlMappingNode CreateLogMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("FileName",        (!nodes.IsNull() && nodes.ContainsKey("FileName")) ? nodes["FileName".ToYamlNode()].ToString() : d_logfilename);
     map.Add("DateFileName",    (!nodes.IsNull() && nodes.ContainsKey("DateFileName")) ? nodes["DateFileName".ToYamlNode()].ToString() : d_logdatefilename.ToString());
     map.Add("MaxFileSize",     (!nodes.IsNull() && nodes.ContainsKey("MaxFileSize")) ? nodes["MaxFileSize".ToYamlNode()].ToString() : d_logmaxfilesize.ToString());
     map.Add("LogLevel",        (!nodes.IsNull() && nodes.ContainsKey("LogLevel")) ? nodes["LogLevel".ToYamlNode()].ToString() : d_loglevel.ToString());
     map.Add("LogDirectory",    (!nodes.IsNull() && nodes.ContainsKey("LogDirectory")) ? nodes["LogDirectory".ToYamlNode()].ToString() : d_logdirectory);
     map.Add("IrcLogDirectory", (!nodes.IsNull() && nodes.ContainsKey("IrcLogDirectory")) ? nodes["IrcLogDirectory".ToYamlNode()].ToString() : d_irclogdirectory);
     map.Add("IrcLog",          (!nodes.IsNull() && nodes.ContainsKey("IrcLog")) ? nodes["IrcLog".ToYamlNode()].ToString() : d_irclog.ToString());
     return map;
 }
Beispiel #56
0
 private YamlMappingNode CreateUpdateMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Enabled", (!nodes.IsNull() && nodes.ContainsKey("Enabled")) ? nodes["Enabled".ToYamlNode()].ToString() : d_updateenabled.ToString());
     map.Add("Version", (!nodes.IsNull() && nodes.ContainsKey("Version")) ? nodes["Version".ToYamlNode()].ToString() : d_updateversion);
     map.Add("Branch",  (!nodes.IsNull() && nodes.ContainsKey("Branch")) ? nodes["Branch".ToYamlNode()].ToString() : d_updatebranch);
     map.Add("WebPage", (!nodes.IsNull() && nodes.ContainsKey("WebPage")) ? nodes["WebPage".ToYamlNode()].ToString() : d_updatewebpage);
     return map;
 }
Beispiel #57
0
            protected override void UpgradeAsset(AssetMigrationContext context, int currentVersion, int targetVersion, dynamic asset, PackageLoadingAssetFile assetFile)
            {
                var hierarchy = asset.Hierarchy;
                var entities = (DynamicYamlArray)hierarchy.Entities;
                foreach (dynamic entity in entities)
                {
                    var components = entity.Components;
                    var physComponent = components["PhysicsComponent.Key"];
                    if (physComponent != null)
                    {
                        foreach (dynamic element in physComponent.Elements)
                        {
                            var index = element.IndexOf("Shape");
                            if (index == -1) continue;

                            dynamic shapeId = element.Shape;
                            element.ColliderShapes = new DynamicYamlArray(new YamlSequenceNode());
                            dynamic subnode = new YamlMappingNode { Tag = "!ColliderShapeAssetDesc" };
                            subnode.Add("Shape", shapeId.Node.Value);
                            element.ColliderShapes.Add(subnode);

                            element.RemoveChild("Shape");
                        }
                    }
                }
            }
Beispiel #58
0
 private YamlMappingNode CreateMySqlMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Enabled",  (!nodes.IsNull() && nodes.ContainsKey("Enabled")) ? nodes["Enabled".ToYamlNode()].ToString() : d_mysqlenabled.ToString());
     map.Add("Host",     (!nodes.IsNull() && nodes.ContainsKey("Host")) ? nodes["Host".ToYamlNode()].ToString() : d_mysqlhost);
     map.Add("Port",     (!nodes.IsNull() && nodes.ContainsKey("Port")) ? nodes["Port".ToYamlNode()].ToString() : d_mysqlport.ToString());
     map.Add("User",     (!nodes.IsNull() && nodes.ContainsKey("User")) ? nodes["User".ToYamlNode()].ToString() : d_mysqluser);
     map.Add("Password", (!nodes.IsNull() && nodes.ContainsKey("Password")) ? nodes["Password".ToYamlNode()].ToString() : d_mysqlpassword);
     map.Add("Database", (!nodes.IsNull() && nodes.ContainsKey("Database")) ? nodes["Database".ToYamlNode()].ToString() : d_mysqldatabase);
     map.Add("Charset",  (!nodes.IsNull() && nodes.ContainsKey("Charset")) ? nodes["Charset".ToYamlNode()].ToString() : d_mysqlcharset);
     return map;
 }
Beispiel #59
0
 private YamlMappingNode CreateScriptsMap(IDictionary<YamlNode, YamlNode> nodes)
 {
     var map = new YamlMappingNode();
     map.Add("Lua",       (!nodes.IsNull() && nodes.ContainsKey("Lua")) ? nodes["Lua".ToYamlNode()].ToString() : d_scriptsluaenabled.ToString());
     map.Add("Python",    (!nodes.IsNull() && nodes.ContainsKey("Python")) ? nodes["Python".ToYamlNode()].ToString() : d_scriptspythonenabled.ToString());
     map.Add("Directory", (!nodes.IsNull() && nodes.ContainsKey("Directory")) ? nodes["Directory".ToYamlNode()].ToString() : d_scriptsdirectory);
     return map;
 }
Beispiel #60
0
        private YamlMappingNode CreateSchumixsMap(IDictionary<YamlNode, YamlNode> nodes)
        {
            var map = new YamlMappingNode();

            if(nodes.IsNull())
            {
                var map2 = new YamlMappingNode();
                map2.Add("File",            d_schumixfile);
                map2.Add("Directory",       d_schumixdirectory);
                map2.Add("ConsoleEncoding", d_schumixconsoleencoding);
                map2.Add("Locale",          d_schumixlocale);
                map.Add("Config",           map2);
            }
            else
            {
                var map2 = new YamlMappingNode();

                if(!nodes.IsNull() && nodes.ContainsKey("Config"))
                {
                    var node2 = ((YamlMappingNode)nodes["Config".ToYamlNode()]).Children;
                    map2.Add("File",            (!node2.IsNull() && node2.ContainsKey("File")) ? node2["File".ToYamlNode()].ToString() : d_schumixfile);
                    map2.Add("Directory",       (!node2.IsNull() && node2.ContainsKey("Directory")) ? node2["Directory".ToYamlNode()].ToString() : d_schumixdirectory);
                    map2.Add("ConsoleEncoding", (!node2.IsNull() && node2.ContainsKey("ConsoleEncoding")) ? node2["ConsoleEncoding".ToYamlNode()].ToString() : d_schumixconsoleencoding);
                    map2.Add("Locale",          (!node2.IsNull() && node2.ContainsKey("Locale")) ? node2["Locale".ToYamlNode()].ToString() : d_schumixlocale);
                }
                else
                {
                    map2.Add("File",            d_schumixfile);
                    map2.Add("Directory",       d_schumixdirectory);
                    map2.Add("ConsoleEncoding", d_schumixconsoleencoding);
                    map2.Add("Locale",          d_schumixlocale);
                }

                map.Add("Config", map2);
            }

            return map;
        }