System.IO.TextWriter.WriteLine(string)

Here are the examples of the csharp api System.IO.TextWriter.WriteLine(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

5861 Examples 7

19 Source : CharacterSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLDELETEStatement(Character input, StreamWriter writer)
        {
            writer.WriteLine($"DELETE FROM `character` WHERE `id` = {input.Id};");
        }

19 Source : CharacterSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(Character input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `character` (`id`, `account_Id`, `name`, `is_Plussed`, `is_Deleted`, `delete_Time`, `last_Login_Timestamp`, `total_Logins`, `character_Options_1`, `character_Options_2`, `gameplay_Options`, `spellbook_Filters`, `hair_Texture`, `default_Hair_Texture`)");

            var output = $"VALUES ({input.Id}, {input.AccountId}, {GetSQLString(input.Name)}, {input.IsPlussed}, {input.IsDeleted}, {input.DeleteTime}, {input.LastLoginTimestamp}, {input.TotalLogins}, {input.CharacterOptions1}, {input.CharacterOptions2}, {input.GameplayOptions}, {input.SpellbookFilters}, {input.HairTexture}, {input.DefaultHairTexture});";

            output = FixNullFields(output);

            writer.WriteLine(output);

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

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

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

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

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

            if (input.CharacterPropertiesSpellBar != null && input.CharacterPropertiesSpellBar.Count > 0)
            {
                writer.WriteLine();
                CreateSQLINSERTStatement(input.Id, input.CharacterPropertiesSpellBar.OrderBy(r => r.SpellBarNumber).ThenBy(r => r.SpellBarIndex).ToList(), writer);
            }

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

19 Source : CharacterSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint characterId, IList<CharacterPropertiesContractRegistry> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `character_properties_contract_registry` (`character_Id`, `contract_Id`, `delete_Contract`, `set_As_Display_Contract`)");

            var lineGenerator = new Func<int, string>(i => $"{characterId}, {input[i].ContractId}, {input[i].DeleteContract}, {input[i].SetAsDisplayContract})");

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

19 Source : CharacterSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint characterId, IList<CharacterPropertiesFillCompBook> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `character_properties_fill_comp_book` (`character_Id`, `spell_Component_Id`, `quanreplacedy_To_Rebuy`)");

            var lineGenerator = new Func<int, string>(i => $"{characterId}, {input[i].SpellComponentId}, {input[i].QuanreplacedyToRebuy})");

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

19 Source : CharacterSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint characterId, IList<CharacterPropertiesFriendList> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `character_properties_friend_list` ( `character_Id`, `friend_Id`)");

            var lineGenerator = new Func<int, string>(i => $"{characterId}, {input[i].FriendId})");

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

19 Source : CharacterSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint characterId, IList<CharacterPropertiesQuestRegistry> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `character_properties_quest_registry` (`character_Id`, `quest_Name`, `last_Time_Completed`, `num_Times_Completed`)");

            var lineGenerator = new Func<int, string>(i => $"{characterId}, {GetSQLString(input[i].QuestName)}, {input[i].LastTimeCompleted}, {input[i].NumTimesCompleted})");

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

19 Source : CharacterSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint characterId, IList<CharacterPropertiesShortcutBar> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `character_properties_shortcut_bar` (`character_Id`, `shortcut_Bar_Index`, `shortcut_Object_Id`)");

            var lineGenerator = new Func<int, string>(i => $"{characterId}, {input[i].ShortcutBarIndex}, {input[i].ShortcutObjectId})");

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

19 Source : CharacterSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint characterId, IList<CharacterPropertiesSpellBar> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `character_properties_spell_bar` (`character_Id`, `spell_Bar_Number`, `spell_Bar_Index`, `spell_Id`)");

            var lineGenerator = new Func<int, string>(i => $"{characterId}, {input[i].SpellBarNumber}, {input[i].SpellBarIndex}, {input[i].SpellId})");

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

19 Source : CharacterSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint characterId, IList<CharacterPropertiesreplacedleBook> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `character_properties_replacedle_book` (`character_Id`, `replacedle_Id`)");

            var lineGenerator = new Func<int, string>(i => $"{characterId}, {input[i].replacedleId})");

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

19 Source : CookBookSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLDELETEStatement(IList<CookBook> input, StreamWriter writer)
        {
            writer.WriteLine($"DELETE FROM `cook_book` WHERE `recipe_Id` = {input[0].RecipeId};");
        }

19 Source : CookBookSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(IList<CookBook> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `cook_book` (`recipe_Id`, `source_W_C_I_D`, `target_W_C_I_D`, `last_Modified`)");

            var lineGenerator = new Func<int, string>(i =>
            {
                string sourceLabel = null;
                if (WeenieNames != null)
                    WeenieNames.TryGetValue(input[i].SourceWCID, out sourceLabel);

                string targetLabel = null;
                if (WeenieNames != null)
                    WeenieNames.TryGetValue(input[i].TargetWCID, out targetLabel);

                return $"{input[i].RecipeId}, {input[i].SourceWCID} /* {sourceLabel} */, {input[i].TargetWCID.ToString().PadLeft(5)} /* {targetLabel} */, '{input[i].LastModified:yyyy-MM-dd HH:mm:ss}')";
            });

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

19 Source : EncounterSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLDELETEStatement(IList<Encounter> input, StreamWriter writer)
        {
            writer.WriteLine($"DELETE FROM `encounter` WHERE `landblock` = 0x{input[0].Landblock:X4};");
        }

19 Source : EncounterSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(IList<Encounter> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `encounter` (`landblock`, `weenie_Clreplaced_Id`, `cell_X`, `cell_Y`, `last_Modified`)");

            var lineGenerator = new Func<int, string>(i =>
            {
                string label = null;

                if (WeenieNames != null)
                    WeenieNames.TryGetValue(input[i].WeenieClreplacedId, out label);

                return $"0x{input[i].Landblock:X4}, {input[i].WeenieClreplacedId}, {input[i].CellX}, {input[i].CellY}, '{input[i].LastModified:yyyy-MM-dd HH:mm:ss}') /* {label} */";
            });

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

19 Source : EventSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLDELETEStatement(Event input, StreamWriter writer)
        {
            writer.WriteLine($"DELETE FROM `event` WHERE `name` = {GetSQLString(input.Name)};");
        }

19 Source : EventSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(Event input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `event` (`name`, `start_Time`, `end_Time`, `state`, `last_Modified`)");

            var output = "VALUES (" +
                             $"{GetSQLString(input.Name)}, " +
                             $"{(input.StartTime == -1 ? $"{input.StartTime}" : $"{input.StartTime} /* {DateTimeOffset.FromUnixTimeSeconds(input.StartTime).DateTime.ToUniversalTime().ToString(CultureInfo.InvariantCulture)} */")}, " +
                             $"{(input.EndTime == -1 ? $"{input.EndTime}" : $"{input.EndTime} /* {DateTimeOffset.FromUnixTimeSeconds(input.EndTime).DateTime.ToUniversalTime().ToString(CultureInfo.InvariantCulture)} */")}, " +
                             $"{input.State}, " +
                             $"'{input.LastModified:yyyy-MM-dd HH:mm:ss}'" +
                             ");";

            output = FixNullFields(output);

            writer.WriteLine(output);
        }

19 Source : HousePortalSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLDELETEStatement(IList<HousePortal> input, StreamWriter writer)
        {
            writer.WriteLine($"DELETE FROM `house_portal` WHERE `house_Id` = {input[0].HouseId};");
        }

19 Source : RecipeSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

private void CreateSQLINSERTStatement(IList<RecipeModsInt> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `recipe_mods_int` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");

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

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

                return $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()}{(comment == null ? "" : $" {comment}")}{(comment != null && comment.Contains(" - ") || input[i].Enum == 7 ? "" : $" {input[i].Value}")}{(input[i].Enum == 7 ? $" {((SpellId)input[i].Stat).ToString()}" : "")} to {((ModificationType)input[i].Index).ToString().Substring(7)} */";
            });

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

19 Source : RecipeSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

private void CreateSQLINSERTStatement(IList<RecipeModsDID> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `recipe_mods_d_i_d` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");

            var lineGenerator = new Func<int, string>(i => $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()} {Enum.GetName(typeof(PropertyDataId), input[i].Stat)} to {((ModificationType)input[i].Index).ToString().Substring(7)} */");

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

19 Source : RecipeSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

private void CreateSQLINSERTStatement(IList<RecipeModsIID> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `recipe_mods_i_i_d` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");

            var lineGenerator = new Func<int, string>(i => $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()} {Enum.GetName(typeof(PropertyInstanceId), input[i].Stat)} to {((ModificationType)input[i].Index).ToString().Substring(7)} */");

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

19 Source : RecipeSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

private void CreateSQLINSERTStatement(IList<RecipeModsFloat> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `recipe_mods_float` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");

            var lineGenerator = new Func<int, string>(i => $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()} {Enum.GetName(typeof(PropertyFloat), input[i].Stat)} to {((ModificationType)input[i].Index).ToString().Substring(7)} */");

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

19 Source : RecipeSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

private void CreateSQLINSERTStatement(IList<RecipeModsString> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `recipe_mods_string` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");

            var lineGenerator = new Func<int, string>(i => $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {GetSQLString(input[i].Value)}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()} {Enum.GetName(typeof(PropertyString), input[i].Stat)} to {((ModificationType)input[i].Index).ToString().Substring(7)} */");

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

19 Source : RecipeSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

private void CreateSQLINSERTStatement(IList<RecipeModsBool> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `recipe_mods_bool` (`recipe_Mod_Id`, `index`, `stat`, `value`, `enum`, `source`)");

            var lineGenerator = new Func<int, string>(i => $"@parent_id, {input[i].Index}, {input[i].Stat.ToString().PadLeft(3)}, {input[i].Value}, {input[i].Enum}, {input[i].Source}) /* On {((RecipeSourceType)input[i].Source).ToString()}.{((ModificationType)input[i].Index).ToString()} {((ModificationOperation)input[i].Enum).ToString()} {Enum.GetName(typeof(PropertyBool), input[i].Stat)} to {((ModificationType)input[i].Index).ToString().Substring(7)} */");

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

19 Source : SpellSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLDELETEStatement(Spell input, StreamWriter writer)
        {
            writer.WriteLine($"DELETE FROM `spell` WHERE `id` = {input.Id};");
        }

19 Source : TreasureDeathSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLDELETEStatement(TreasureDeath input, StreamWriter writer)
        {
            writer.WriteLine($"DELETE FROM `treasure_death` WHERE `treasure_Type` = {input.TreasureType};");
        }

19 Source : TreasureDeathSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(TreasureDeath input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `treasure_death` (`treasure_Type`, `tier`, `loot_Quality_Mod`, `unknown_Chances`, `item_Chance`, `item_Min_Amount`, `item_Max_Amount`, `item_Treasure_Type_Selection_Chances`, `magic_Item_Chance`, `magic_Item_Min_Amount`, `magic_Item_Max_Amount`, `magic_Item_Treasure_Type_Selection_Chances`, `mundane_Item_Chance`, `mundane_Item_Min_Amount`, `mundane_Item_Max_Amount`, `mundane_Item_Type_Selection_Chances`, `last_Modified`)");

            var output = "VALUES (" +
                $"{input.TreasureType}, " +
                $"{input.Tier}, " +
                $"{input.LootQualityMod}, " +
                $"{input.UnknownChances}, " +
                $"{input.ItemChance}, " +
                $"{input.ItemMinAmount}, " +
                $"{input.ItemMaxAmount}, " +
                $"{input.ItemTreasureTypeSelectionChances}, " +
                $"{input.MagicItemChance}, " +
                $"{input.MagicItemMinAmount}, " +
                $"{input.MagicItemMaxAmount}, " +
                $"{input.MagicItemTreasureTypeSelectionChances}, " +
                $"{input.MundaneItemChance}, " +
                $"{input.MundaneItemMinAmount}, " +
                $"{input.MundaneItemMaxAmount}, " +
                $"{input.MundaneItemTypeSelectionChances}, " +
                $"'{input.LastModified:yyyy-MM-dd HH:mm:ss}'" +
                ");";

            output = FixNullFields(output);

            writer.WriteLine(output);
        }

19 Source : TreasureWieldedSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLDELETEStatement(IList<TreasureWielded> input, StreamWriter writer)
        {
            writer.WriteLine($"DELETE FROM `treasure_wielded` WHERE `treasure_Type` = {input[0].TreasureType};");
        }

19 Source : TreasureWieldedSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(IList<TreasureWielded> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `treasure_wielded` (`treasure_Type`, `weenie_Clreplaced_Id`, `palette_Id`, `unknown_1`, `shade`, `stack_Size`, `stack_Size_Variance`, `probability`, `unknown_3`, `unknown_4`, `unknown_5`, `set_Start`, `has_Sub_Set`, `continues_Previous_Set`, `unknown_9`, `unknown_10`, `unknown_11`, `unknown_12`, `last_Modified`)");

            var lineGenerator = new Func<int, string>(i =>
            {
                string weenieLabel = null;
                if (WeenieNames != null)
                    WeenieNames.TryGetValue(input[i].WeenieClreplacedId, out weenieLabel);

                return
                    $"{input[i].TreasureType}, " +
                    $"{input[i].WeenieClreplacedId.ToString().PadLeft(5)}, " +
                    $"{input[i].PaletteId.ToString().PadLeft(2)}, " +
                    $"{input[i].Unknown1}, " +
                    $"{input[i].Shade.ToString(CultureInfo.InvariantCulture).PadLeft(4)}, " +
                    $"{input[i].StackSize}, " +
                    $"{input[i].StackSizeVariance}, " +
                    $"{input[i].Probability.ToString(CultureInfo.InvariantCulture).PadLeft(7)}, " +
                    $"{input[i].Unknown3}, " +
                    $"{input[i].Unknown4}, " +
                    $"{input[i].Unknown5}, " +
                    $"{input[i].SetStart.ToString().PadLeft(5)}, " +
                    $"{input[i].HreplacedubSet.ToString().PadLeft(5)}, " +
                    $"{input[i].ContinuesPreviousSet.ToString().PadLeft(5)}, " +
                    $"{input[i].Unknown9}, " +
                    $"{input[i].Unknown10}, " +
                    $"{input[i].Unknown11}, " +
                    $"{input[i].Unknown12}, " +
                    $"'{input[i].LastModified:yyyy-MM-dd HH:mm:ss}'" +
                    $") /* {weenieLabel} */";
            });

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

19 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

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

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

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

19 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesAttribute> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_attribute` (`object_Id`, `type`, `init_Level`, `level_From_C_P`, `c_P_Spent`)");

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

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

19 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesAttribute2nd> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_attribute_2nd` (`object_Id`, `type`, `init_Level`, `level_From_C_P`, `c_P_Spent`, `current_Level`)");

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

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

19 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesSkill> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_skill` (`object_Id`, `type`, `level_From_P_P`, `s_a_c`, `p_p`, `init_Level`, `resistance_At_Last_Check`, `last_Used_Time`)");

            var lineGenerator = new Func<int, string>(i =>
                $"{weenieClreplacedID}, " +
                $"{input[i].Type.ToString().PadLeft(2)}, " +
                $"{input[i].LevelFromPP}, " +
                $"{input[i].SAC}, " +
                $"{input[i].PP}, " +
                $"{input[i].InitLevel.ToString().PadLeft(3)}, " +
                $"{input[i].ResistanceAtLastCheck}, " +
                $"{input[i].LastUsedTime}) " +
                // ReSharper disable once PossibleNullReferenceException
                $"/* {Enum.GetName(typeof(Skill), input[i].Type).PadRight(19)} {((SkillAdvancementClreplaced)input[i].SAC).ToString()} */");

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

19 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesBodyPart> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_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 =>
                $"{weenieClreplacedID}, " +
                $"{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 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesEventFilter> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_event_filter` (`object_Id`, `event`)");

            var lineGenerator = new Func<int, string>(i =>
            {
                string label = null;

                if (PacketOpCodes != null)
                    PacketOpCodes.TryGetValue((uint)input[i].Event, out label);

                return $"{weenieClreplacedID}, {input[i].Event.ToString().PadLeft(3)}) /* {label} */";
            });

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

19 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

private void CreateSQLINSERTStatement(IList<WeeniePropertiesEmoteAction> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_emote_action` (`emote_Id`, `order`, `type`, `delay`, `extent`, `motion`, `message`, `test_String`, `min`, `max`, `min_64`, `max_64`, `min_Dbl`, `max_Dbl`, " +
                             "`stat`, `display`, `amount`, `amount_64`, `hero_X_P_64`, `percent`, `spell_Id`, `wealth_Rating`, `treasure_Clreplaced`, `treasure_Type`, `p_Script`, `sound`, `destination_Type`, `weenie_Clreplaced_Id`, `stack_Size`, `palette`, `shade`, `try_To_Bond`, " +
                             "`obj_Cell_Id`, `origin_X`, `origin_Y`, `origin_Z`, `angles_W`, `angles_X`, `angles_Y`, `angles_Z`)");

            var lineGenerator = new Func<int, string>(i =>
            {
                string typeLabel = Enum.GetName(typeof(EmoteType), input[i].Type);
                if (typeLabel != null)
                    typeLabel = $" /* {typeLabel} */";

                string motionLabel = null;
                if (input[i].Motion.HasValue)
                {
                    motionLabel = Enum.GetName(typeof(MotionCommand), input[i].Motion.Value);
                    if (motionLabel != null)
                        motionLabel = $" /* {motionLabel} */";
                }

                string spellIdLabel = null;
                if (SpellNames != null && input[i].SpellId.HasValue)
                {
                    SpellNames.TryGetValue((uint)input[i].SpellId.Value, out spellIdLabel);
                    if (spellIdLabel != null)
                        spellIdLabel = $" /* {spellIdLabel} */";
                }

                string pScriptLabel = null;
                if (input[i].PScript.HasValue)
                {
                    pScriptLabel = Enum.GetName(typeof(PlayScript), input[i].PScript.Value);
                    if (pScriptLabel != null)
                        pScriptLabel = $" /* {pScriptLabel} */";
                }

                string soundLabel = null;
                if (input[i].Sound.HasValue)
                {
                    soundLabel = Enum.GetName(typeof(Sound), input[i].Sound.Value);
                    if (soundLabel != null)
                        soundLabel = $" /* {soundLabel} */";
                }

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

                string destinationTypeLabel = null;
                if (input[i].DestinationType.HasValue)
                {
                    destinationTypeLabel = Enum.GetName(typeof(DestinationType), input[i].DestinationType.Value);
                    if (destinationTypeLabel != null)
                        destinationTypeLabel = $" /* {destinationTypeLabel} */";
                }

                string telelocLabel = null;
                if (input[i].ObjCellId.HasValue && input[i].ObjCellId.Value > 0)
                {
                    telelocLabel = $" /* @teleloc 0x{input[i].ObjCellId.Value:X8} [{TrimNegativeZero(input[i].OriginX.Value):F6} {TrimNegativeZero(input[i].OriginY.Value):F6} {TrimNegativeZero(input[i].OriginZ.Value):F6}] {TrimNegativeZero(input[i].AnglesW.Value):F6} {TrimNegativeZero(input[i].AnglesX.Value):F6} {TrimNegativeZero(input[i].AnglesY.Value):F6} {TrimNegativeZero(input[i].AnglesZ.Value):F6} */";
                }

                string statLabel = null;
                if (input[i].Stat.HasValue)
                {
                    switch ((EmoteType)input[i].Type)
                    {
                        case EmoteType.AwardLevelProportionalSkillXP:
                        case EmoteType.AwardSkillPoints:
                        case EmoteType.AwardSkillXP:

                        case EmoteType.InqSkillStat:
                        case EmoteType.InqRawSkillStat:
                        case EmoteType.InqSkillTrained:
                        case EmoteType.InqSkillSpecialized:
                        case EmoteType.UntrainSkill:
                            statLabel = $" /* Skill.{(Skill)input[i].Stat.Value} */";
                            break;

                        case EmoteType.DecrementIntStat:
                        case EmoteType.IncrementIntStat:
                        case EmoteType.InqIntStat:
                        case EmoteType.SetIntStat:
                            statLabel = $" /* PropertyInt.{(PropertyInt)input[i].Stat.Value} */";
                            break;

                        case EmoteType.InqAttributeStat:
                        case EmoteType.InqRawAttributeStat:
                            statLabel = $" /* PropertyAttribute.{(PropertyAttribute)input[i].Stat.Value} */";
                            break;

                        case EmoteType.InqBoolStat:
                        case EmoteType.SetBoolStat:
                            statLabel = $" /* PropertyBool.{(PropertyBool)input[i].Stat.Value} */";
                            break;

                        case EmoteType.InqFloatStat:
                        case EmoteType.SetFloatStat:
                            statLabel = $" /* PropertyFloat.{(PropertyFloat)input[i].Stat.Value} */";
                            break;

                        case EmoteType.InqInt64Stat:
                        case EmoteType.SetInt64Stat:
                            statLabel = $" /* PropertyInt64.{(PropertyInt64)input[i].Stat.Value} */";
                            break;

                        case EmoteType.InqSecondaryAttributeStat:
                        case EmoteType.InqRawSecondaryAttributeStat:
                            statLabel = $" /* PropertyAttribute2nd.{(PropertyAttribute2nd)input[i].Stat.Value} */";
                            break;

                        case EmoteType.InqStringStat:
                            statLabel = $" /* PropertyString.{(PropertyString)input[i].Stat.Value} */";
                            break;

                        default:
                            break;
                    }
                }

                string amountLabel = null;
                if (input[i].Amount.HasValue)
                {
                    switch ((EmoteType)input[i].Type)
                    {
                        case EmoteType.AddCharacterreplacedle:
                            amountLabel = $" /* {(Characterreplacedle)input[i].Amount.Value} */";
                            break;

                        case EmoteType.AddContract:
                        case EmoteType.RemoveContract:
                            amountLabel = $" /* {(ContractId)input[i].Amount.Value} */";
                            break;

                        default:
                            break;
                    }
                }

                string treasureClreplacedLabel = null;
                if (input[i].TreasureClreplaced.HasValue)
                {
                    treasureClreplacedLabel = Enum.GetName(typeof(TreasureClreplaced), input[i].TreasureClreplaced.Value);
                    if (treasureClreplacedLabel != null)
                        treasureClreplacedLabel = $" /* {treasureClreplacedLabel} */";
                }

                string treasureTypeLabel = null;
                if (input[i].TreasureType.HasValue)
                {
                    treasureTypeLabel = Enum.GetName(typeof(TreasureType), input[i].TreasureType.Value);
                    if (treasureTypeLabel != null)
                        treasureTypeLabel = $" /* {treasureTypeLabel} */";
                }

                string paletteLabel = null;
                if (input[i].Palette.HasValue)
                {
                    paletteLabel = Enum.GetName(typeof(PaletteTemplate), input[i].Palette.Value);
                    if (paletteLabel != null)
                        paletteLabel = $" /* {paletteLabel} */";
                }

                return
                    "@parent_id, " +
                    $"{input[i].Order.ToString().PadLeft(2)}, " +
                    $"{input[i].Type.ToString().PadLeft(3)}{typeLabel}, " +
                    $"{input[i].Delay:0.######}, " +
                    $"{input[i].Extent:0.######}, " +
                    $"{(input[i].Motion.HasValue ? "0x" : "")}{input[i].Motion:X8}{motionLabel}, " +
                    $"{GetSQLString(input[i].Message)}, " +
                    $"{GetSQLString(input[i].TestString)}, " +
                    $"{input[i].Min}, " +
                    $"{input[i].Max}, " +
                    $"{input[i].Min64}, " +
                    $"{input[i].Max64}, " +
                    $"{input[i].MinDbl}, " +
                    $"{input[i].MaxDbl}, " +
                    $"{input[i].Stat}{statLabel}, " +
                    $"{input[i].Display}, " +
                    $"{input[i].Amount}{amountLabel}, " +
                    $"{input[i].Amount64}, " +
                    $"{input[i].HeroXP64}, " +
                    $"{input[i].Percent}, " +
                    $"{input[i].SpellId}{spellIdLabel}, " +
                    $"{input[i].WealthRating}, " +
                    $"{input[i].TreasureClreplaced}{treasureClreplacedLabel}, " +
                    $"{input[i].TreasureType}{treasureTypeLabel}, " +
                    $"{input[i].PScript}{pScriptLabel}, " +
                    $"{input[i].Sound}{soundLabel}, " +
                    $"{input[i].DestinationType}{destinationTypeLabel}, " +
                    $"{input[i].WeenieClreplacedId}{weenieClreplacedIdLabel}, " +
                    $"{input[i].StackSize}, " +
                    $"{input[i].Palette}{paletteLabel}, " +
                    $"{input[i].Shade:0.######}, " +
                    $"{input[i].TryToBond}, " +
                    $"{(input[i].ObjCellId.HasValue ? "0x" : "")}{input[i].ObjCellId:X8}{telelocLabel}, " +
                    $"{TrimNegativeZero(input[i].OriginX):0.######}, " +
                    $"{TrimNegativeZero(input[i].OriginY):0.######}, " +
                    $"{TrimNegativeZero(input[i].OriginZ):0.######}, " +
                    $"{TrimNegativeZero(input[i].AnglesW):0.######}, " +
                    $"{TrimNegativeZero(input[i].AnglesX):0.######}, " +
                    $"{TrimNegativeZero(input[i].AnglesY):0.######}, " +
                    $"{TrimNegativeZero(input[i].AnglesZ):0.######})";
            });

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

19 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, WeeniePropertiesBook input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_book` (`object_Id`, `max_Num_Pages`, `max_Num_Chars_Per_Page`)");

           writer.WriteLine($"VALUES ({weenieClreplacedID}, {input.MaxNumPages}, {input.MaxNumCharsPerPage});");
        }

19 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesBookPageData> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_book_page_data` (`object_Id`, `page_Id`, `author_Id`, `author_Name`, `author_Account`, `ignore_Author`, `page_Text`)");

            var lineGenerator = new Func<int, string>(i => $"{weenieClreplacedID}, {input[i].PageId}, 0x{input[i].AuthorId:X8}, {GetSQLString(input[i].AuthorName)}, {GetSQLString(input[i].AuthorAccount)}, {input[i].IgnoreAuthor}, {GetSQLString(input[i].PageText)})");

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

19 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesPalette> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_palette` (`object_Id`, `sub_Palette_Id`, `offset`, `length`)");

            var lineGenerator = new Func<int, string>(i => $"{weenieClreplacedID}, {input[i].SubPaletteId}, {input[i].Offset}, {input[i].Length})");

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

19 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesTextureMap> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_texture_map` (`object_Id`, `index`, `old_Id`, `new_Id`)");

            var lineGenerator = new Func<int, string>(i => $"{weenieClreplacedID}, {input[i].Index}, {input[i].OldId}, {input[i].NewId})");

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

19 Source : WeenieSQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

public void CreateSQLINSERTStatement(uint weenieClreplacedID, IList<WeeniePropertiesAnimPart> input, StreamWriter writer)
        {
            writer.WriteLine("INSERT INTO `weenie_properties_anim_part` (`object_Id`, `index`, `animation_Id`)");

            var lineGenerator = new Func<int, string>(i => $"{weenieClreplacedID}, {input[i].Index}, {input[i].AnimationId})");

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

19 Source : SQLWriter.cs
with GNU Affero General Public License v3.0
from ACEmulator

protected static void ValuesWriter(int count, Func<int, string> lineGenerator, StreamWriter writer)
        {
            for (int i = 0; i < count; i++)
            {
                string output;

                if (i == 0)
                    output = "VALUES (";
                else
                    output = "     , (";

                output += lineGenerator(i);

                if (i == count - 1)
                    output += ";";

                output = FixNullFields(output);

                writer.WriteLine(output);
            }
        }

19 Source : Extensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static string BuildPacketString(this byte[] bytes, int startPosition = 0, int bytesToOutput = 9999)
        {
            TextWriter tw = new StringWriter();
            byte[] buffer = bytes;

            int column = 0;
            int row = 0;
            int columns = 16;
            tw.Write("   x  ");
            for (int i = 0; i < columns; i++)
            {
                tw.Write(i.ToString().PadLeft(3));
            }
            tw.WriteLine("  |Text");
            tw.Write("   0  ");

            string asciiLine = "";
            for (int i = startPosition; i < startPosition+bytesToOutput; i++)
            {
                if (i >= buffer.Length) {
                    break;
                }
                if (column >= columns)
                {
                    row++;
                    column = 0;
                    tw.WriteLine("  |" + asciiLine);
                    asciiLine = "";
                    tw.Write((row * columns).ToString().PadLeft(4));
                    tw.Write("  ");
                }

                tw.Write(buffer[i].ToString("X2").PadLeft(3));

                if (Char.IsControl((char)buffer[i]))
                    asciiLine += " ";
                else
                    asciiLine += (char)buffer[i];
                column++;
            }

            tw.Write("".PadLeft((columns - column) * 3));
            tw.WriteLine("  |" + asciiLine);
            return tw.ToString();
        }

19 Source : Logging.cs
with MIT License
from actions

public void Write(string message)
        {
            // lazy creation on write
            if (_pageWriter == null)
            {
                Create();
            }

            string line = $"{DateTime.UtcNow.ToString("O")} {message}";
            _pageWriter.WriteLine(line);

            _totalLines++;
            if (line.IndexOf('\n') != -1)
            {
                foreach (char c in line)
                {
                    if (c == '\n')
                    {
                        _totalLines++;
                    }
                }
            }

            _byteCount += System.Text.Encoding.UTF8.GetByteCount(line);
            if (_byteCount >= PageSize)
            {
                NewPage();
            }
        }

19 Source : Terminal.cs
with MIT License
from actions

public void WriteError(Exception ex)
        {
            Trace.Error("WRITE ERROR (exception):");
            Trace.Error(ex);
            if (!Silent)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Error.WriteLine(ex.Message);
                Console.ResetColor();
            }
        }

19 Source : Terminal.cs
with MIT License
from actions

public void WriteError(string line)
        {
            Trace.Error($"WRITE ERROR: {line}");
            if (!Silent)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Error.WriteLine(line);
                Console.ResetColor();
            }
        }

19 Source : Program.cs
with MIT License
from actions

public static int Main(string[] args)
        {
            Console.CancelKeyPress += Console_CancelKeyPress;

            // Set encoding to UTF8, process invoker will use UTF8 write to STDIN
            Console.InputEncoding = Encoding.UTF8;
            Console.OutputEncoding = Encoding.UTF8;
            try
            {
                ArgUtil.NotNull(args, nameof(args));
                ArgUtil.Equal(2, args.Length, nameof(args.Length));

                string pluginType = args[0];
                if (string.Equals("action", pluginType, StringComparison.OrdinalIgnoreCase))
                {
                    string replacedemblyQualifiedName = args[1];
                    ArgUtil.NotNullOrEmpty(replacedemblyQualifiedName, nameof(replacedemblyQualifiedName));

                    string serializedContext = Console.ReadLine();
                    ArgUtil.NotNullOrEmpty(serializedContext, nameof(serializedContext));

                    RunnerActionPluginExecutionContext executionContext = StringUtil.ConvertFromJson<RunnerActionPluginExecutionContext>(serializedContext);
                    ArgUtil.NotNull(executionContext, nameof(executionContext));

                    VariableValue culture;
                    ArgUtil.NotNull(executionContext.Variables, nameof(executionContext.Variables));
                    if (executionContext.Variables.TryGetValue("system.culture", out culture) &&
                        !string.IsNullOrEmpty(culture?.Value))
                    {
                        CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(culture.Value);
                        CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(culture.Value);
                    }

                    replacedemblyLoadContext.Default.Resolving += Resolvereplacedembly;
                    try
                    {
                        Type type = Type.GetType(replacedemblyQualifiedName, throwOnError: true);
                        var taskPlugin = Activator.CreateInstance(type) as IRunnerActionPlugin;
                        ArgUtil.NotNull(taskPlugin, nameof(taskPlugin));
                        taskPlugin.RunAsync(executionContext, tokenSource.Token).GetAwaiter().GetResult();
                    }
                    catch (Exception ex)
                    {
                        // any exception throw from plugin will fail the task.
                        executionContext.Error(ex.Message);
                        executionContext.Debug(ex.StackTrace);
                        return 1;
                    }
                    finally
                    {
                        replacedemblyLoadContext.Default.Resolving -= Resolvereplacedembly;
                    }

                    return 0;
                }
                else
                {
                    throw new ArgumentOutOfRangeException(pluginType);
                }
            }
            catch (Exception ex)
            {
                // infrastructure failure.
                Console.Error.WriteLine(ex.ToString());
                return 1;
            }
            finally
            {
                Console.CancelKeyPress -= Console_CancelKeyPress;
            }
        }

19 Source : ProcessInvoker.cs
with MIT License
from actions

private void StartWriteStream(Channel<string> redirectStandardIn, StreamWriter standardIn, bool keepStandardInOpen)
        {
            Task.Run(async () =>
            {
                // Write the contents as UTF8 to handle all characters.
                var utf8Writer = new StreamWriter(standardIn.BaseStream, new UTF8Encoding(false));

                while (!_processExitedCompletionSource.Task.IsCompleted)
                {
                    ValueTask<string> dequeueTask = redirectStandardIn.Reader.ReadAsync(_processStandardInWriteCancellationTokenSource.Token);
                    string input = await dequeueTask;
                    if (input != null)
                    {
                        utf8Writer.WriteLine(input);
                        utf8Writer.Flush();

                        if (!keepStandardInOpen)
                        {
                            Trace.Info("Close STDIN after the first redirect finished.");
                            standardIn.Close();
                            break;
                        }
                    }
                }

                Trace.Info("STDIN stream write finished.");
            });
        }

19 Source : ConnectedInstruction_BACKUP_44876.cs
with BSD 3-Clause "New" or "Revised" License
from ActuarialIntelligence

public static void WritetoCsvu(IList<IList<double>> gridValues, string path)
        {
            Console.WriteLine("Write Begin " + DateTime.Now.ToString());
            var sw = new StreamWriter(path);
            var cnt = 0;
            foreach (var row in gridValues)
            {
                sw.WriteLine(row[0] + "," + row[1] + "," + row[2] + "," + row[3] + "," + row[4] + "," + row[5] + "," + row[6]);
                cnt++;
            }
            sw.Close();
            Console.WriteLine("Write Complete " + DateTime.Now.ToString());
        }

19 Source : Program.cs
with Apache License 2.0
from adamralph

public static int Main(string[] args)
        {
            if (args.Contains("unicode"))
            {
                Console.OutputEncoding = Encoding.Unicode;
                args = args.Concat(new[] { "Pi (\u03a0)" }).ToArray();
            }

            var input = args.Contains("in")
                ? Console.In.ReadToEnd()
                    .Replace("\r", "\\r", StringComparison.Ordinal)
                    .Replace("\n", "\\n", StringComparison.Ordinal)
                : null;

            Console.Out.WriteLine($"SimpleExecTester (stdin): {input}");
            Console.Out.WriteLine($"SimpleExecTester (stdout): {string.Join(" ", args)}");
            Console.Error.WriteLine($"SimpleExecTester (stderr): {string.Join(" ", args)}");

            if (args.Contains("large"))
            {
                Console.Out.WriteLine(new string('x', (int)Math.Pow(2, 12)));
                Console.Error.WriteLine(new string('x', (int)Math.Pow(2, 12)));
            }

            var exitCode = 0;
            if (args.FirstOrDefault(arg => int.TryParse(arg, out exitCode)) != null)
            {
                return exitCode;
            }

            if (args.Contains("sleep"))
            {
                Thread.Sleep(Timeout.Infinite);
                return 0;
            }

            Console.WriteLine($"foo={Environment.GetEnvironmentVariable("foo")}");

            return 0;
        }

19 Source : ProcessExtensions.cs
with Apache License 2.0
from adamralph

public static void Run(this Process process, bool noEcho, string echoPrefix, CancellationToken cancellationToken)
        {
            var cancelled = 0L;

            if (!noEcho)
            {
                Console.Out.WriteLine(process.GetMessage(echoPrefix));
            }

            _ = process.Start();

            using (cancellationToken.Register(
                () =>
                {
                    if (process.TryKill())
                    {
                        _ = Interlocked.Increment(ref cancelled);
                    }
                },
                useSynchronizationContext: false))
            {
                process.WaitForExit();
            }

            if (Interlocked.Read(ref cancelled) == 1)
            {
                cancellationToken.ThrowIfCancellationRequested();
            }
        }

19 Source : POGenerator.cs
with MIT License
from adams85

private void WriteComments(IList<POComment> comments)
        {
            IOrderedEnumerable<IGrouping<POCommentKind, POComment>> commentLookup = comments.ToLookup(c => c.Kind).OrderBy(c => c.Key);

            foreach (IGrouping<POCommentKind, POComment> commentGroup in commentLookup)
                foreach (POComment comment in commentGroup)
                {
                    char commentKindToken;
                    switch (comment.Kind)
                    {
                        case POCommentKind.Translator: commentKindToken = ' '; break;
                        case POCommentKind.Extracted: commentKindToken = '.'; break;
                        case POCommentKind.Reference: commentKindToken = ':'; break;
                        case POCommentKind.Flags: commentKindToken = ','; break;
                        case POCommentKind.PreviousValue: commentKindToken = '|'; break;
                        default: throw new InvalidOperationException();
                    }

                    _writer.WriteLine($"#{commentKindToken} {comment}");
                }
        }

See More Examples