System.Enum.GetName(System.Type, object)

Here are the examples of the csharp api System.Enum.GetName(System.Type, object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1422 Examples 7

19 View Source File : Message.cs
License : zlib License
Project Creator : 0x0ade

public static string MsgToString(int msg) {
            if (Enum.IsDefined(typeof(Messages), msg))
                return Enum.GetName(typeof(Messages), msg);

            if (((msg & (int) Messages.WM_REFLECT) == (int) Messages.WM_REFLECT)) {
                string subtext = MsgToString(msg & (int) ~Messages.WM_REFLECT);
                if (subtext == null) subtext = "???";
                return "WM_REFLECT + " + subtext;
            }

            return null;
        }

19 View Source File : XnaToFnaUtil.Processor.cs
License : zlib License
Project Creator : 0x0ade

public OpCode ShortToLongOp(OpCode op) {
            string name = Enum.GetName(typeof(Code), op.Code);
            if (!name.EndsWith("_S"))
                return op;
            return (OpCode?) typeof(OpCodes).GetField(name.Substring(0, name.Length - 2))?.GetValue(null) ?? op;
        }

19 View Source File : XnaToFnaUtil.Processor.cs
License : zlib License
Project Creator : 0x0ade

public OpCode LongToShortOp(OpCode op) {
            string name = Enum.GetName(typeof(Code), op.Code);
            if (name.EndsWith("_S"))
                return op;
            return (OpCode?) typeof(OpCodes).GetField(name + "_S")?.GetValue(null) ?? op;
        }

19 View Source File : Client.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen

private void RdpConnectionOnOnLogonError(object sender, IMsTscAxEvents_OnLogonErrorEvent e)
        {
            LogonErrorCode = e.lError;
            var errorstatus = Enum.GetName(typeof(LogonErrors), (uint)LogonErrorCode);
            Console.WriteLine("[-] Logon Error           :  {0} - {1}", LogonErrorCode, errorstatus);
            Thread.Sleep(1000);

            if(LogonErrorCode == -5 && takeover == true)
            {
                // it doesn't go to the logon event, so this has to be done here
                var rdpSession = (AxMsRdpClient9NotSafeForScripting)sender;
                Thread.Sleep(1000);
                keydata = (IMsRdpClientNonScriptable)rdpSession.GetOcx();
                Console.WriteLine("[+] Another user is logged on, asking to take over session");
                SendElement("Tab");
                Thread.Sleep(500);
                SendElement("Enter+down");
                Thread.Sleep(500);
                SendElement("Enter+up");
                Thread.Sleep(500);
                Console.WriteLine("[+] Sleeping for 30 seconds");
                Task.Delay(31000).GetAwaiter().GetResult();
                Marshal.ReleaseComObject(rdpSession);
                Marshal.ReleaseComObject(keydata);
            }
            else if (LogonErrorCode != -2)
            {
                Environment.Exit(0);
            }
        }

19 View Source File : Client.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 0xthirteen

private void RdpConnectionOnOnDisconnected(object sender, IMsTscAxEvents_OnDisconnectedEvent e)
        {
            DisconnectCode = e.discReason;
            var dire = Enum.GetName(typeof(DisconnectReasons), (uint)DisconnectCode);
            Console.WriteLine("[+] Connection closed     :  {0}", target);
            if(e.discReason != 1)
            {
                Console.WriteLine("[-] Disconnection Reason  :  {0} - {1}", DisconnectCode, dire);
            }
            Environment.Exit(0);
        }

19 View Source File : UserManager.cs
License : MIT License
Project Creator : 404Lcc

public void InitManager()
        {
            AudioManager.Instance.SetVolume(GameDataManager.Instance.userSetData.audio, Objects.AudioSource);
            string name = Enum.GetName(typeof(ResolutionType), GameDataManager.Instance.userSetData.resolutionType).Substring(10);
            int width = int.Parse(name.Substring(0, name.IndexOf('x')));
            int height = int.Parse(name.Substring(name.IndexOf('x') + 1));
            if (GameDataManager.Instance.userSetData.displayModeType == DisplayModeType.FullScreen)
            {
                LccUtil.SetResolution(true, width, height);
            }
            else if (GameDataManager.Instance.userSetData.displayModeType == DisplayModeType.Window)
            {
                LccUtil.SetResolution(false, width, height);
            }
            else if (GameDataManager.Instance.userSetData.displayModeType == DisplayModeType.BorderlessWindow)
            {
                LccUtil.SetResolution(false, width, height);
                StartCoroutine(DisplayMode.SetNoFrame(width, height));
            }
            QualitySettings.SetQualityLevel(6, true);
        }

19 View Source File : JsonExtension.cs
License : MIT License
Project Creator : 4egod

public static string ToEnumString<T>(this T type)
        {
            var enumType = typeof (T);
            var name = Enum.GetName(enumType, type);
            var enumMemberAttribute = ((EnumMemberAttribute[])enumType.GetField(name).GetCustomAttributes(typeof(EnumMemberAttribute), true)).Single();
            return enumMemberAttribute.Value;
        }

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public static BitfinexPublicTickerGet GetPublicTicker(BtcInfo.PairTypeEnum pairType, BtcInfo.BitfinexUnauthenicatedCallsEnum callType)
		{
			var call = Enum.GetName(typeof(BtcInfo.BitfinexUnauthenicatedCallsEnum), callType);
			var symbol = Enum.GetName(typeof(BtcInfo.PairTypeEnum), pairType);
			var url = @"/v1/" + call.ToLower(CultureInfo.InvariantCulture) + "/" + symbol.ToLower(CultureInfo.InvariantCulture);
			var response = WebApi.GetBaseResponse(url);

			var publicticketResponseObj = JsonConvert.DeserializeObject<BitfinexPublicTickerGet>(response);
			Log.Info("Ticker: {0}", publicticketResponseObj);

			return publicticketResponseObj;
		}

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public static IList<BitfinexSymbolStatsResponse> GetPairStats(BtcInfo.PairTypeEnum pairType, BtcInfo.BitfinexUnauthenicatedCallsEnum callType)
		{
			var call = Enum.GetName(typeof(BtcInfo.BitfinexUnauthenicatedCallsEnum), callType);
			var symbol = Enum.GetName(typeof(BtcInfo.PairTypeEnum), pairType);
			var url = @"/v1/" + call.ToLower(CultureInfo.InvariantCulture) + "/" + symbol.ToLower(CultureInfo.InvariantCulture);
			var response = WebApi.GetBaseResponse(url);

			var symbolStatsResponseObj = JsonConvert.DeserializeObject<IList<BitfinexSymbolStatsResponse>>(response);

			foreach (var symbolStatsResponse in symbolStatsResponseObj)
				Log.Info("Pair Stats: {0}", symbolStatsResponse);

			return symbolStatsResponseObj;
		}

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public static IList<BitfinexTradesGet> GetPairTrades(BtcInfo.PairTypeEnum pairType, BtcInfo.BitfinexUnauthenicatedCallsEnum callType)
		{
			var call = Enum.GetName(typeof(BtcInfo.BitfinexUnauthenicatedCallsEnum), callType);
			var symbol = Enum.GetName(typeof(BtcInfo.PairTypeEnum), pairType);
			var url = @"/v1/" + call.ToLower(CultureInfo.InvariantCulture) + "/" + symbol.ToLower(CultureInfo.InvariantCulture);
			var response = WebApi.GetBaseResponse(url);

			var pairTradesResponseObj = JsonConvert.DeserializeObject<IList<BitfinexTradesGet>>(response);

			foreach (var pairTrade in pairTradesResponseObj)
				Log.Info("Pair Trade: {0}", pairTrade);

			return pairTradesResponseObj;
		}

19 View Source File : WexPair.cs
License : MIT License
Project Creator : aabiryukov

public static string ToString(WexPair v) {
			return Enum.GetName(typeof(WexPair), v).ToLowerInvariant();
		}

19 View Source File : BitfinexApi.cs
License : MIT License
Project Creator : aabiryukov

public static BitfinexOrderBookGet GetOrderBook(BtcInfo.PairTypeEnum pairType, int limitBids = 30, int limitAsks = 30)
		{
			try
			{
				var url = DepthOfBookRequestUrl + Enum.GetName(typeof(BtcInfo.PairTypeEnum), pairType);
				var response = WebApi.GetBaseResponse(url + string.Format("?limit_bids={0};limit_asks={1}", limitBids, limitAsks));
				var orderBookResponseObj = JsonConvert.DeserializeObject<BitfinexOrderBookGet>(response);
				return orderBookResponseObj;
			}
			catch (Exception ex)
			{
				Log.Error(ex);
				return new BitfinexOrderBookGet();
			}
		}

19 View Source File : TradeType.cs
License : MIT License
Project Creator : aabiryukov

public static string ToString(TradeType tradeType) {
			return Enum.GetName(typeof(TradeType), tradeType).ToLowerInvariant();
		}

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public int PlaceOrder(double price, double amount, MarketType market)
        {
            string regPrice = "", regAmount = "", method = "", mParams = "";
            switch (market)
            {
                case MarketType.BTCCNY:
					regPrice = price.ToString("F2", CultureInfo.InvariantCulture);
					regAmount = amount.ToString("F4", CultureInfo.InvariantCulture);
                    break;
                case MarketType.LTCCNY:
					regPrice = price.ToString("F2", CultureInfo.InvariantCulture);
					regAmount = amount.ToString("F3", CultureInfo.InvariantCulture);
                    break;
                case MarketType.LTCBTC:
					regPrice = price.ToString("F4", CultureInfo.InvariantCulture);
					regAmount = amount.ToString("F3", CultureInfo.InvariantCulture);
                    break;
                default://"ALL" is not supported
                    throw new BTCChinaException("PlaceOrder", "N/A", "Market not supported.");
            }
            if (regPrice.StartsWith("-", StringComparison.Ordinal))
                regPrice = "null";
			if (regAmount.StartsWith("-", StringComparison.Ordinal))
            {
                regAmount = regAmount.TrimStart('-');
                method = "sellOrder2";
            }
            else
            {
                method = "buyOrder2";
            }

//          mParams = regPrice + "," + regAmount;
            mParams = "\"" + regPrice + "\",\"" + regAmount + "\"";
            //not default market
            if (market != MarketType.BTCCNY)
                mParams += ",\"" + System.Enum.GetName(typeof(MarketType), market) + "\"";

            var response = DoMethod(BuildParams(method, mParams));
	        var jsonObject = JObject.Parse(response);
	        var orderId = jsonObject.Value<int>("result");

	        return orderId;
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public bool cancelOrder(int orderID, MarketType market=MarketType.BTCCNY)
        {
            const string method = "cancelOrder";
            string mParams = orderID.ToString(CultureInfo.InvariantCulture);
            //all is not supported
            if (market == MarketType.ALL)
                throw new BTCChinaException(method, "N/A", "Market:ALL is not supported.");
            //not default market
            if (market != MarketType.BTCCNY)
                mParams += ",\"" + System.Enum.GetName(typeof(MarketType), market) + "\"";

            var response = DoMethod(BuildParams(method, mParams));
			var jsonObject = JObject.Parse(response);
			var success = jsonObject.Value<bool>("result");

	        return success;
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public string getDeposits(CurrencyType currency, bool pendingonly = true)
        {
            const string method = "getDeposits";
            string mParams = "\"" + System.Enum.GetName(typeof(CurrencyType), currency) + "\"";
            if (!pendingonly)
                mParams += "," + pendingonly.ToString(CultureInfo.InvariantCulture).ToLowerInvariant();
            return DoMethod(BuildParams(method, mParams));
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public string getWithdrawals(CurrencyType currency, bool pendingonly = true)
        {
            const string method = "getWithdrawals";
            string mParams = "\"" + System.Enum.GetName(typeof(CurrencyType), currency) + "\"";
            if (!pendingonly)
				mParams += "," + pendingonly.ToString(CultureInfo.InvariantCulture).ToLowerInvariant();
            return DoMethod(BuildParams(method, mParams));
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public string getMarketDepth(uint limit = 10, MarketType markets = MarketType.BTCCNY)
        {
            const string method = "getMarketDepth2";
            string mParams = "";
			if (limit != 10) mParams = limit.ToString(CultureInfo.InvariantCulture);
            if (markets != MarketType.BTCCNY)
                mParams += ",\"" + System.Enum.GetName(typeof(MarketType), markets) + "\"";
            return DoMethod(BuildParams(method, mParams));
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public string getWithdrawal(int withdrawalID, CurrencyType currency = CurrencyType.BTC)
        {
            const string method = "getWithdrawal";
			string mParams = withdrawalID.ToString(CultureInfo.InvariantCulture);
            if (currency != CurrencyType.BTC)
                mParams += ",\"" + System.Enum.GetName(typeof(CurrencyType), currency) + "\"";//should be "LTC" but for further implmentations
            return DoMethod(BuildParams(method, mParams));
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public string requestWithdrawal(CurrencyType currency, double amount)
        {
            if (amount <= 0)
                throw new BTCChinaException("requestWithdrawal", "N/A", "withdrawal amount cannot be negative nor zero");
            const string method = "requestWithdrawal";
            string mParams = "\"" + System.Enum.GetName(typeof(CurrencyType), currency) + "\"," + amount.ToString("F3", CultureInfo.InvariantCulture);
            return DoMethod(BuildParams(method, mParams));
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public string getOrder(uint orderID, MarketType markets = MarketType.BTCCNY)
        {
            if (markets == MarketType.ALL)
                throw new BTCChinaException("getOrder", "N/A", "Market: ALL is not supported.");
            else
            {
                const string method = "getOrder";
				string mParams = orderID.ToString(CultureInfo.InvariantCulture);
                if (markets != MarketType.BTCCNY)
                    mParams += ",\"" + System.Enum.GetName(typeof(MarketType), markets) + "\"";
                return DoMethod(BuildParams(method, mParams));
            }
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public IEnumerable<Order> getOrders(bool openonly = true, MarketType markets = MarketType.BTCCNY, uint limit = 1000, uint offset = 0, bool withdetails = false)
        {
            //due to the complexity of parameters, all default values are explicitly set.
            const string method = "getOrders";
			string mParams = openonly.ToString(CultureInfo.InvariantCulture).ToLowerInvariant() +
                ",\"" + System.Enum.GetName(typeof(MarketType), markets) + "\"," +
				limit.ToString(CultureInfo.InvariantCulture) + "," +
				offset.ToString(CultureInfo.InvariantCulture) + "," +
				withdetails.ToString(CultureInfo.InvariantCulture).ToLowerInvariant();
            var response = DoMethod(BuildParams(method, mParams));

			var jobj = JObject.Parse(response);
			if (jobj["result"] != null)
			{
				var orders = jobj["result"]["order"];
				foreach (var orderItem in orders)
				{
					var order = Order.ReadFromJObject(orderItem);
					yield return order;
				}
			};
        }

19 View Source File : BTCChinaAPI.cs
License : MIT License
Project Creator : aabiryukov

public string getTransactions(TransactionType transaction = TransactionType.all, uint limit = 10, uint offset = 0)
        {
            //likewise, set all parameters
            const string method = "getTransactions";
            string mParams = "\"" + System.Enum.GetName(typeof(TransactionType), transaction) + "\","
				+ limit.ToString(CultureInfo.InvariantCulture) + ","
				+ offset.ToString(CultureInfo.InvariantCulture);
            return DoMethod(BuildParams(method, mParams));
        }

19 View Source File : SolverHandlerInspector.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

public override void OnInspectorGUI()
        {
            serializedObject.Update();

            if (target != null)
            {
                InspectorUIUtility.RenderHelpURL(target.GetType());
            }

            bool trackedObjectChanged = false;

            EditorGUI.BeginChangeCheck();

            InspectorUIUtility.DrawEnumSerializedProperty(trackedTargetProperty, TrackedTypeLabel, solverHandler.TrackedTargetType);

            if (!SolverHandler.IsValidTrackedObjectType(solverHandler.TrackedTargetType))
            {
                InspectorUIUtility.DrawWarning(" Current Tracked Target Type value of \"" 
                    + Enum.GetName(typeof(TrackedObjectType), solverHandler.TrackedTargetType) 
                    + "\" is obsolete. Select MotionController or HandJoint values instead");
            }

            if (trackedTargetProperty.enumValueIndex == (int)TrackedObjectType.HandJoint ||
                trackedTargetProperty.enumValueIndex == (int)TrackedObjectType.ControllerRay)
            {
                EditorGUILayout.PropertyField(trackedHandnessProperty);
                if (trackedHandnessProperty.enumValueIndex > (int)Handedness.Both)
                {
                    InspectorUIUtility.DrawWarning("Only Handedness values of None, Left, Right, and Both are valid");
                }
            }

            if (trackedTargetProperty.enumValueIndex == (int)TrackedObjectType.HandJoint)
            {
                EditorGUILayout.PropertyField(trackedHandJointProperty);
            }
            else if (trackedTargetProperty.enumValueIndex == (int)TrackedObjectType.CustomOverride)
            {
                EditorGUILayout.PropertyField(transformOverrideProperty);
            }

            EditorGUILayout.PropertyField(additionalOffsetProperty);
            EditorGUILayout.PropertyField(additionalRotationProperty);

            trackedObjectChanged = EditorGUI.EndChangeCheck();

            EditorGUILayout.PropertyField(updateSolversProperty);

            serializedObject.ApplyModifiedProperties();

            if (EditorApplication.isPlaying && trackedObjectChanged)
            {
                solverHandler.RefreshTrackedObject();
            }
        }

19 View Source File : EnumValueToStringConverter.cs
License : MIT License
Project Creator : ABTSoftware

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Enum.GetName(value.GetType(), value);
        }

19 View Source File : RemoteCommand.cs
License : Apache License 2.0
Project Creator : acblog

public override async Task<int> Handle(CArgument argument, IHost host, CancellationToken cancellationToken)
        {
            Workspace workspace = host.Services.GetRequiredService<Workspace>();
            if (argument.Current is null)
            {
                Console.WriteLine($"Current: {workspace.Option.CurrentRemote}");
                foreach (var item in workspace.Option.Remotes.Values)
                {
                    Console.WriteLine($"{item.Name} ({Enum.GetName(typeof(RemoteType), item.Type)}): {item.Uri}");
                }
            }
            else
            {
                workspace.Option.CurrentRemote = argument.Current;
                await workspace.Save();
            }
            return 0;
        }

19 View Source File : Workspace.cs
License : Apache License 2.0
Project Creator : acblog

public async Task Connect(string name = "")
        {
            if (string.IsNullOrEmpty(name))
                name = Option.CurrentRemote;

            Logger.LogInformation($"Connect to remote {name}.");

            if (Option.Remotes.TryGetValue(name, out var remote))
            {
                Logger.LogInformation($"Detect remote {remote.Name} ({Enum.GetName(typeof(RemoteType), remote.Type)}).");
                switch (remote.Type)
                {
                    case RemoteType.LocalFS:
                        Remote = new FileSystemBlogService(
                            new PhysicalFileProvider(remote.Uri).AsFileProvider());
                        break;
                    case RemoteType.RemoteFS:
                        {
                            var client = HttpClientFactory.CreateClient();
                            client.BaseAddress = new Uri(remote.Uri);
                            Remote = new FileSystemBlogService(
                                new HttpFileProvider(client));
                        }
                        break;
                    case RemoteType.Api:
                        {
                            var client = HttpClientFactory.CreateClient();
                            client.BaseAddress = new Uri(remote.Uri);
                            Remote = new ApiBlogService(client);
                        }
                        break;
                    case RemoteType.Git:
                        {
                            FSBuilder builder = new FSBuilder(Environment.CurrentDirectory);

                            Logger.LogInformation("Pull git repository.");

                            try
                            {
                                using var repo = new Repository(GitTempFolder);
                                // Credential information to fetch
                                LibGit2Sharp.PullOptions options = new LibGit2Sharp.PullOptions();

                                // User information to create a merge commit
                                var signature = new LibGit2Sharp.Signature(
                                    new Idenreplacedy("AcBlog.Tools.Sdk", "[email protected]"), DateTimeOffset.Now);

                                // Pull
                                LibGit2Sharp.Commands.Pull(repo, signature, options);
                            }
                            catch
                            {
                                builder.EnsureDirectoryEmpty(GitTempFolder);
                                Repository.Clone(remote.Uri, GitTempFolder);
                            }

                            Remote = new FileSystemBlogService(
                                new PhysicalFileProvider(Path.Join(Environment.CurrentDirectory, GitTempFolder)).AsFileProvider());
                        }
                        break;
                }
                // TODO: sub-service 's token
                Remote.Context.Token = remote.Token;

                Option.CurrentRemote = name;
                await SaveOption();
            }
            else
            {
                throw new Exception("No remote");
            }
        }

19 View Source File : Workspace.cs
License : Apache License 2.0
Project Creator : acblog

public async Task Push(string name = "", bool full = false)
        {
            if (string.IsNullOrEmpty(name))
                name = Option.CurrentRemote;

            Logger.LogInformation($"Push to remote {name}.");

            if (Option.Remotes.TryGetValue(name, out var remote))
            {
                Logger.LogInformation($"Detect remote {remote.Name} ({Enum.GetName(typeof(RemoteType), remote.Type)}).");
                switch (remote.Type)
                {
                    case RemoteType.LocalFS:
                        {
                            await toLocalFS(remote);
                        }
                        break;
                    case RemoteType.RemoteFS:
                        {
                            throw new NotSupportedException("Not support pushing to remote file system, please push to local file system and sync to remote.");
                        }
                    case RemoteType.Api:
                        {
                            await Connect(name);

                            Logger.LogInformation($"Fetch remote posts.");

                            await Remote.SetOptions(await Local.GetOptions());

                            await SyncRecordRepository(Local.PostService, Remote.PostService, full);

                            await SyncRecordRepository(Local.PageService, Remote.PageService, full);

                            await SyncRecordRepository(Local.LayoutService, Remote.LayoutService, full);
                        }
                        break;
                    case RemoteType.Git:
                        {
                            await Connect(name);

                            string tempDist = Path.Join(Environment.CurrentDirectory, "temp/dist");

                            Logger.LogInformation("Generate data.");

                            await toLocalFS(new RemoteOption
                            {
                                Uri = tempDist,
                                Type = RemoteType.LocalFS,
                                Name = remote.Name
                            });

                            FSExtensions.CopyDirectory(tempDist, GitTempFolder);

                            Logger.LogInformation("Load git config.");

                            string userName = Option.Properties[$"remote.{remote.Name}.git.username"],
                                preplacedword = Option.Properties[$"remote.{remote.Name}.git.preplacedword"];

                            {
                                if (string.IsNullOrEmpty(userName))
                                    userName = ConsoleExtensions.Input("Input username: ");
                                if (string.IsNullOrEmpty(preplacedword))
                                    preplacedword = ConsoleExtensions.InputPreplacedword("Input preplacedword: ");
                            }

                            using (var repo = new Repository(GitTempFolder))
                            {
                                Logger.LogInformation("Commit to git.");

                                LibGit2Sharp.Commands.Stage(repo, "*");

                                var signature = new LibGit2Sharp.Signature(
                                        new Idenreplacedy("AcBlog.Tools.Sdk", "[email protected]"), DateTimeOffset.Now);
                                repo.Commit(DateTimeOffset.Now.ToString(), signature, signature, new CommitOptions
                                {
                                    AllowEmptyCommit = true
                                });

                                Logger.LogInformation($"Push to {repo.Head.RemoteName}.");

                                PushOptions options = new PushOptions
                                {
                                    CredentialsProvider = new CredentialsHandler(
                                    (url, usernameFromUrl, types) =>
                                        new UsernamePreplacedwordCredentials()
                                        {
                                            Username = string.IsNullOrEmpty(userName) ? usernameFromUrl : userName,
                                            Preplacedword = preplacedword
                                        })
                                };
                                repo.Network.Push(repo.Head, options);
                            }
                        }
                        break;
                }
            }
            else
            {
                throw new Exception("No remote");
            }

            async Task toLocalFS(RemoteOption remote)
            {
                FSBuilder fsBuilder = new FSBuilder(remote.Uri);
                fsBuilder.EnsureDirectoryEmpty();

                List<Post> posts = new List<Post>();
                await foreach (var item in Local.PostService.GetAllItems().IgnoreNull())
                {
                    Logger.LogInformation($"Loaded Post {item.Id}: {item.replacedle}");
                    posts.Add(item);
                }

                List<Layout> layouts = new List<Layout>();
                await foreach (var item in Local.LayoutService.GetAllItems().IgnoreNull())
                {
                    Logger.LogInformation($"Loaded Layout {item.Id}");
                    layouts.Add(item);
                }

                List<Page> pages = new List<Page>();
                await foreach (var item in Local.PageService.GetAllItems().IgnoreNull())
                {
                    Logger.LogInformation($"Loaded Page {item.Id}: {item.replacedle}");
                    pages.Add(item);
                }

                var baseAddress = Option.Properties[$"remote.{remote.Name}.generator.baseAddress"];

                List<Data.Models.File> files = new List<Data.Models.File>();
                {
                    string path = Path.Join(Environment.CurrentDirectory, replacedetsPath);
                    if (Directory.Exists(path))
                    {
                        foreach (var file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories))
                        {
                            var id = Path.GetRelativePath(Environment.CurrentDirectory, file).Replace('\\', '/');
                            Data.Models.File f = new Data.Models.File
                            {
                                Id = id,
                                Uri = string.IsNullOrWhiteSpace(baseAddress) ? $"/{id}" : $"{baseAddress.TrimEnd('/')}/{id}"
                            };
                            files.Add(f);
                        }
                    }
                }

                Logger.LogInformation("Build data.");
                {
                    BlogOptions options = await Local.GetOptions();
                    BlogBuilder builder = new BlogBuilder(options, Path.Join(remote.Uri));
                    await builder.Build();
                    await builder.BuildPosts(posts);
                    await builder.BuildLayouts(layouts);
                    await builder.BuildPages(pages);
                    await builder.BuildFiles(files);
                }

                {
                    if (!string.IsNullOrEmpty(baseAddress))
                    {
                        Logger.LogInformation("Build sitemap.");
                        var sub = fsBuilder.CreateSubDirectoryBuilder("Site");
                        {
                            var siteMapBuilder = await Local.BuildSitemap(baseAddress);
                            await using var st = sub.GetFileRewriteStream("sitemap.xml");
                            await using var writer = XmlWriter.Create(st, new XmlWriterSettings { Async = true });
                            siteMapBuilder.Build().WriteTo(writer);
                        }
                        Logger.LogInformation("Build feed.");
                        {
                            var feed = await Local.BuildSyndication(baseAddress);
                            await using (var st = sub.GetFileRewriteStream("atom.xml"))
                            {
                                await using var writer = XmlWriter.Create(st, new XmlWriterSettings { Async = true });
                                feed.GetAtom10Formatter().WriteTo(writer);
                            }
                            await using (var st = sub.GetFileRewriteStream("rss.xml"))
                            {
                                await using var writer = XmlWriter.Create(st, new XmlWriterSettings { Async = true });
                                feed.GetRss20Formatter().WriteTo(writer);
                            }
                        }
                    }
                }
                {
                    string replacedetsPath = Path.Join(Environment.CurrentDirectory, replacedetsPath);
                    if (Directory.Exists(replacedetsPath))
                    {
                        Logger.LogInformation("Copy replacedets.");
                        FSExtensions.CopyDirectory(replacedetsPath, Path.Join(remote.Uri, replacedetsPath));
                    }
                }
            }
        }

19 View Source File : BiotaSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(Biota input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `biota` (`id`, `weenie_Clreplaced_Id`, `weenie_Type`, `populated_Collection_Flags`)");

            // Default to all flags if none are set
            var output = $"VALUES ({input.Id}, {input.WeenieClreplacedId}, {input.WeenieType}, {(input.PopulatedCollectionFlags != 0 ? input.PopulatedCollectionFlags : 4294967295)}) /* {Enum.GetName(typeof(WeenieType), input.WeenieType)} */;";

            output = FixNullFields(output);

            writer.WriteLine(output);

            if (input.BiotaPropertiesInt != null && input.BiotaPropertiesInt.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesInt.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.BiotaPropertiesInt64 != null && input.BiotaPropertiesInt64.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesInt64.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.BiotaPropertiesBool != null && input.BiotaPropertiesBool.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesBool.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.BiotaPropertiesFloat != null && input.BiotaPropertiesFloat.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesFloat.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.BiotaPropertiesString != null && input.BiotaPropertiesString.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesString.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.BiotaPropertiesDID != null && input.BiotaPropertiesDID.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesDID.OrderBy(r => r.Type).ToList(), writer);
            }

            if (input.BiotaPropertiesPosition != null && input.BiotaPropertiesPosition.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesPosition.OrderBy(r => r.PositionType).ToList(), writer);
            }

            if (input.BiotaPropertiesIID != null && input.BiotaPropertiesIID.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesIID.OrderBy(r => r.Type).ToList(), writer);
            }

            if (input.BiotaPropertiesAttribute != null && input.BiotaPropertiesAttribute.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesAttribute.OrderBy(r => r.Type).ToList(), writer);
            }
            if (input.BiotaPropertiesAttribute2nd != null && input.BiotaPropertiesAttribute2nd.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesAttribute2nd.OrderBy(r => r.Type).ToList(), writer);
            }

            if (input.BiotaPropertiesSkill != null && input.BiotaPropertiesSkill.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesSkill.OrderBy(r => r.Type).ToList(), writer);
            }

            if (input.BiotaPropertiesBodyPart != null && input.BiotaPropertiesBodyPart.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesBodyPart.OrderBy(r => r.Key).ToList(), writer);
            }

            if (input.BiotaPropertiesSpellBook != null && input.BiotaPropertiesSpellBook.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesSpellBook.OrderBy(r => r.Spell).ToList(), writer);
            }

            if (input.BiotaPropertiesEventFilter != null && input.BiotaPropertiesEventFilter.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesEventFilter.OrderBy(r => r.Event).ToList(), writer);
            }

            if (input.BiotaPropertiesEmote != null && input.BiotaPropertiesEmote.Count > 0)
            {
                //writer.WriteLine(); // This is not needed because CreateSQLINSERTStatement will take care of it for us on each Recipe.
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesEmote.OrderBy(r => r.Category).ToList(), writer);
            }

            if (input.BiotaPropertiesCreateList != null && input.BiotaPropertiesCreateList.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesCreateList.OrderBy(r => r.DestinationType).ToList(), writer);
            }

            if (input.BiotaPropertiesBook != null)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesBook, writer);
            }
            if (input.BiotaPropertiesBookPageData != null && input.BiotaPropertiesBookPageData.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesBookPageData.OrderBy(r => r.PageId).ToList(), writer);
            }

            if (input.BiotaPropertiesGenerator != null && input.BiotaPropertiesGenerator.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesGenerator.ToList(), writer);
            }

            if (input.BiotaPropertiesPalette != null && input.BiotaPropertiesPalette.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesPalette.OrderBy(r => r.SubPaletteId).ToList(), writer);
            }
            if (input.BiotaPropertiesTextureMap != null && input.BiotaPropertiesTextureMap.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesTextureMap.OrderBy(r => r.Index).ToList(), writer);
            }
            if (input.BiotaPropertiesAnimPart != null && input.BiotaPropertiesAnimPart.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesAnimPart.OrderBy(r => r.Index).ToList(), writer);
            }

            if (input.BiotaPropertiesEnchantmentRegistry != null && input.BiotaPropertiesEnchantmentRegistry.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.BiotaPropertiesEnchantmentRegistry.ToList(), writer);
            }
        }

19 View Source File : BiotaSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint id, IList<BiotaPropertiesInt> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `biota_properties_int` (`object_Id`, `type`, `value`)");

            var lineGenerator = new Func<int, string>(i =>
            {
                string propertyValueDescription = GetValueEnumName((PropertyInt)input[i].Type, input[i].Value);

                var comment = Enum.GetName(typeof(PropertyInt), input[i].Type);
                if (propertyValueDescription != null)
                    comment += " - " + propertyValueDescription;

                return $"{id}, {input[i].Type.ToString().PadLeft(3)}, {input[i].Value.ToString().PadLeft(10)}) /* {comment} */";
            });

            ValuesWriter(input.Count, lineGenerator, writer);
        }

19 View Source File : BiotaSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint id, IList<BiotaPropertiesEmote> input, StreamWriter writer)
        {
            foreach (var value in input)
            {
                writer.WriteLine();
                writer.WriteLine("INSERT INTO `biota_properties_emote` (`object_Id`, `category`, `probability`, `biota_Clreplaced_Id`, `style`, `substyle`, `quest`, `vendor_Type`, `min_Health`, `max_Health`)");

                var categoryLabel = Enum.GetName(typeof(EmoteCategory), value.Category);
                if (categoryLabel != null)
                    categoryLabel = $" /* {categoryLabel} */";

                string weenieClreplacedIdLabel = null;
                if (WeenieNames != null && value.WeenieClreplacedId.HasValue)
                {
                    WeenieNames.TryGetValue(value.WeenieClreplacedId.Value, out weenieClreplacedIdLabel);
                    if (weenieClreplacedIdLabel != null)
                        weenieClreplacedIdLabel = $" /* {weenieClreplacedIdLabel} */";
                }

                string styleLabel = null;
                if (value.Style.HasValue)
                {
                    styleLabel = Enum.GetName(typeof(MotionStance), value.Style.Value);
                    if (styleLabel != null)
                        styleLabel = $" /* {styleLabel} */";
                }

                string substyleLabel = null;
                if (value.Substyle.HasValue)
                {
                    substyleLabel = Enum.GetName(typeof(MotionCommand), value.Substyle.Value);
                    if (substyleLabel != null)
                        substyleLabel = $" /* {substyleLabel} */";
                }

                string vendorTypeLabel = null;
                if (value.VendorType.HasValue)
                {
                    vendorTypeLabel = Enum.GetName(typeof(VendorType), value.VendorType.Value);
                    if (vendorTypeLabel != null)
                        vendorTypeLabel = $" /* {vendorTypeLabel} */";
                }

                var output = "VALUES (" +
                             $"{id}, " +
                             $"{value.Category.ToString().PadLeft(2)}{categoryLabel}, " +
                             $"{value.Probability.ToString(CultureInfo.InvariantCulture).PadLeft(6)}, " +
                             $"{value.WeenieClreplacedId}{weenieClreplacedIdLabel}, " +
                             $"{value.Style}{styleLabel}, " +
                             $"{value.Substyle}{substyleLabel}, " +
                             $"{GetSQLString(value.Quest)}, " +
                             $"{value.VendorType}{vendorTypeLabel}, " +
                             $"{value.MinHealth}, " +
                             $"{value.MaxHealth}" +
                             ");";

                output = FixNullFields(output);

                writer.WriteLine(output);

                if (value.BiotaPropertiesEmoteAction != null && value.BiotaPropertiesEmoteAction.Count > 0)
                {
                    writer.WriteLine();
                    writer.WriteLine("SET @parent_id = LAST_INSERT_ID();");

                    writer.WriteLine();
                    CreateSQLINSERTStatement(value.BiotaPropertiesEmoteAction.OrderBy(r => r.Order).ToList(), writer);
                }
            }
        }

19 View Source File : RecipeSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeRequirementsDID> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `recipe_requirements_d_i_d` (`recipe_Id`, `index`, `stat`, `value`, `enum`, `message`)");

            var lineGenerator = new Func<int, string>(i => $"{recipeId}, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {GetSQLString(input[i].Message)}) /* {((RequirementType)input[i].Index).ToString()}.{Enum.GetName(typeof(PropertyDataId), input[i].Stat)} {((CompareType)input[i].Enum).ToString()} {input[i].Value} */");

            ValuesWriter(input.Count, lineGenerator, writer);
        }

19 View Source File : RecipeSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeRequirementsIID> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `recipe_requirements_i_i_d` (`recipe_Id`, `index`, `stat`, `value`, `enum`, `message`)");

            var lineGenerator = new Func<int, string>(i => $"{recipeId}, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {GetSQLString(input[i].Message)}) /* {((RequirementType)input[i].Index).ToString()}.{Enum.GetName(typeof(PropertyInstanceId), input[i].Stat)} {((CompareType)input[i].Enum).ToString()} {input[i].Value} */");

            ValuesWriter(input.Count, lineGenerator, writer);
        }

19 View Source File : RecipeSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeRequirementsFloat> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `recipe_requirements_float` (`recipe_Id`, `index`, `stat`, `value`, `enum`, `message`)");

            var lineGenerator = new Func<int, string>(i => $"{recipeId}, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {GetSQLString(input[i].Message)}) /* {((RequirementType)input[i].Index).ToString()}.{Enum.GetName(typeof(PropertyFloat), input[i].Stat)} {((CompareType)input[i].Enum).ToString()} {input[i].Value} */");

            ValuesWriter(input.Count, lineGenerator, writer);
        }

19 View Source File : RecipeSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeRequirementsString> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `recipe_requirements_string` (`recipe_Id`, `index`, `stat`, `value`, `enum`, `message`)");

            var lineGenerator = new Func<int, string>(i => $"{recipeId}, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {GetSQLString(input[i].Value)}, {input[i].Enum}, {GetSQLString(input[i].Message)}) /* {((RequirementType)input[i].Index).ToString()}.{Enum.GetName(typeof(PropertyString), input[i].Stat)} {((CompareType)input[i].Enum).ToString()} {input[i].Value} */");

            ValuesWriter(input.Count, lineGenerator, writer);
        }

19 View Source File : RecipeSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint recipeId, IList<RecipeRequirementsBool> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `recipe_requirements_bool` (`recipe_Id`, `index`, `stat`, `value`, `enum`, `message`)");

            var lineGenerator = new Func<int, string>(i => $"{recipeId}, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {GetSQLString(input[i].Message)}) /* {((RequirementType)input[i].Index).ToString()}.{Enum.GetName(typeof(PropertyBool), input[i].Stat)} {((CompareType)input[i].Enum).ToString()} {input[i].Value} */");

            ValuesWriter(input.Count, lineGenerator, writer);
        }

19 View Source File : SpellSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(Spell input, StreamWriter writer)
        {
            var spellLineHdr = "INSERT INTO `spell` (`id`, `name`";

            var spellLine = $"VALUES ({input.Id}, {GetSQLString(input.Name)}";

            if (input.StatModType.HasValue)
            {
                spellLineHdr += ", `stat_Mod_Type`";
                spellLine += $", {input.StatModType} /* {((EnchantmentTypeFlags)input.StatModType).ToString()} */";
            }
            if (input.StatModKey.HasValue)
            {
                spellLineHdr += ", `stat_Mod_Key`";
                spellLine += $", {input.StatModKey}";

                if (input.StatModType.HasValue)
                {
                    var smt = (EnchantmentTypeFlags)input.StatModType;

                    if (smt.HasFlag(EnchantmentTypeFlags.Skill))
                    {
                        if (Enum.IsDefined(typeof(Skill), (int)input.StatModKey))
                            spellLine += $" /* {Enum.GetName(typeof(Skill), input.StatModKey)} */";
                    }
                    else if (smt.HasFlag(EnchantmentTypeFlags.Attribute))
                    {
                        if (Enum.IsDefined(typeof(PropertyAttribute), (ushort)input.StatModKey))
                            spellLine += $" /* {Enum.GetName(typeof(PropertyAttribute), input.StatModKey)} */";
                    }
                    else if (smt.HasFlag(EnchantmentTypeFlags.SecondAtt))
                    {
                        if (Enum.IsDefined(typeof(PropertyAttribute2nd), (ushort)input.StatModKey))
                            spellLine += $" /* {Enum.GetName(typeof(PropertyAttribute2nd), input.StatModKey)} */";
                    }
                    else if (smt.HasFlag(EnchantmentTypeFlags.Int))
                    {
                        if (Enum.IsDefined(typeof(PropertyInt), (ushort)input.StatModKey))
                            spellLine += $" /* {Enum.GetName(typeof(PropertyInt), input.StatModKey)} */";
                    }
                    else if (smt.HasFlag(EnchantmentTypeFlags.Float))
                    {
                        if (Enum.IsDefined(typeof(PropertyFloat), (ushort)input.StatModKey))
                            spellLine += $" /* {Enum.GetName(typeof(PropertyFloat), input.StatModKey)} */";
                    }                    
                }
            }
            if (input.StatModVal.HasValue)
            {
                spellLineHdr += ", `stat_Mod_Val`";
                spellLine += $", {input.StatModVal:0.######}";
            }

            if (input.EType.HasValue)
            {
                spellLineHdr += ", `e_Type`";
                spellLine += $", {input.EType} /* {Enum.GetName(typeof(DamageType), input.EType)} */";
            }

            if (input.BaseIntensity.HasValue)
            {
                spellLineHdr += ", `base_Intensity`";
                spellLine += $", {input.BaseIntensity}";
            }

            if (input.Variance.HasValue)
            {
                spellLineHdr += ", `variance`";
                spellLine += $", {input.Variance}";
            }

            if (input.Wcid.HasValue)
            {
                spellLineHdr += ", `wcid`";

                if (WeenieNames != null && input.Wcid.Value > 0 && WeenieNames.ContainsKey(input.Wcid.Value))
                    spellLine += $", {input.Wcid} /* {WeenieNames[input.Wcid.Value]} */";
                else
                    spellLine += $", {input.Wcid}";
            }

            if (input.NumProjectiles.HasValue)
            {
                spellLineHdr += ", `num_Projectiles`";
                spellLine += $", {input.NumProjectiles}";
            }

            if (input.NumProjectilesVariance.HasValue)
            {
                spellLineHdr += ", `num_Projectiles_Variance`";
                spellLine += $", {input.NumProjectilesVariance:0.######}";
            }

            if (input.SpreadAngle.HasValue)
            {
                spellLineHdr += ", `spread_Angle`";
                spellLine += $", {input.SpreadAngle:0.######}";
            }

            if (input.VerticalAngle.HasValue)
            {
                spellLineHdr += ", `vertical_Angle`";
                spellLine += $", {input.VerticalAngle:0.######}";
            }

            if (input.DefaultLaunchAngle.HasValue)
            {
                spellLineHdr += ", `default_Launch_Angle`";
                spellLine += $", {input.DefaultLaunchAngle:0.######}";
            }

            if (input.NonTracking.HasValue)
            {
                spellLineHdr += ", `non_Tracking`";
                spellLine += $", {input.NonTracking}";
            }

            if (input.CreateOffsetOriginX.HasValue)
            {
                spellLineHdr += ", `create_Offset_Origin_X`";
                spellLine += $", {input.CreateOffsetOriginX:0.######}";
            }
            if (input.CreateOffsetOriginY.HasValue)
            {
                spellLineHdr += ", `create_Offset_Origin_Y`";
                spellLine += $", {input.CreateOffsetOriginY:0.######}";
            }
            if (input.CreateOffsetOriginZ.HasValue)
            {
                spellLineHdr += ", `create_Offset_Origin_Z`";
                spellLine += $", {input.CreateOffsetOriginZ:0.######}";
            }

            if (input.PaddingOriginX.HasValue)
            {
                spellLineHdr += ", `padding_Origin_X`";
                spellLine += $", {input.PaddingOriginX:0.######}";
            }
            if (input.PaddingOriginY.HasValue)
            {
                spellLineHdr += ", `padding_Origin_Y`";
                spellLine += $", {input.PaddingOriginY:0.######}";
            }
            if (input.PaddingOriginZ.HasValue)
            {
                spellLineHdr += ", `padding_Origin_Z`";
                spellLine += $", {input.PaddingOriginZ:0.######}";
            }

            if (input.DimsOriginX.HasValue)
            {
                spellLineHdr += ", `dims_Origin_X`";
                spellLine += $", {input.DimsOriginX:0.######}";
            }
            if (input.DimsOriginY.HasValue)
            {
                spellLineHdr += ", `dims_Origin_Y`";
                spellLine += $", {input.DimsOriginY:0.######}";
            }
            if (input.DimsOriginZ.HasValue)
            {
                spellLineHdr += ", `dims_Origin_Z`";
                spellLine += $", {input.DimsOriginZ:0.######}";
            }

            if (input.PeturbationOriginX.HasValue)
            {
                spellLineHdr += ", `peturbation_Origin_X`";
                spellLine += $", {input.PeturbationOriginX:0.######}";
            }
            if (input.PeturbationOriginY.HasValue)
            {
                spellLineHdr += ", `peturbation_Origin_Y`";
                spellLine += $", {input.PeturbationOriginY:0.######}";
            }
            if (input.PeturbationOriginZ.HasValue)
            {
                spellLineHdr += ", `peturbation_Origin_Z`";
                spellLine += $", {input.PeturbationOriginZ:0.######}";
            }

            if (input.ImbuedEffect.HasValue)
            {
                spellLineHdr += ", `imbued_Effect`";
                spellLine += $", {input.ImbuedEffect} /* {Enum.GetName(typeof(ImbuedEffectType), input.ImbuedEffect)} */";
            }

            if (input.SlayerCreatureType.HasValue)
            {
                spellLineHdr += ", `slayer_Creature_Type`";
                spellLine += $", {input.SlayerCreatureType} /* {Enum.GetName(typeof(CreatureType), input.SlayerCreatureType)} */";
            }

            if (input.SlayerDamageBonus.HasValue)
            {
                spellLineHdr += ", `slayer_Damage_Bonus`";
                spellLine += $", {input.SlayerDamageBonus}";
            }

            if (input.CritFreq.HasValue)
            {
                spellLineHdr += ", `crit_Freq`";
                spellLine += $", {input.CritFreq}";
            }

            if (input.CritMultiplier.HasValue)
            {
                spellLineHdr += ", `crit_Multiplier`";
                spellLine += $", {input.CritMultiplier}";
            }

            if (input.IgnoreMagicResist.HasValue)
            {
                spellLineHdr += ", `ignore_Magic_Resist`";
                spellLine += $", {input.IgnoreMagicResist}";
            }

            if (input.ElementalModifier.HasValue)
            {
                spellLineHdr += ", `elemental_Modifier`";
                spellLine += $", {input.ElementalModifier}";
            }

            if (input.DrainPercentage.HasValue)
            {
                spellLineHdr += ", `drain_Percentage`";
                spellLine += $", {input.DrainPercentage:0.######}";
            }

            if (input.DamageRatio.HasValue)
            {
                spellLineHdr += ", `damage_Ratio`";
                spellLine += $", {input.DamageRatio}";
            }

            if (input.DamageType.HasValue)
            {
                spellLineHdr += ", `damage_Type`";
                spellLine += $", {(int)input.DamageType} /* {Enum.GetName(typeof(DamageType), input.DamageType)} */";
            }

            if (input.Boost.HasValue)
            {
                spellLineHdr += ", `boost`";
                spellLine += $", {input.Boost}";
            }

            if (input.BoostVariance.HasValue)
            {
                spellLineHdr += ", `boost_Variance`";
                spellLine += $", {input.BoostVariance}";
            }

            if (input.Source.HasValue)
            {
                spellLineHdr += ", `source`";
                spellLine += $", {(int)input.Source} /* {Enum.GetName(typeof(PropertyAttribute2nd), input.Source)} */";
            }

            if (input.Destination.HasValue)
            {
                spellLineHdr += ", `destination`";
                spellLine += $", {(int)input.Destination} /* {Enum.GetName(typeof(PropertyAttribute2nd), input.Destination)} */";
            }

            if (input.Proportion.HasValue)
            {
                spellLineHdr += ", `proportion`";
                spellLine += $", {input.Proportion}";
            }

            if (input.LossPercent.HasValue)
            {
                spellLineHdr += ", `loss_Percent`";
                spellLine += $", {input.LossPercent:0.######}";
            }

            if (input.SourceLoss.HasValue)
            {
                spellLineHdr += ", `source_Loss`";
                spellLine += $", {input.SourceLoss}";
            }

            if (input.TransferCap.HasValue)
            {
                spellLineHdr += ", `transfer_Cap`";
                spellLine += $", {input.TransferCap}";
            }

            if (input.MaxBoostAllowed.HasValue)
            {
                spellLineHdr += ", `max_Boost_Allowed`";
                spellLine += $", {input.MaxBoostAllowed}";
            }

            if (input.TransferBitfield.HasValue)
            {
                spellLineHdr += ", `transfer_Bitfield`";
                spellLine += $", {input.TransferBitfield} /* {((TransferFlags)input.TransferBitfield).ToString()} */";
            }

            if (input.Index.HasValue)
            {
                spellLineHdr += ", `index`";
                spellLine += $", {input.Index} /* {(input.Name.Contains("Tie") ? ("PortalLinkType." + (PortalLinkType)input.Index).ToString() : ("PortalRecallType." + (PortalRecallType)input.Index).ToString())} */";
            }

            if (input.Link.HasValue)
            {
                spellLineHdr += ", `link`";
                spellLine += $", {input.Link} /* PortalSummonType.{((PortalSummonType)input.Link).ToString()} */";
            }

            if (input.PositionObjCellId.HasValue)
            {
                spellLineHdr += ", `position_Obj_Cell_ID`";
                spellLine += $", 0x{input.PositionObjCellId:X8}";
            }
            if (input.PositionOriginX.HasValue)
            {
                spellLineHdr += ", `position_Origin_X`";
                spellLine += $", {TrimNegativeZero(input.PositionOriginX):0.######}";
            }
            if (input.PositionOriginY.HasValue)
            {
                spellLineHdr += ", `position_Origin_Y`";
                spellLine += $", {TrimNegativeZero(input.PositionOriginY):0.######}";
            }
            if (input.PositionOriginZ.HasValue)
            {
                spellLineHdr += ", `position_Origin_Z`";
                spellLine += $", {TrimNegativeZero(input.PositionOriginZ):0.######}";
            }
            if (input.PositionAnglesW.HasValue)
            {
                spellLineHdr += ", `position_Angles_W`";
                spellLine += $", {TrimNegativeZero(input.PositionAnglesW):0.######}";
            }
            if (input.PositionAnglesX.HasValue)
            {
                spellLineHdr += ", `position_Angles_X`";
                spellLine += $", {TrimNegativeZero(input.PositionAnglesX):0.######}";
            }
            if (input.PositionAnglesY.HasValue)
            {
                spellLineHdr += ", `position_Angles_Y`";
                spellLine += $", {TrimNegativeZero(input.PositionAnglesY):0.######}";
            }
            if (input.PositionAnglesZ.HasValue)
            {
                spellLineHdr += ", `position_Angles_Z`";
                spellLine += $", {TrimNegativeZero(input.PositionAnglesZ):0.######}";
            }

            if (input.MinPower.HasValue)
            {
                spellLineHdr += ", `min_Power`";
                spellLine += $", {input.MinPower}";
            }

            if (input.MaxPower.HasValue)
            {
                spellLineHdr += ", `max_Power`";
                spellLine += $", {input.MaxPower}";
            }

            if (input.PowerVariance.HasValue)
            {
                spellLineHdr += ", `power_Variance`";
                spellLine += $", {input.PowerVariance:0.######}";
            }

            if (input.DispelSchool.HasValue)
            {
                spellLineHdr += ", `dispel_School`";
                spellLine += $", {(int)input.DispelSchool} /* {Enum.GetName(typeof(MagicSchool), input.DispelSchool)} */";
            }

            if (input.Align.HasValue)
            {
                spellLineHdr += ", `align`";
                spellLine += $", {input.Align}";
            }

            if (input.Number.HasValue)
            {
                spellLineHdr += ", `number`";
                spellLine += $", {input.Number}";
            }

            if (input.NumberVariance.HasValue)
            {
                spellLineHdr += ", `number_Variance`";
                spellLine += $", {input.NumberVariance:0.######}";
            }

            if (input.DotDuration.HasValue)
            {
                spellLineHdr += ", `dot_Duration`";
                spellLine += $", {input.DotDuration}";
            }

            
            spellLineHdr += ", `last_Modified`";
            spellLine += $", '{input.LastModified:yyyy-MM-dd HH:mm:ss}'";
            
            spellLineHdr += ")";
            spellLine += ");";

            spellLine = FixNullFields(spellLine);

            if (input.PositionObjCellId.HasValue && input.PositionOriginX.HasValue && input.PositionOriginY.HasValue && input.PositionOriginZ.HasValue && input.PositionAnglesX.HasValue && input.PositionAnglesY.HasValue && input.PositionAnglesZ.HasValue && input.PositionAnglesW.HasValue)
            {
                spellLine += Environment.NewLine + $"/* @teleloc 0x{input.PositionObjCellId.Value:X8} [{TrimNegativeZero(input.PositionOriginX.Value):F6} {TrimNegativeZero(input.PositionOriginY.Value):F6} {TrimNegativeZero(input.PositionOriginZ.Value):F6}] {TrimNegativeZero(input.PositionAnglesW.Value):F6} {TrimNegativeZero(input.PositionAnglesX.Value):F6} {TrimNegativeZero(input.PositionAnglesY.Value):F6} {TrimNegativeZero(input.PositionAnglesZ.Value):F6} */";
            }

            writer.WriteLine(spellLineHdr);
            writer.WriteLine(spellLine);
        }

19 View Source File : WeenieSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public string GetDefaultSubfolder(Weenie input)
        {
            var subFolder = Enum.GetName(typeof(WeenieType), input.Type) + "\\";

            if (input.Type == (int)WeenieType.Creature)
            {
                var property = input.WeeniePropertiesInt.FirstOrDefault(r => r.Type == (int)PropertyInt.CreatureType);

                if (property != null)
                {
                    Enum.TryParse(property.Value.ToString(), out CreatureType ct);

                    if (Enum.IsDefined(typeof(CreatureType), ct))
                        subFolder += Enum.GetName(typeof(CreatureType), property.Value) + "\\";
                    else
                        subFolder += "UnknownCT_" + property.Value + "\\";
                }
                else
                    subFolder += "Unsorted" + "\\";
            }
            else if (input.Type == (int)WeenieType.House)
            {
                var property = input.WeeniePropertiesInt.FirstOrDefault(r => r.Type == (int)PropertyInt.HouseType);

                if (property != null)
                {
                    Enum.TryParse(property.Value.ToString(), out HouseType ht);

                    if (Enum.IsDefined(typeof(HouseType), ht))
                        subFolder += Enum.GetName(typeof(HouseType), property.Value) + "\\";
                    else
                        subFolder += "UnknownHT_" + property.Value + "\\";
                }
                else
                    subFolder += "Unsorted" + "\\";
            }
            else
            {
                var property = input.WeeniePropertiesInt.FirstOrDefault(r => r.Type == (int)PropertyInt.ItemType);

                if (property != null)
                    subFolder += Enum.GetName(typeof(ItemType), property.Value) + "\\";
                else
                    subFolder += Enum.GetName(typeof(ItemType), ItemType.None) + "\\";
            }

            return subFolder;
        }

19 View Source File : DerethDateTime.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public override string ToString()
        {
            return "Date: " + Enum.GetName(typeof(Months), Month) + " " + Day + ", " + Year + " P.Y.  Time: " + Enum.GetName(typeof(Hours), Hour).Replace("_", "-");
        }

19 View Source File : DerethDateTime.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public string MonthToString()
        {
            return Enum.GetName(typeof(Months), Month);
        }

19 View Source File : DerethDateTime.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public string MonthNameToString()
        {
            return Enum.GetName(typeof(Months), MonthName);
        }

19 View Source File : DerethDateTime.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public string HourToString()
        {
            return Enum.GetName(typeof(Hours), Hour).Replace("_", "-");
        }

19 View Source File : DerethDateTime.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public string HourNameToString()
        {
            return Enum.GetName(typeof(Hours), HourName).Replace("_", "-");
        }

19 View Source File : DerethDateTime.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public string TimeToString()
        {
            return Enum.GetName(typeof(Hours), Time).Replace("_", "-");
        }

19 View Source File : DerethDateTime.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public string DateToString()
        {
            return Enum.GetName(typeof(Months), Month) + " " + Day + ", " + Year + " P.Y.";
        }

19 View Source File : BiotaSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint id, IList<BiotaPropertiesBool> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `biota_properties_bool` (`object_Id`, `type`, `value`)");

            var lineGenerator = new Func<int, string>(i => $"{id}, {input[i].Type.ToString().PadLeft(3)}, {input[i].Value.ToString().PadRight(5)}) /* {Enum.GetName(typeof(PropertyBool), input[i].Type)} */");

            ValuesWriter(input.Count, lineGenerator, writer);
        }

19 View Source File : BiotaSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint id, IList<BiotaPropertiesBodyPart> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `biota_properties_body_part` (`object_Id`, `key`, " +
                             "`d_Type`, `d_Val`, `d_Var`, " +
                             "`base_Armor`, `armor_Vs_Slash`, `armor_Vs_Pierce`, `armor_Vs_Bludgeon`, `armor_Vs_Cold`, `armor_Vs_Fire`, `armor_Vs_Acid`, `armor_Vs_Electric`, `armor_Vs_Nether`, " +
                             "`b_h`, `h_l_f`, `m_l_f`, `l_l_f`, `h_r_f`, `m_r_f`, `l_r_f`, `h_l_b`, `m_l_b`, `l_l_b`, `h_r_b`, `m_r_b`, `l_r_b`)");

            var lineGenerator = new Func<int, string>(i =>
                $"{id}, " +
                $"{input[i].Key.ToString().PadLeft(2)}, " +
                $"{input[i].DType.ToString().PadLeft(2)}, " +
                $"{input[i].DVal.ToString().PadLeft(2)}, " +
                $"{input[i].DVar.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].BaseArmor.ToString().PadLeft(4)}, " +
                $"{input[i].ArmorVsSlash.ToString().PadLeft(4)}, " +
                $"{input[i].ArmorVsPierce.ToString().PadLeft(4)}, " +
                $"{input[i].ArmorVsBludgeon.ToString().PadLeft(4)}, " +
                $"{input[i].ArmorVsCold.ToString().PadLeft(4)}, " +
                $"{input[i].ArmorVsFire.ToString().PadLeft(4)}, " +
                $"{input[i].ArmorVsAcid.ToString().PadLeft(4)}, " +
                $"{input[i].ArmorVsElectric.ToString().PadLeft(4)}, " +
                $"{input[i].ArmorVsNether.ToString().PadLeft(4)}, " +
                $"{input[i].BH}, " +
                $"{input[i].HLF.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].MLF.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].LLF.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].HRF.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].MRF.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].LRF.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].HLB.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].MLB.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].LLB.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].HRB.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].MRB.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                $"{input[i].LRB.ToString(CultureInfo.InvariantCulture).PadLeft(4)}) " +
                $"/* {Enum.GetName(typeof(CombatBodyPart), input[i].Key)} */");

            ValuesWriter(input.Count, lineGenerator, writer);
        }

19 View Source File : WeenieSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesInt64> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_int64` (`object_Id`, `type`, `value`)");

            var lineGenerator = new Func<int, string>(i => $"{weenieClreplacedID}, {input[i].Type.ToString().PadLeft(3)}, {input[i].Value.ToString().PadLeft(10)}) /* {Enum.GetName(typeof(PropertyInt64), input[i].Type)} */");

            ValuesWriter(input.Count, lineGenerator, writer);
        }

19 View Source File : WeenieSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesBool> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_bool` (`object_Id`, `type`, `value`)");

            var lineGenerator = new Func<int, string>(i => $"{weenieClreplacedID}, {input[i].Type.ToString().PadLeft(3)}, {input[i].Value.ToString().PadRight(5)}) /* {Enum.GetName(typeof(PropertyBool), input[i].Type)} */");

            ValuesWriter(input.Count, lineGenerator, writer);
        }

19 View Source File : WeenieSQLWriter.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesFloat> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_float` (`object_Id`, `type`, `value`)");

            var lineGenerator = new Func<int, string>(i => $"{weenieClreplacedID}, {input[i].Type.ToString().PadLeft(3)}, {input[i].Value.ToString("0.###", CultureInfo.InvariantCulture).PadLeft(7)}) /* {Enum.GetName(typeof(PropertyFloat), input[i].Type)} */");

            ValuesWriter(input.Count, lineGenerator, writer);
        }

See More Examples