{"size":4303,"ext":"cs","lang":"C#","max_stars_count":1.0,"content":"\ufeffusing System;\nusing System.Activities;\nusing System.Activities.Core.Presentation;\nusing System.Activities.Presentation;\nusing System.Activities.Presentation.Toolbox;\nusing System.Activities.Presentation.View;\nusing System.Activities.Statements;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Windows;\nusing System.Windows.Controls;\nusing System.Windows.Data;\nusing System.Windows.Documents;\nusing System.Windows.Input;\nusing System.Windows.Media;\nusing System.Windows.Media.Imaging;\nusing System.Windows.Navigation;\nusing System.Windows.Shapes;\n\nnamespace HostingApplication\n{\n \/\/\/ \n \/\/\/ Interaction logic for TestCaseDesigner.xaml\n \/\/\/ <\/summary>\n public partial class TestCaseDesigner1 : UserControl\n {\n private WorkflowDesigner wd;\n public TestCaseDesigner1()\n {\n InitializeComponent();\n\n RegisterMetadata();\n\n \/\/ Add the WFF Designer\n AddDesigner();\n\n AddToolBox();\n\n this.AddPropertyInspector();\n }\n\n private void RegisterMetadata()\n {\n DesignerMetadata dm = new DesignerMetadata();\n dm.Register();\n }\n\n private void AddDesigner()\n {\n \/\/Create an instance of WorkflowDesigner class.\n this.wd = new WorkflowDesigner();\n\n \/\/Place the designer canvas in the middle column of the grid.\n Grid.SetColumn(this.wd.View, 1);\n\n\n ActivityBuilder activityBuilderType = new ActivityBuilder();\n activityBuilderType.Name = \"Activity Builder\";\n activityBuilderType.Implementation = new Sequence()\n {\n DisplayName = \"Default Template\",\n Activities =\n {\n \t\t new WriteLine()\n {\n \t\t Text = \"Workflow Rehosted Designer\"\n }\n }\n };\n\n \/\/Load a new Sequence as default.\n this.wd.Load(activityBuilderType);\n\n\n\n\n \/\/Add the designer canvas to the grid.\n grid1.Children.Add(this.wd.View);\n\n this.wd.Context.Services.GetService().WorkflowShellBarItemVisibility\n = ShellBarItemVisibility.All;\n\n\n }\n\n private ToolboxControl GetToolboxControl()\n {\n \/\/ Create the ToolBoxControl.\n ToolboxControl ctrl = new ToolboxControl();\n\n \/\/ Create a category.\n ToolboxCategory category = new ToolboxCategory(\"category1\");\n\n \/\/ Create Toolbox items.\n ToolboxItemWrapper tool1 =\n new ToolboxItemWrapper(\"System.Activities.Statements.Assign\",\n typeof(Assign).Assembly.FullName, null, \"Assign\");\n\n ToolboxItemWrapper tool2 = new ToolboxItemWrapper(\"System.Activities.Statements.Sequence\",\n typeof(Sequence).Assembly.FullName, null, \"Sequence\");\n\n\n ToolboxItemWrapper tool3 = new ToolboxItemWrapper(\"System.Activities.Statements.WriteLine\",\n typeof(Sequence).Assembly.FullName, null, \"WriteLine\");\n\n\n \/\/ToolboxItemWrapper tool4 = new ToolboxItemWrapper(\"ActivityLibrary.CodeActivity1\",\n \/\/ typeof(ActivityLibrary.CodeActivity1).Assembly.FullName, null, \"CodeActivit1\");\n\n\n ToolboxItemWrapper tool5 = new ToolboxItemWrapper(\"ActivityLibrary.Activity1\",\n typeof(ActivityLibrary.Activity1).Assembly.FullName, null, \"Activity1\");\n\n\n\n \/\/ Add the Toolbox items to the category.\n category.Add(tool1);\n category.Add(tool2);\n category.Add(tool3);\n \/\/category.Add(tool4);\n category.Add(tool5);\n\n \/\/ Add the category to the ToolBox control.\n ctrl.Categories.Add(category);\n return ctrl;\n }\n\n private void AddToolBox()\n {\n ToolboxControl tc = GetToolboxControl();\n Grid.SetColumn(tc, 0);\n grid1.Children.Add(tc);\n }\n\n private void AddPropertyInspector()\n {\n Grid.SetColumn(wd.PropertyInspectorView, 2);\n grid1.Children.Add(wd.PropertyInspectorView);\n }\n }\n}\n","avg_line_length":29.8819444444,"max_line_length":103,"alphanum_fraction":0.6063211713} {"size":483,"ext":"cs","lang":"C#","max_stars_count":null,"content":"\ufeff\/*\n * Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.\n * See LICENSE in the source repository root for complete license information.\n *\/\n\nusing Windows.UI.Xaml.Navigation;\nusing Windows.UI.Xaml.Controls;\n\nnamespace ExcelServiceExplorer.Views\n{\n public sealed partial class AddChart : Page\n {\n public AddChart()\n {\n InitializeComponent();\n NavigationCacheMode = NavigationCacheMode.Disabled;\n }\n }\n}","avg_line_length":25.4210526316,"max_line_length":81,"alphanum_fraction":0.6811594203} {"size":10292,"ext":"cs","lang":"C#","max_stars_count":1.0,"content":"using System;\nusing NetRuntimeSystem = System;\nusing System.ComponentModel;\nusing NetOffice;\nnamespace NetOffice.VisioApi\n{\n\n\t#region Delegates\n\n\t#pragma warning disable\n\t#pragma warning restore\n\n\t#endregion\n\n\t\/\/\/\n\t\/\/\/ CoClass Comment \n\t\/\/\/ SupportByVersion Visio, 15, 16\n\t\/\/\/<\/summary>\n\t[SupportByVersionAttribute(\"Visio\", 15, 16)]\n\t[EntityTypeAttribute(EntityType.IsCoClass)]\n\tpublic class Comment : IVComment\n\t{\n\t\t#pragma warning disable\n\t\t#region Fields\n\t\t\n\t\tprivate NetRuntimeSystem.Runtime.InteropServices.ComTypes.IConnectionPoint _connectPoint;\n\t\tprivate string _activeSinkId;\n\t\tprivate NetRuntimeSystem.Type _thisType;\n\t\n\t\t#endregion\n\n\t\t#region Type Information\n\n private static Type _type;\n\t\t\n\t\t[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]\n public static Type LateBindingApiWrapperType\n {\n get\n {\n if (null == _type)\n _type = typeof(Comment);\n return _type;\n }\n }\n \n #endregion\n \t\t\n\t\t#region Construction\n\n\t\t\/\/\/current used factory core<\/param>\n\t\t\/\/\/object there has created the proxy<\/param>\n \/\/\/inner wrapped COM proxy<\/param>\n\t\tpublic Comment(Core factory, COMObject parentObject, object comProxy) : base(factory, parentObject, comProxy)\n\t\t{\n\t\t\t\n\t\t}\n\n \/\/\/object there has created the proxy<\/param>\n \/\/\/inner wrapped COM proxy<\/param>\n\t\tpublic Comment(COMObject parentObject, object comProxy) : base(parentObject, comProxy)\n\t\t{\n\t\t\t\n\t\t}\n\n\t\t\/\/\/current used factory core<\/param>\n\t\t\/\/\/object there has created the proxy<\/param>\n \/\/\/inner wrapped COM proxy<\/param>\n \/\/\/Type of inner wrapped COM proxy\"<\/param>\n\t\t[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]\n\t\tpublic Comment(Core factory, COMObject parentObject, object comProxy, NetRuntimeSystem.Type comProxyType) : base(factory, parentObject, comProxy, comProxyType)\n\t\t{\n\t\t\t\n\t\t}\n\n\t\t\/\/\/object there has created the proxy<\/param>\n \/\/\/inner wrapped COM proxy<\/param>\n \/\/\/Type of inner wrapped COM proxy\"<\/param>\n\t\t[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]\n\t\tpublic Comment(COMObject parentObject, object comProxy, NetRuntimeSystem.Type comProxyType) : base(parentObject, comProxy, comProxyType)\n\t\t{\n\t\t\t\n\t\t}\n\t\t\n\t\t\/\/\/object to replaced. replacedObject are not usable after this action<\/param>\n\t\t[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]\n\t\tpublic Comment(COMObject replacedObject) : base(replacedObject)\n\t\t{\n\t\t\t\n\t\t}\n\t\t\n\t\t\/\/\/\n \/\/\/ Creates a new instance of Comment \n \/\/\/<\/summary>\t\t\n\t\tpublic Comment():base(\"Visio.Comment\")\n\t\t{\n\t\t\t\n\t\t}\n\t\t\n\t\t\/\/\/\n \/\/\/ Creates a new instance of Comment\n \/\/\/<\/summary>\n \/\/\/registered ProgID<\/param>\n\t\tpublic Comment(string progId):base(progId)\n\t\t{\n\t\t\t\n\t\t}\n\n\t\t#endregion\n\n\t\t#region Static CoClass Methods\n\n\t\t\/\/\/ \n \/\/\/ Returns all running Visio.Comment objects from the environment\/system\n \/\/\/ <\/summary>\n \/\/\/ an Visio.Comment array<\/returns>\n\t\tpublic static NetOffice.VisioApi.Comment[] GetActiveInstances()\n\t\t{\t\t\n\t\t\tIDisposableEnumeration proxyList = NetOffice.ProxyService.GetActiveInstances(\"Visio\",\"Comment\");\n\t\t\tNetRuntimeSystem.Collections.Generic.List resultList = new NetRuntimeSystem.Collections.Generic.List();\n\t\t\tforeach(object proxy in proxyList)\n\t\t\t\tresultList.Add( new NetOffice.VisioApi.Comment(null, proxy) );\n\t\t\treturn resultList.ToArray();\n\t\t}\n\n\t\t\/\/\/ \n \/\/\/ Returns a running Visio.Comment object from the environment\/system.\n \/\/\/ <\/summary>\n \/\/\/ an Visio.Comment object or null<\/returns>\n\t\tpublic static NetOffice.VisioApi.Comment GetActiveInstance()\n\t\t{\n\t\t\tobject proxy = NetOffice.ProxyService.GetActiveInstance(\"Visio\",\"Comment\", false);\n\t\t\tif(null != proxy)\n\t\t\t\treturn new NetOffice.VisioApi.Comment(null, proxy);\n\t\t\telse\n\t\t\t\treturn null;\n\t\t}\n\n\t\t\/\/\/ \n \/\/\/ Returns a running Visio.Comment object from the environment\/system. \n \/\/\/ <\/summary>\n\t \/\/\/ throw an exception if no object was found<\/param>\n \/\/\/ an Visio.Comment object or null<\/returns>\n\t\tpublic static NetOffice.VisioApi.Comment GetActiveInstance(bool throwOnError)\n\t\t{\n\t\t\tobject proxy = NetOffice.ProxyService.GetActiveInstance(\"Visio\",\"Comment\", throwOnError);\n\t\t\tif(null != proxy)\n\t\t\t\treturn new NetOffice.VisioApi.Comment(null, proxy);\n\t\t\telse\n\t\t\t\treturn null;\n\t\t}\n\t\t#endregion\n\n\t\t#region Events\n\n\t\t#endregion\n \n\t #region IEventBinding Member\n \n\t\t\/\/\/ \n \/\/\/ Creates active sink helper\n \/\/\/ <\/summary>\n\t\t[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]\n\t\tpublic void CreateEventBridge()\n {\n\t\t\tif(false == Factory.Settings.EnableEvents)\n\t\t\t\treturn;\n\t\n\t\t\tif (null != _connectPoint)\n\t\t\t\treturn;\n\t\n if (null == _activeSinkId)\n\t\t\t\t_activeSinkId = SinkHelper.GetConnectionPoint(this, ref _connectPoint, null);\n\n \n }\n\n \/\/\/ \n \/\/\/ The instance use currently an event listener \n \/\/\/ <\/summary>\n [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]\n public bool EventBridgeInitialized\n {\n get \n {\n return (null != _connectPoint);\n }\n }\n\n \/\/\/ \n \/\/\/ The instance has currently one or more event recipients \n \/\/\/ <\/summary>\n [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]\n public bool HasEventRecipients() \n {\n\t\t\tif(null == _thisType)\n\t\t\t\t_thisType = this.GetType();\n\t\t\t\t\t\n\t\t\tforeach (NetRuntimeSystem.Reflection.EventInfo item in _thisType.GetEvents())\n\t\t\t{\n\t\t\t\tMulticastDelegate eventDelegate = (MulticastDelegate) _thisType.GetType().GetField(item.Name, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNetRuntimeSystem.Reflection.BindingFlags.NonPublic |\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tNetRuntimeSystem.Reflection.BindingFlags.Instance).GetValue(this);\n\t\t\t\t\t\n\t\t\t\tif( (null != eventDelegate) && (eventDelegate.GetInvocationList().Length > 0) )\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\t\t\n\t\t\treturn false;\n }\n \n \/\/\/ \n \/\/\/ Target methods from its actual event recipients\n \/\/\/ <\/summary>\n\t\t[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]\n public Delegate[] GetEventRecipients(string eventName)\n {\n\t\t\tif(null == _thisType)\n\t\t\t\t_thisType = this.GetType();\n \n MulticastDelegate eventDelegate = (MulticastDelegate)_thisType.GetField(\n \"_\" + eventName + \"Event\",\n NetRuntimeSystem.Reflection.BindingFlags.Instance |\n NetRuntimeSystem.Reflection.BindingFlags.NonPublic).GetValue(this);\n\n if (null != eventDelegate)\n {\n Delegate[] delegates = eventDelegate.GetInvocationList();\n return delegates;\n }\n else\n return new Delegate[0];\n }\n \n \/\/\/ \n \/\/\/ Returns the current count of event recipients\n \/\/\/ <\/summary>\n\t\t[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]\n public int GetCountOfEventRecipients(string eventName)\n {\n\t\t\tif(null == _thisType)\n\t\t\t\t_thisType = this.GetType();\n \n MulticastDelegate eventDelegate = (MulticastDelegate)_thisType.GetField(\n \"_\" + eventName + \"Event\",\n NetRuntimeSystem.Reflection.BindingFlags.Instance |\n NetRuntimeSystem.Reflection.BindingFlags.NonPublic).GetValue(this);\n\n if (null != eventDelegate)\n {\n Delegate[] delegates = eventDelegate.GetInvocationList();\n return delegates.Length;\n }\n else\n return 0;\n }\n \n \/\/\/ \n \/\/\/ Raise an instance event\n \/\/\/ <\/summary>\n \/\/\/ name of the event without 'Event' at the end<\/param>\n \/\/\/ custom arguments for the event<\/param>\n \/\/\/ count of called event recipients<\/returns>\n\t\t[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]\n public int RaiseCustomEvent(string eventName, ref object[] paramsArray)\n\t\t{\n\t\t\tif(null == _thisType)\n\t\t\t\t_thisType = this.GetType();\n \n MulticastDelegate eventDelegate = (MulticastDelegate)_thisType.GetField(\n \"_\" + eventName + \"Event\",\n NetRuntimeSystem.Reflection.BindingFlags.Instance |\n NetRuntimeSystem.Reflection.BindingFlags.NonPublic).GetValue(this);\n\n if (null != eventDelegate)\n {\n Delegate[] delegates = eventDelegate.GetInvocationList();\n foreach (var item in delegates)\n {\n try\n {\n item.Method.Invoke(item.Target, paramsArray);\n }\n catch (NetRuntimeSystem.Exception exception)\n {\n Factory.Console.WriteException(exception);\n }\n }\n return delegates.Length;\n }\n else\n return 0;\n\t\t}\n\n \/\/\/ \n \/\/\/ Stop listening events for the instance\n \/\/\/ <\/summary>\n [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]\n public void DisposeEventBridge()\n {\n\n\t\t\t_connectPoint = null;\n\t\t}\n \n #endregion\n\n\t\t#pragma warning restore\n\t}\n}","avg_line_length":33.3074433657,"max_line_length":162,"alphanum_fraction":0.6076564322} {"size":836,"ext":"cs","lang":"C#","max_stars_count":56.0,"content":"\/\/------------------------------------------------------------------------------\n\/\/ \n\/\/ This code was generated from a template.\n\/\/\n\/\/ Manual changes to this file may cause unexpected behavior in your application.\n\/\/ Manual changes to this file will be overwritten if the code is regenerated.\n\/\/ <\/auto-generated>\n\/\/------------------------------------------------------------------------------\n\nnamespace Models.NorthwindIB.EDMX_2012\n{\n using System;\n using System.Collections.Generic;\n \n public partial class TimeGroup\n {\n public TimeGroup()\n {\n this.TimeLimits = new HashSet();\n }\n \n public int Id { get; set; }\n public string Comment { get; set; }\n \n public virtual ICollection TimeLimits { get; set; }\n }\n}\n","avg_line_length":29.8571428571,"max_line_length":84,"alphanum_fraction":0.5119617225} {"size":31919,"ext":"cs","lang":"C#","max_stars_count":null,"content":"using System;\r\nusing System.IO;\r\nusing System.Collections;\r\nusing System.Collections.Generic;\r\nusing UltimaOnline;\r\nusing UltimaOnline.Mobiles;\r\nusing UltimaOnline.Network;\r\nusing UltimaOnline.Targeting;\r\nusing UltimaOnline.ContextMenus;\r\n\r\nnamespace UltimaOnline.Items\r\n{\r\n public class TreasureMap : MapItem\r\n {\r\n private int m_Level;\r\n private bool m_Completed;\r\n private Mobile m_CompletedBy;\r\n private Mobile m_Decoder;\r\n private Map m_Map;\r\n private Point2D m_Location;\r\n\r\n [CommandProperty(AccessLevel.GameMaster)]\r\n public int Level { get { return m_Level; } set { m_Level = value; InvalidateProperties(); } }\r\n\r\n [CommandProperty(AccessLevel.GameMaster)]\r\n public bool Completed { get { return m_Completed; } set { m_Completed = value; InvalidateProperties(); } }\r\n\r\n [CommandProperty(AccessLevel.GameMaster)]\r\n public Mobile CompletedBy { get { return m_CompletedBy; } set { m_CompletedBy = value; InvalidateProperties(); } }\r\n\r\n [CommandProperty(AccessLevel.GameMaster)]\r\n public Mobile Decoder { get { return m_Decoder; } set { m_Decoder = value; InvalidateProperties(); } }\r\n\r\n [CommandProperty(AccessLevel.GameMaster)]\r\n public Map ChestMap { get { return m_Map; } set { m_Map = value; InvalidateProperties(); } }\r\n\r\n [CommandProperty(AccessLevel.GameMaster)]\r\n public Point2D ChestLocation { get { return m_Location; } set { m_Location = value; } }\r\n\r\n private static Point2D[] m_Locations;\r\n private static Point2D[] m_HavenLocations;\r\n\r\n private static Type[][] m_SpawnTypes = new Type[][]\r\n {\r\n new Type[]{ typeof( HeadlessOne ), typeof( Skeleton ) },\r\n new Type[]{ typeof( Mongbat ), typeof( Ratman ), typeof( HeadlessOne ), typeof( Skeleton ), typeof( Zombie ) },\r\n new Type[]{ typeof( OrcishMage ), typeof( Gargoyle ), typeof( Gazer ), typeof( HellHound ), typeof( EarthElemental ) },\r\n new Type[]{ typeof( Lich ), typeof( OgreLord ), typeof( DreadSpider ), typeof( AirElemental ), typeof( FireElemental ) },\r\n new Type[]{ typeof( DreadSpider ), typeof( LichLord ), typeof( Daemon ), typeof( ElderGazer ), typeof( OgreLord ) },\r\n new Type[]{ typeof( LichLord ), typeof( Daemon ), typeof( ElderGazer ), typeof( PoisonElemental ), typeof( BloodElemental ) },\r\n new Type[]{ typeof( AncientWyrm ), typeof( Balron ), typeof( BloodElemental ), typeof( PoisonElemental ), typeof( Titan ) }\r\n };\r\n\r\n public const double LootChance = 0.01; \/\/ 1% chance to appear as loot\r\n\r\n public static Point2D GetRandomLocation()\r\n {\r\n if (m_Locations == null)\r\n LoadLocations();\r\n\r\n if (m_Locations.Length > 0)\r\n return m_Locations[Utility.Random(m_Locations.Length)];\r\n\r\n return Point2D.Zero;\r\n }\r\n\r\n public static Point2D GetRandomHavenLocation()\r\n {\r\n if (m_HavenLocations == null)\r\n LoadLocations();\r\n\r\n if (m_HavenLocations.Length > 0)\r\n return m_HavenLocations[Utility.Random(m_HavenLocations.Length)];\r\n\r\n return Point2D.Zero;\r\n }\r\n\r\n private static void LoadLocations()\r\n {\r\n string filePath = Path.Combine(Core.BaseDirectory, \"Data\/treasure.cfg\");\r\n\r\n List list = new List();\r\n List havenList = new List();\r\n\r\n if (File.Exists(filePath))\r\n {\r\n using (StreamReader ip = new StreamReader(filePath))\r\n {\r\n string line;\r\n\r\n while ((line = ip.ReadLine()) != null)\r\n {\r\n try\r\n {\r\n string[] split = line.Split(' ');\r\n\r\n int x = Convert.ToInt32(split[0]), y = Convert.ToInt32(split[1]);\r\n\r\n Point2D loc = new Point2D(x, y);\r\n list.Add(loc);\r\n\r\n if (IsInHavenIsland(loc))\r\n havenList.Add(loc);\r\n }\r\n catch\r\n {\r\n }\r\n }\r\n }\r\n }\r\n\r\n m_Locations = list.ToArray();\r\n m_HavenLocations = havenList.ToArray();\r\n }\r\n\r\n public static bool IsInHavenIsland(IPoint2D loc)\r\n {\r\n return (loc.X >= 3314 && loc.X <= 3814 && loc.Y >= 2345 && loc.Y <= 3095);\r\n }\r\n\r\n public static BaseCreature Spawn(int level, Point3D p, bool guardian)\r\n {\r\n if (level >= 0 && level < m_SpawnTypes.Length)\r\n {\r\n BaseCreature bc;\r\n\r\n try\r\n {\r\n bc = (BaseCreature)Activator.CreateInstance(m_SpawnTypes[level][Utility.Random(m_SpawnTypes[level].Length)]);\r\n }\r\n catch\r\n {\r\n return null;\r\n }\r\n\r\n bc.Home = p;\r\n bc.RangeHome = 5;\r\n\r\n if (guardian && level == 0)\r\n {\r\n bc.Name = \"a chest guardian\";\r\n bc.Hue = 0x835;\r\n }\r\n\r\n return bc;\r\n }\r\n\r\n return null;\r\n }\r\n\r\n public static BaseCreature Spawn(int level, Point3D p, Map map, Mobile target, bool guardian)\r\n {\r\n if (map == null)\r\n return null;\r\n\r\n BaseCreature c = Spawn(level, p, guardian);\r\n\r\n if (c != null)\r\n {\r\n bool spawned = false;\r\n\r\n for (int i = 0; !spawned && i < 10; ++i)\r\n {\r\n int x = p.X - 3 + Utility.Random(7);\r\n int y = p.Y - 3 + Utility.Random(7);\r\n\r\n if (map.CanSpawnMobile(x, y, p.Z))\r\n {\r\n c.MoveToWorld(new Point3D(x, y, p.Z), map);\r\n spawned = true;\r\n }\r\n else\r\n {\r\n int z = map.GetAverageZ(x, y);\r\n\r\n if (map.CanSpawnMobile(x, y, z))\r\n {\r\n c.MoveToWorld(new Point3D(x, y, z), map);\r\n spawned = true;\r\n }\r\n }\r\n }\r\n\r\n if (!spawned)\r\n {\r\n c.Delete();\r\n return null;\r\n }\r\n\r\n if (target != null)\r\n c.Combatant = target;\r\n\r\n return c;\r\n }\r\n\r\n return null;\r\n }\r\n\r\n [Constructable]\r\n public TreasureMap(int level, Map map)\r\n {\r\n m_Level = level;\r\n m_Map = map;\r\n\r\n if (level == 0)\r\n m_Location = GetRandomHavenLocation();\r\n else\r\n m_Location = GetRandomLocation();\r\n\r\n Width = 300;\r\n Height = 300;\r\n\r\n int width = 600;\r\n int height = 600;\r\n\r\n int x1 = m_Location.X - Utility.RandomMinMax(width \/ 4, (width \/ 4) * 3);\r\n int y1 = m_Location.Y - Utility.RandomMinMax(height \/ 4, (height \/ 4) * 3);\r\n\r\n if (x1 < 0)\r\n x1 = 0;\r\n\r\n if (y1 < 0)\r\n y1 = 0;\r\n\r\n int x2 = x1 + width;\r\n int y2 = y1 + height;\r\n\r\n if (x2 >= 5120)\r\n x2 = 5119;\r\n\r\n if (y2 >= 4096)\r\n y2 = 4095;\r\n\r\n x1 = x2 - width;\r\n y1 = y2 - height;\r\n\r\n Bounds = new Rectangle2D(x1, y1, width, height);\r\n Protected = true;\r\n\r\n AddWorldPin(m_Location.X, m_Location.Y);\r\n }\r\n\r\n public TreasureMap(Serial serial) : base(serial)\r\n {\r\n }\r\n\r\n public static bool HasDiggingTool(Mobile m)\r\n {\r\n if (m.Backpack == null)\r\n return false;\r\n\r\n List items = m.Backpack.FindItemsByType();\r\n\r\n foreach (BaseHarvestTool tool in items)\r\n {\r\n if (tool.HarvestSystem == Engines.Harvest.Mining.System)\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n public void OnBeginDig(Mobile from)\r\n {\r\n if (m_Completed)\r\n {\r\n from.SendLocalizedMessage(503028); \/\/ The treasure for this map has already been found.\r\n }\r\n else if (m_Level == 0 && !CheckYoung(from))\r\n {\r\n from.SendLocalizedMessage(1046447); \/\/ Only a young player may use this treasure map.\r\n }\r\n \/*\r\n\t\t\telse if ( from != m_Decoder )\r\n\t\t\t{\r\n\t\t\t\tfrom.SendLocalizedMessage( 503016 ); \/\/ Only the person who decoded this map may actually dig up the treasure.\r\n\t\t\t}\r\n\t\t\t*\/\r\n else if (m_Decoder != from && !HasRequiredSkill(from))\r\n {\r\n from.SendLocalizedMessage(503031); \/\/ You did not decode this map and have no clue where to look for the treasure.\r\n }\r\n else if (!from.CanBeginAction(typeof(TreasureMap)))\r\n {\r\n from.SendLocalizedMessage(503020); \/\/ You are already digging treasure.\r\n }\r\n else if (from.Map != this.m_Map)\r\n {\r\n from.SendLocalizedMessage(1010479); \/\/ You seem to be in the right place, but may be on the wrong facet!\r\n }\r\n else\r\n {\r\n from.SendLocalizedMessage(503033); \/\/ Where do you wish to dig?\r\n from.Target = new DigTarget(this);\r\n }\r\n }\r\n\r\n private class DigTarget : Target\r\n {\r\n private TreasureMap m_Map;\r\n\r\n public DigTarget(TreasureMap map) : base(6, true, TargetFlags.None)\r\n {\r\n m_Map = map;\r\n }\r\n\r\n protected override void OnTarget(Mobile from, object targeted)\r\n {\r\n if (m_Map.Deleted)\r\n return;\r\n\r\n Map map = m_Map.m_Map;\r\n\r\n if (m_Map.m_Completed)\r\n {\r\n from.SendLocalizedMessage(503028); \/\/ The treasure for this map has already been found.\r\n }\r\n \/*\r\n\t\t\t\telse if ( from != m_Map.m_Decoder )\r\n\t\t\t\t{\r\n\t\t\t\t\tfrom.SendLocalizedMessage( 503016 ); \/\/ Only the person who decoded this map may actually dig up the treasure.\r\n\t\t\t\t}\r\n\t\t\t\t*\/\r\n else if (m_Map.m_Decoder != from && !m_Map.HasRequiredSkill(from))\r\n {\r\n from.SendLocalizedMessage(503031); \/\/ You did not decode this map and have no clue where to look for the treasure.\r\n return;\r\n }\r\n else if (!from.CanBeginAction(typeof(TreasureMap)))\r\n {\r\n from.SendLocalizedMessage(503020); \/\/ You are already digging treasure.\r\n }\r\n else if (!HasDiggingTool(from))\r\n {\r\n from.SendMessage(\"You must have a digging tool to dig for treasure.\");\r\n }\r\n else if (from.Map != map)\r\n {\r\n from.SendLocalizedMessage(1010479); \/\/ You seem to be in the right place, but may be on the wrong facet!\r\n }\r\n else\r\n {\r\n IPoint3D p = targeted as IPoint3D;\r\n\r\n Point3D targ3D;\r\n if (p is Item)\r\n targ3D = ((Item)p).GetWorldLocation();\r\n else\r\n targ3D = new Point3D(p);\r\n\r\n int maxRange;\r\n double skillValue = from.Skills[SkillName.Mining].Value;\r\n\r\n if (skillValue >= 100.0)\r\n maxRange = 4;\r\n else if (skillValue >= 81.0)\r\n maxRange = 3;\r\n else if (skillValue >= 51.0)\r\n maxRange = 2;\r\n else\r\n maxRange = 1;\r\n\r\n Point2D loc = m_Map.m_Location;\r\n int x = loc.X, y = loc.Y;\r\n\r\n Point3D chest3D0 = new Point3D(loc, 0);\r\n\r\n if (Utility.InRange(targ3D, chest3D0, maxRange))\r\n {\r\n if (from.Location.X == x && from.Location.Y == y)\r\n {\r\n from.SendLocalizedMessage(503030); \/\/ The chest can't be dug up because you are standing on top of it.\r\n }\r\n else if (map != null)\r\n {\r\n int z = map.GetAverageZ(x, y);\r\n\r\n if (!map.CanFit(x, y, z, 16, true, true))\r\n {\r\n from.SendLocalizedMessage(503021); \/\/ You have found the treasure chest but something is keeping it from being dug up.\r\n }\r\n else if (from.BeginAction(typeof(TreasureMap)))\r\n {\r\n new DigTimer(from, m_Map, new Point3D(x, y, z), map).Start();\r\n }\r\n else\r\n {\r\n from.SendLocalizedMessage(503020); \/\/ You are already digging treasure.\r\n }\r\n }\r\n }\r\n else if (m_Map.Level > 0)\r\n {\r\n if (Utility.InRange(targ3D, chest3D0, 8)) \/\/ We're close, but not quite\r\n {\r\n from.SendLocalizedMessage(503032); \/\/ You dig and dig but no treasure seems to be here.\r\n }\r\n else\r\n {\r\n from.SendLocalizedMessage(503035); \/\/ You dig and dig but fail to find any treasure.\r\n }\r\n }\r\n else\r\n {\r\n if (Utility.InRange(targ3D, chest3D0, 8)) \/\/ We're close, but not quite\r\n {\r\n from.SendAsciiMessage(0x44, \"The treasure chest is very close!\");\r\n }\r\n else\r\n {\r\n Direction dir = Utility.GetDirection(targ3D, chest3D0);\r\n\r\n string sDir;\r\n switch (dir)\r\n {\r\n case Direction.North: sDir = \"north\"; break;\r\n case Direction.Right: sDir = \"northeast\"; break;\r\n case Direction.East: sDir = \"east\"; break;\r\n case Direction.Down: sDir = \"southeast\"; break;\r\n case Direction.South: sDir = \"south\"; break;\r\n case Direction.Left: sDir = \"southwest\"; break;\r\n case Direction.West: sDir = \"west\"; break;\r\n default: sDir = \"northwest\"; break;\r\n }\r\n\r\n from.SendAsciiMessage(0x44, \"Try looking for the treasure chest more to the {0}.\", sDir);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private class DigTimer : Timer\r\n {\r\n private Mobile m_From;\r\n private TreasureMap m_TreasureMap;\r\n\r\n private Point3D m_Location;\r\n private Map m_Map;\r\n\r\n private TreasureChestDirt m_Dirt1;\r\n private TreasureChestDirt m_Dirt2;\r\n private TreasureMapChest m_Chest;\r\n\r\n private int m_Count;\r\n\r\n private long m_NextSkillTime;\r\n private long m_NextSpellTime;\r\n private long m_NextActionTime;\r\n private long m_LastMoveTime;\r\n\r\n public DigTimer(Mobile from, TreasureMap treasureMap, Point3D location, Map map) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0))\r\n {\r\n m_From = from;\r\n m_TreasureMap = treasureMap;\r\n\r\n m_Location = location;\r\n m_Map = map;\r\n\r\n m_NextSkillTime = from.NextSkillTime;\r\n m_NextSpellTime = from.NextSpellTime;\r\n m_NextActionTime = from.NextActionTime;\r\n m_LastMoveTime = from.LastMoveTime;\r\n\r\n Priority = TimerPriority.TenMS;\r\n }\r\n\r\n private void Terminate()\r\n {\r\n Stop();\r\n m_From.EndAction(typeof(TreasureMap));\r\n\r\n if (m_Chest != null)\r\n m_Chest.Delete();\r\n\r\n if (m_Dirt1 != null)\r\n {\r\n m_Dirt1.Delete();\r\n m_Dirt2.Delete();\r\n }\r\n }\r\n\r\n protected override void OnTick()\r\n {\r\n if (m_NextSkillTime != m_From.NextSkillTime || m_NextSpellTime != m_From.NextSpellTime || m_NextActionTime != m_From.NextActionTime)\r\n {\r\n Terminate();\r\n return;\r\n }\r\n\r\n if (m_LastMoveTime != m_From.LastMoveTime)\r\n {\r\n m_From.SendLocalizedMessage(503023); \/\/ You cannot move around while digging up treasure. You will need to start digging anew.\r\n Terminate();\r\n return;\r\n }\r\n\r\n int z = (m_Chest != null) ? m_Chest.Z + m_Chest.ItemData.Height : int.MinValue;\r\n int height = 16;\r\n\r\n if (z > m_Location.Z)\r\n height -= (z - m_Location.Z);\r\n else\r\n z = m_Location.Z;\r\n\r\n if (!m_Map.CanFit(m_Location.X, m_Location.Y, z, height, true, true, false))\r\n {\r\n m_From.SendLocalizedMessage(503024); \/\/ You stop digging because something is directly on top of the treasure chest.\r\n Terminate();\r\n return;\r\n }\r\n\r\n m_Count++;\r\n\r\n m_From.RevealingAction();\r\n m_From.Direction = m_From.GetDirectionTo(m_Location);\r\n\r\n if (m_Count > 1 && m_Dirt1 == null)\r\n {\r\n m_Dirt1 = new TreasureChestDirt();\r\n m_Dirt1.MoveToWorld(m_Location, m_Map);\r\n\r\n m_Dirt2 = new TreasureChestDirt();\r\n m_Dirt2.MoveToWorld(new Point3D(m_Location.X, m_Location.Y - 1, m_Location.Z), m_Map);\r\n }\r\n\r\n if (m_Count == 5)\r\n {\r\n m_Dirt1.Turn1();\r\n }\r\n else if (m_Count == 10)\r\n {\r\n m_Dirt1.Turn2();\r\n m_Dirt2.Turn2();\r\n }\r\n else if (m_Count > 10)\r\n {\r\n if (m_Chest == null)\r\n {\r\n m_Chest = new TreasureMapChest(m_From, m_TreasureMap.Level, true);\r\n m_Chest.MoveToWorld(new Point3D(m_Location.X, m_Location.Y, m_Location.Z - 15), m_Map);\r\n }\r\n else\r\n {\r\n m_Chest.Z++;\r\n }\r\n\r\n Effects.PlaySound(m_Chest, m_Map, 0x33B);\r\n }\r\n\r\n if (m_Chest != null && m_Chest.Location.Z >= m_Location.Z)\r\n {\r\n Stop();\r\n m_From.EndAction(typeof(TreasureMap));\r\n\r\n m_Chest.Temporary = false;\r\n m_TreasureMap.Completed = true;\r\n m_TreasureMap.CompletedBy = m_From;\r\n\r\n int spawns;\r\n switch (m_TreasureMap.Level)\r\n {\r\n case 0: spawns = 3; break;\r\n case 1: spawns = 0; break;\r\n default: spawns = 4; break;\r\n }\r\n\r\n for (int i = 0; i < spawns; ++i)\r\n {\r\n BaseCreature bc = Spawn(m_TreasureMap.Level, m_Chest.Location, m_Chest.Map, null, true);\r\n\r\n if (bc != null)\r\n m_Chest.Guardians.Add(bc);\r\n }\r\n }\r\n else\r\n {\r\n if (m_From.Body.IsHuman && !m_From.Mounted)\r\n m_From.Animate(11, 5, 1, true, false, 0);\r\n\r\n new SoundTimer(m_From, 0x125 + (m_Count % 2)).Start();\r\n }\r\n }\r\n\r\n private class SoundTimer : Timer\r\n {\r\n private Mobile m_From;\r\n private int m_SoundID;\r\n\r\n public SoundTimer(Mobile from, int soundID) : base(TimeSpan.FromSeconds(0.9))\r\n {\r\n m_From = from;\r\n m_SoundID = soundID;\r\n\r\n Priority = TimerPriority.TenMS;\r\n }\r\n\r\n protected override void OnTick()\r\n {\r\n m_From.PlaySound(m_SoundID);\r\n }\r\n }\r\n }\r\n\r\n public override void OnDoubleClick(Mobile from)\r\n {\r\n if (!from.InRange(GetWorldLocation(), 2))\r\n {\r\n from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); \/\/ I can't reach that.\r\n return;\r\n }\r\n\r\n if (!m_Completed && m_Decoder == null)\r\n Decode(from);\r\n else\r\n DisplayTo(from);\r\n }\r\n\r\n private bool CheckYoung(Mobile from)\r\n {\r\n if (from.AccessLevel >= AccessLevel.GameMaster)\r\n return true;\r\n\r\n if (from is PlayerMobile && ((PlayerMobile)from).Young)\r\n return true;\r\n\r\n if (from == this.Decoder)\r\n {\r\n this.Level = 1;\r\n from.SendLocalizedMessage(1046446); \/\/ This is now a level one treasure map.\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n private double GetMinSkillLevel()\r\n {\r\n switch (m_Level)\r\n {\r\n case 1: return -3.0;\r\n case 2: return 41.0;\r\n case 3: return 51.0;\r\n case 4: return 61.0;\r\n case 5: return 70.0;\r\n case 6: return 70.0;\r\n\r\n default: return 0.0;\r\n }\r\n }\r\n\r\n private bool HasRequiredSkill(Mobile from)\r\n {\r\n return (from.Skills[SkillName.Cartography].Value >= GetMinSkillLevel());\r\n }\r\n\r\n public void Decode(Mobile from)\r\n {\r\n if (m_Completed || m_Decoder != null)\r\n return;\r\n\r\n if (m_Level == 0)\r\n {\r\n if (!CheckYoung(from))\r\n {\r\n from.SendLocalizedMessage(1046447); \/\/ Only a young player may use this treasure map.\r\n return;\r\n }\r\n }\r\n else\r\n {\r\n double minSkill = GetMinSkillLevel();\r\n\r\n if (from.Skills[SkillName.Cartography].Value < minSkill)\r\n from.SendLocalizedMessage(503013); \/\/ The map is too difficult to attempt to decode.\r\n\r\n double maxSkill = minSkill + 60.0;\r\n\r\n if (!from.CheckSkill(SkillName.Cartography, minSkill, maxSkill))\r\n {\r\n from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 503018); \/\/ You fail to make anything of the map.\r\n return;\r\n }\r\n }\r\n\r\n from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 503019); \/\/ You successfully decode a treasure map!\r\n Decoder = from;\r\n\r\n if (Core.AOS)\r\n LootType = LootType.Blessed;\r\n\r\n DisplayTo(from);\r\n }\r\n\r\n public override void DisplayTo(Mobile from)\r\n {\r\n if (m_Completed)\r\n {\r\n SendLocalizedMessageTo(from, 503014); \/\/ This treasure hunt has already been completed.\r\n }\r\n else if (m_Level == 0 && !CheckYoung(from))\r\n {\r\n from.SendLocalizedMessage(1046447); \/\/ Only a young player may use this treasure map.\r\n return;\r\n }\r\n else if (m_Decoder != from && !HasRequiredSkill(from))\r\n {\r\n from.SendLocalizedMessage(503031); \/\/ You did not decode this map and have no clue where to look for the treasure.\r\n return;\r\n }\r\n else\r\n {\r\n SendLocalizedMessageTo(from, 503017); \/\/ The treasure is marked by the red pin. Grab a shovel and go dig it up!\r\n }\r\n\r\n from.PlaySound(0x249);\r\n base.DisplayTo(from);\r\n }\r\n\r\n public override void GetContextMenuEntries(Mobile from, List list)\r\n {\r\n base.GetContextMenuEntries(from, list);\r\n\r\n if (!m_Completed)\r\n {\r\n if (m_Decoder == null)\r\n {\r\n list.Add(new DecodeMapEntry(this));\r\n }\r\n else\r\n {\r\n bool digTool = HasDiggingTool(from);\r\n\r\n list.Add(new OpenMapEntry(this));\r\n list.Add(new DigEntry(this, digTool));\r\n }\r\n }\r\n }\r\n\r\n private class DecodeMapEntry : ContextMenuEntry\r\n {\r\n private TreasureMap m_Map;\r\n\r\n public DecodeMapEntry(TreasureMap map) : base(6147, 2)\r\n {\r\n m_Map = map;\r\n }\r\n\r\n public override void OnClick()\r\n {\r\n if (!m_Map.Deleted)\r\n m_Map.Decode(Owner.From);\r\n }\r\n }\r\n\r\n private class OpenMapEntry : ContextMenuEntry\r\n {\r\n private TreasureMap m_Map;\r\n\r\n public OpenMapEntry(TreasureMap map) : base(6150, 2)\r\n {\r\n m_Map = map;\r\n }\r\n\r\n public override void OnClick()\r\n {\r\n if (!m_Map.Deleted)\r\n m_Map.DisplayTo(Owner.From);\r\n }\r\n }\r\n\r\n private class DigEntry : ContextMenuEntry\r\n {\r\n private TreasureMap m_Map;\r\n\r\n public DigEntry(TreasureMap map, bool enabled) : base(6148, 2)\r\n {\r\n m_Map = map;\r\n\r\n if (!enabled)\r\n this.Flags |= CMEFlags.Disabled;\r\n }\r\n\r\n public override void OnClick()\r\n {\r\n if (m_Map.Deleted)\r\n return;\r\n\r\n Mobile from = Owner.From;\r\n\r\n if (HasDiggingTool(from))\r\n m_Map.OnBeginDig(from);\r\n else\r\n from.SendMessage(\"You must have a digging tool to dig for treasure.\");\r\n }\r\n }\r\n\r\n public override int LabelNumber\r\n {\r\n get\r\n {\r\n if (m_Decoder != null)\r\n {\r\n if (m_Level == 6)\r\n return 1063453;\r\n else\r\n return 1041516 + m_Level;\r\n }\r\n else if (m_Level == 6)\r\n return 1063452;\r\n else\r\n return 1041510 + m_Level;\r\n }\r\n }\r\n\r\n public override void GetProperties(ObjectPropertyList list)\r\n {\r\n base.GetProperties(list);\r\n\r\n list.Add(m_Map == Map.Felucca ? 1041502 : 1041503); \/\/ for somewhere in Felucca : for somewhere in Trammel\r\n\r\n if (m_Completed)\r\n {\r\n list.Add(1041507, m_CompletedBy == null ? \"someone\" : m_CompletedBy.Name); \/\/ completed by ~1_val~\r\n }\r\n }\r\n\r\n public override void OnSingleClick(Mobile from)\r\n {\r\n if (m_Completed)\r\n {\r\n from.Send(new MessageLocalizedAffix(Serial, ItemID, MessageType.Label, 0x3B2, 3, 1048030, \"\", AffixType.Append, String.Format(\" completed by {0}\", m_CompletedBy == null ? \"someone\" : m_CompletedBy.Name), \"\"));\r\n }\r\n else if (m_Decoder != null)\r\n {\r\n if (m_Level == 6)\r\n LabelTo(from, 1063453);\r\n else\r\n LabelTo(from, 1041516 + m_Level);\r\n }\r\n else\r\n {\r\n if (m_Level == 6)\r\n LabelTo(from, 1041522, String.Format(\"#{0}\\t \\t#{1}\", 1063452, m_Map == Map.Felucca ? 1041502 : 1041503));\r\n else\r\n LabelTo(from, 1041522, String.Format(\"#{0}\\t \\t#{1}\", 1041510 + m_Level, m_Map == Map.Felucca ? 1041502 : 1041503));\r\n }\r\n }\r\n\r\n public override void Serialize(GenericWriter writer)\r\n {\r\n base.Serialize(writer);\r\n\r\n writer.Write((int)1);\r\n\r\n writer.Write((Mobile)m_CompletedBy);\r\n\r\n writer.Write(m_Level);\r\n writer.Write(m_Completed);\r\n writer.Write(m_Decoder);\r\n writer.Write(m_Map);\r\n writer.Write(m_Location);\r\n }\r\n\r\n public override void Deserialize(GenericReader reader)\r\n {\r\n base.Deserialize(reader);\r\n\r\n int version = reader.ReadInt();\r\n\r\n switch (version)\r\n {\r\n case 1:\r\n {\r\n m_CompletedBy = reader.ReadMobile();\r\n\r\n goto case 0;\r\n }\r\n case 0:\r\n {\r\n m_Level = (int)reader.ReadInt();\r\n m_Completed = reader.ReadBool();\r\n m_Decoder = reader.ReadMobile();\r\n m_Map = reader.ReadMap();\r\n m_Location = reader.ReadPoint2D();\r\n\r\n if (version == 0 && m_Completed)\r\n m_CompletedBy = m_Decoder;\r\n\r\n break;\r\n }\r\n }\r\n\r\n if (Core.AOS && m_Decoder != null && LootType == LootType.Regular)\r\n LootType = LootType.Blessed;\r\n }\r\n }\r\n\r\n public class TreasureChestDirt : Item\r\n {\r\n public TreasureChestDirt() : base(0x912)\r\n {\r\n Movable = false;\r\n\r\n Timer.DelayCall(TimeSpan.FromMinutes(2.0), new TimerCallback(Delete));\r\n }\r\n\r\n public TreasureChestDirt(Serial serial) : base(serial)\r\n {\r\n }\r\n\r\n public void Turn1()\r\n {\r\n this.ItemID = 0x913;\r\n }\r\n\r\n public void Turn2()\r\n {\r\n this.ItemID = 0x914;\r\n }\r\n\r\n public override void Serialize(GenericWriter writer)\r\n {\r\n base.Serialize(writer);\r\n\r\n writer.WriteEncodedInt(0); \/\/ version\r\n }\r\n\r\n public override void Deserialize(GenericReader reader)\r\n {\r\n base.Deserialize(reader);\r\n\r\n int version = reader.ReadEncodedInt();\r\n\r\n Delete();\r\n }\r\n }\r\n}","avg_line_length":34.0287846482,"max_line_length":226,"alphanum_fraction":0.4402080266} {"size":5419,"ext":"cs","lang":"C#","max_stars_count":11.0,"content":"using System;\nusing System.Threading.Tasks;\nusing Vonage.Request;\n\nnamespace Vonage.Numbers\n{\n public class NumbersClient : INumbersClient\n {\n public NumbersClient(Credentials creds = null)\n {\n Credentials = creds;\n }\n \n public Credentials Credentials { get; set; }\n \n public Task GetOwnedNumbersAsync(NumberSearchRequest request, Credentials creds = null)\n {\n return ApiRequest.DoGetRequestWithQueryParametersAsync(\n ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, \"\/account\/numbers\"), \n ApiRequest.AuthType.Query, \n request, \n creds ?? Credentials\n );\n }\n\n public Task GetAvailableNumbersAsync(NumberSearchRequest request, Credentials creds = null)\n {\n return ApiRequest.DoGetRequestWithQueryParametersAsync(\n ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, \"\/number\/search\"), \n ApiRequest.AuthType.Query, \n request, \n creds ?? Credentials\n );\n }\n\n public async Task BuyANumberAsync(NumberTransactionRequest request, Credentials creds = null)\n {\n var response = await ApiRequest.DoPostRequestUrlContentFromObjectAsync( \n ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, \"\/number\/buy\"),\n request, \n creds ?? Credentials\n );\n ValidateNumbersResponse(response);\n return response; \n }\n\n public async Task CancelANumberAsync(NumberTransactionRequest request, Credentials creds = null)\n {\n var response = await ApiRequest.DoPostRequestUrlContentFromObjectAsync( \n ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, \"\/number\/cancel\"),\n request, \n creds ?? Credentials\n );\n ValidateNumbersResponse(response);\n return response;\n }\n\n public async Task UpdateANumberAsync(UpdateNumberRequest request, Credentials creds = null)\n {\n var response = await ApiRequest.DoPostRequestUrlContentFromObjectAsync(\n ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, \"\/number\/update\"),\n request,\n creds ?? Credentials\n );\n ValidateNumbersResponse(response);\n return response;\n }\n\n public static void ValidateNumbersResponse(NumberTransactionResponse response)\n {\n const string SUCCESS = \"200\";\n if (response.ErrorCode != SUCCESS)\n {\n throw new VonageNumberResponseException($\"Number Transaction failed with error code:{response.ErrorCode} and label {response.ErrorCodeLabel}\"){ Response = response};\n }\n }\n\n public NumbersSearchResponse GetOwnedNumbers(NumberSearchRequest request, Credentials creds = null)\n {\n return ApiRequest.DoGetRequestWithQueryParameters(\n ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, \"\/account\/numbers\"),\n ApiRequest.AuthType.Query,\n request,\n creds ?? Credentials\n );\n }\n\n public NumbersSearchResponse GetAvailableNumbers(NumberSearchRequest request, Credentials creds = null)\n {\n return ApiRequest.DoGetRequestWithQueryParameters(\n ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, \"\/number\/search\"),\n ApiRequest.AuthType.Query,\n request,\n creds ?? Credentials\n );\n }\n\n public NumberTransactionResponse BuyANumber(NumberTransactionRequest request, Credentials creds = null)\n {\n var response = ApiRequest.DoPostRequestUrlContentFromObject(\n ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, \"\/number\/buy\"),\n request,\n creds ?? Credentials\n );\n ValidateNumbersResponse(response);\n return response;\n }\n\n public NumberTransactionResponse CancelANumber(NumberTransactionRequest request, Credentials creds = null)\n {\n var response = ApiRequest.DoPostRequestUrlContentFromObject(\n ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, \"\/number\/cancel\"),\n request,\n creds ?? Credentials\n );\n ValidateNumbersResponse(response);\n return response;\n }\n\n public NumberTransactionResponse UpdateANumber(UpdateNumberRequest request, Credentials creds = null)\n {\n var response = ApiRequest.DoPostRequestUrlContentFromObject(\n ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, \"\/number\/update\"),\n request,\n creds ?? Credentials\n );\n ValidateNumbersResponse(response);\n return response;\n }\n }\n}","avg_line_length":41.3664122137,"max_line_length":181,"alphanum_fraction":0.6159808083} {"size":245,"ext":"cs","lang":"C#","max_stars_count":1.0,"content":"using System.Xml.Serialization;\n\nnamespace Taxer.Domain.VAT\n{\n [XmlRoot(ElementName = \"Veta5\")]\n public class VATAdjustments\n {\n [XmlAttribute(AttributeName = \"odp_uprav_kf\")]\n public double Coef { get; set; } = 0;\n }\n}","avg_line_length":22.2727272727,"max_line_length":54,"alphanum_fraction":0.6448979592} {"size":12839,"ext":"cs","lang":"C#","max_stars_count":14.0,"content":"\ufeffusing Bindding.ExcuteClasses;\nusing CefSharp;\nusing CefSharp.WinForms;\nusing System;\nusing System.Windows.Forms;\nusing CefSharp.WinForms.Internals;\nusing System.Threading.Tasks;\nusing System.Threading;\nusing System.Collections.Generic;\nusing Newtonsoft.Json;\nusing WindowsInput;\nusing WindowsInput.Native;\nusing Bindding.ExcuteClasses.AboutParameter;\n\nnamespace Bindding.MainForms.UserControls\n{\n \/\/\/ \n \/\/\/ \u6d4f\u89c8\u5668\u63a7\u4ef6\n \/\/\/ <\/summary>\n public partial class UC_Browser : BaseUserControl\n {\n private ChromiumWebBrowser browser;\n\n \/\/\/\/\/ \n \/\/\/\/\/ \u4e3a\u4fdd\u8bc1\u7ebf\u7a0b\u5b89\u5168\uff0c\u786e\u4fdd\u987a\u5e8f\u6267\u884c\n \/\/\/\/\/ <\/summary>\n \/\/private readonly static object _locker = new object();\n\n \/\/\/ \n \/\/\/ \u5f53\u524d\u6267\u884c\u7684\u662f\u7b2c\u51e0\u4e2a\n \/\/\/ <\/summary>\n private int _currentIndex = 0;\n\n #region \u5c5e\u6027\n\n \/\/\/ \n \/\/\/ \u5f53\u524d\u6267\u884c\u7684\u6b21\u6570\n \/\/\/ <\/summary>\n internal int _currentNum\n {\n get\n {\n return CommonParameter.CurrentLoopNum;\n }\n set\n {\n CommonParameter.CurrentLoopNum = value;\n OnChangeCurrentNum(value, null);\n }\n }\n\n internal bool _is_working { get; set; }\n\n #endregion \u5c5e\u6027\n\n public UC_Browser()\n {\n InitializeComponent();\n }\n\n \/\/\/ \n \/\/\/ \u5f00\u59cb\u70b9\u51fb\u4e8b\u4ef6\n \/\/\/ <\/summary>\n internal void StartClick()\n {\n _currentNum = 1;\n _currentIndex = 0;\n _is_working = true;\n browser.Load(ConstParameter.SEARCH_ENGINES);\n }\n\n \/\/\/ \n \/\/\/ \u7ed3\u675f\u70b9\u51fb\u4e8b\u4ef6\n \/\/\/ <\/summary>\n internal void StopClick()\n {\n _currentNum = 1;\n _currentIndex = 0;\n _is_working = false;\n }\n\n internal void InitialBrower()\n {\n \/\/ Set the CachePath during initialization.\n var settings = new CefSettings()\n {\n UserAgent = CommonParameter.CurrentUserAgentValue\n };\n Cef.Initialize(settings);\n\n CommonFunction.DeleteCefsharpDirectory();\n browser = new ChromiumWebBrowser(ConstParameter.SEARCH_ENGINES)\n {\n Dock = DockStyle.Fill,\n BrowserSettings =\n {\n ApplicationCache = CefState.Disabled,\n JavascriptOpenWindows = CefState.Enabled,\n TabToLinks = CefState.Disabled\n }\n };\n\n var mng = Cef.GetGlobalCookieManager();\n bool flag = mng.SetStoragePath(ConstParameter.CookiePath, true);\n\n toolStripContainer1.ContentPanel.Controls.Add(browser);\n\n browser.RequestHandler = new RequestHandler(); \/\/ \u91cd\u5199request\n browser.LoadingStateChanged += OnBrowserLoadingStateChanged;\n browser.AddressChanged += OnBrowserAddressChanged;\n browser.FrameLoadEnd += BeginSearch;\n var _lfsh = new LifeSpanHandler(); \/\/ \u5f39\u51fa\u6846\n _lfsh.MyBeforPopup += MyBeforPopup;\n browser.LifeSpanHandler = _lfsh;\n }\n\n internal event EventHandler MyBeforPopup;\n\n \/\/\/ \n \/\/\/ \u6267\u884c\u7b2c\u4e8c\u6b21\u7684\u67e5\u8be2\n \/\/\/ <\/summary>\n internal event EventHandler MyNextSearch;\n\n \/\/\/ \n \/\/\/ \u52a0\u8f7d\u5b8c\u6210\u4ee5\u540e\n \/\/\/ <\/summary>\n \/\/\/ <\/param>\n \/\/\/ <\/param>\n private void OnBrowserLoadingStateChanged(object sender, LoadingStateChangedEventArgs args)\n {\n SetCanGoBack(args.CanGoBack);\n SetCanGoForward(args.CanGoForward);\n this.InvokeOnUiThreadIfRequired(() => SetIsLoading(!args.CanReload));\n\n if (_is_working && _currentNum > CommonParameter.ConfigParam.loop_count)\n {\n OnExcuteClickEnd(this, null);\n return;\n }\n\n if (!args.IsLoading && browser.Address != ConstParameter.SEARCH_ENGINES && _is_working && _currentNum <= CommonParameter.ConfigParam.loop_count)\n {\n \/\/ \u70b9\u51fb \u767e\u5ea6\u4e00\u4e0b\u540e\uff0c\u52a0\u8f7d\u7684\u9875\u9762\n Task.Factory.StartNew(() =>\n {\n Monitor.Enter(CommonParameter.LokerObj);\n \/\/ Monitor.Wait(CommonParameter.LokerObj);\n Thread.Sleep(CommonParameter.ConfigParam.sleep_seconds.after_search.ToRandom());\n this.RunJS(\"var _matchKey='\" + CommonParameter.ConfigParam.key_match_list[_currentIndex].Value + ConstParameter.GET_BAIDU_LIST_JS);\n Monitor.Exit(CommonParameter.LokerObj);\n });\n }\n }\n\n \/\/\/ \n \/\/\/ \u6267\u884cjs\u8fd4\u56de\uff0c\u6267\u884c\u7684\u7ed3\u679c\n \/\/\/ <\/summary>\n \/\/\/ <\/param>\n private void RunJS(string strJS)\n {\n string returnValue = string.Empty;\n browser.EvaluateScriptAsync(strJS).ContinueWith(t =>\n {\n if (!t.IsFaulted)\n {\n var response = t.Result;\n if (response.Success && response.Result != null)\n {\n returnValue = response.Result.ToString();\n if (!string.IsNullOrEmpty(returnValue))\n {\n this.AfterSearchSimClick(returnValue);\n }\n }\n else\n {\n Thread.Sleep(2000);\n browser.Load(ConstParameter.SEARCH_ENGINES);\n }\n }\n });\n }\n\n \/\/\/ \n \/\/\/ \u52a0\u8f7d\u5217\u8868\n \/\/\/ <\/summary>\n \/\/\/ <\/param>\n private void AfterSearchSimClick(string strData)\n {\n Monitor.Enter(CommonParameter.LokerObj);\n var _dataList = JsonConvert.DeserializeObject>(strData);\n bool _is_click = false;\n foreach (ListContent singleContent in _dataList)\n {\n \/\/ \u6a21\u62df\u70b9\u51fb\n if (singleContent.is_ad == ConstParameter.CLICK_AD)\n {\n var sim = new InputSimulator();\n sim.Mouse\n .VerticalScroll(20)\n .Sleep(CommonParameter.ConfigParam.simulate_speed.mouse_scroll.ToRandom()); \/\/ \u5148\u5230\u6700\u9876\u5c42 1 = 100px\uff1b\n\n CommonFunction.SimMoveAndLefClick(singleContent.left, singleContent.top, true);\n\n \/\/ \u8bb0\u5f55\u65e5\u5fd7\n var _tmpLog = new ContentLog();\n _tmpLog.ch_Key = CommonParameter.ConfigParam.key_match_list[_currentIndex].Key;\n _tmpLog.ch_Website = singleContent.target;\n _tmpLog.ch_Title = singleContent.title;\n OnWriteLog(_tmpLog, null);\n _is_click = true;\n break; \/\/ \u4e00\u6b21\u641c\u7d22\uff0c\u53ea\u70b9\u51fb\u4e00\u6b21\n }\n }\n\n _currentIndex++;\n if (_is_click)\n {\n Monitor.Wait(CommonParameter.LokerObj); \/\/ \u70b9\u51fb\u6210\u529f\u9700\u8981\u7b49\u5f85\n MyNextSearch(null, null);\n }\n\n Thread.Sleep(CommonParameter.ConfigParam.sleep_seconds.baidu_search.ToRandom());\n Cef.GetGlobalCookieManager().DeleteCookiesAsync(string.Empty, string.Empty);\n Monitor.Exit(CommonParameter.LokerObj);\n browser.Load(ConstParameter.SEARCH_ENGINES);\n }\n\n private void BeginSearch(object sender, FrameLoadEndEventArgs args)\n {\n if (browser.Address == ConstParameter.SEARCH_ENGINES && _is_working && _currentNum <= CommonParameter.ConfigParam.loop_count)\n {\n if (_currentIndex < CommonParameter.ConfigParam.key_match_list.Count)\n {\n \/\/ \u79fb\u52a8\u5230\u641c\u7d22\u6846\n int _x = CommonParameter.FormX + ConstParameter.SearchX + ConstParameter.RandomSeed.Next(50, 300);\n int _y = CommonParameter.FormY + ConstParameter.BrowerY + ConstParameter.SearchY + ConstParameter.RandomSeed.Next(15, 20);\n Task.Factory.StartNew(() =>\n {\n Monitor.Enter(CommonParameter.LokerObj); \/\/ \u5f00\u59cb \u641c\u7d22\uff0c\u9700\u8981\u9501\u5b9a\n var sim = new InputSimulator();\n sim.Mouse\n .MoveMouseTo(CommonParameter.CurrentScreenWidth * _x, CommonParameter.CurrentScreenHeight * _y)\n .Sleep(CommonParameter.ConfigParam.simulate_speed.mouse_move_search_input.ToRandom())\n .LeftButtonClick()\n .Sleep(CommonParameter.ConfigParam.simulate_speed.mouse_click_search_input.ToRandom());\n \/\/ \u8f93\u5165 \u641c\u7d22\u5173\u952e\u5b57\n foreach (char _single in CommonParameter.ConfigParam.key_match_list[_currentIndex].Key)\n {\n sim.Keyboard\n .TextEntry(_single)\n .Sleep(CommonParameter.ConfigParam.simulate_speed.keyboard_keywords_speed.ToRandom());\n }\n\n sim.Keyboard.KeyPress(VirtualKeyCode.RETURN); \/\/ \u6309\u4e0b\u56de\u8f66\u952e\n\n Monitor.Pulse(CommonParameter.LokerObj);\n Monitor.Exit(CommonParameter.LokerObj); \/\/ \u8f93\u5165\u641c\u7d22\u5b8c\u6210\n });\n }\n else\n {\n \/\/ \u7528\u4e8e\u5224\u65ad\u6700\u540e\u4e00\u6b21\n if (_is_working && _currentNum >= CommonParameter.ConfigParam.loop_count)\n {\n OnExcuteClickEnd(this, null);\n return;\n }\n var _msg = CommonFunction.BackgroundDoWorkIpelfFast();\n if (!string.IsNullOrEmpty(_msg))\n {\n MessageBox.Show(_msg, \"IP\u7cbe\u7075\u5f02\u5e38\", MessageBoxButtons.OK, MessageBoxIcon.Error);\n return;\n }\n\n _currentNum++;\n OnExitApplcation(null, null);\n }\n }\n }\n\n #region \u6d4f\u89c8\u7684\u4e8b\u4ef6\n\n \/\/\/ \n \/\/\/ \u6267\u884c\u70b9\u51fb\u5b8c\u6210\u540e\n \/\/\/ <\/summary>\n internal event EventHandler OnExcuteClickEnd;\n\n internal event EventHandler OnChangeCurrentNum;\n\n internal event EventHandler OnWriteLog;\n\n \/\/\/ \n \/\/\/ \u6267\u884c\u4e00\u6b21\u540e\uff0c\u9700\u8981\u5173\u95ed\u8f6f\u4ef6\n \/\/\/ <\/summary>\n internal event EventHandler OnExitApplcation;\n\n #endregion \u6d4f\u89c8\u7684\u4e8b\u4ef6\n\n #region \u6d4f\u89c8\u5668\u7684\u6309\u94ae\n\n private void OnBrowserAddressChanged(object sender, AddressChangedEventArgs args)\n {\n this.InvokeOnUiThreadIfRequired(() => urlTextBox.Text = args.Address);\n }\n\n private void SetCanGoBack(bool canGoBack)\n {\n this.InvokeOnUiThreadIfRequired(() => backButton.Enabled = canGoBack);\n }\n\n private void SetCanGoForward(bool canGoForward)\n {\n this.InvokeOnUiThreadIfRequired(() => forwardButton.Enabled = canGoForward);\n }\n\n private void SetIsLoading(bool isLoading)\n {\n goButton.Text = isLoading ? \"Stop\" : \"Go\";\n goButton.Image = isLoading ?\n Bindding.Properties.Resources.nav_plain_red :\n Bindding.Properties.Resources.nav_plain_green;\n\n HandleToolStripLayout();\n }\n\n private void HandleToolStripLayout(object sender, LayoutEventArgs e)\n {\n HandleToolStripLayout();\n }\n\n private void HandleToolStripLayout()\n {\n var width = toolStrip1.Width;\n foreach (ToolStripItem item in toolStrip1.Items)\n {\n if (item != urlTextBox)\n {\n width -= item.Width - item.Margin.Horizontal;\n }\n }\n urlTextBox.Width = Math.Max(0, width - urlTextBox.Margin.Horizontal - 18);\n }\n\n private void UrlTextBoxKeyUp(object sender, KeyEventArgs e)\n {\n if (e.KeyCode != Keys.Enter)\n {\n return;\n }\n\n LoadUrl(urlTextBox.Text);\n }\n\n private void LoadUrl(string url)\n {\n if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))\n {\n browser.Load(url);\n }\n }\n\n private void GoButtonClick(object sender, EventArgs e)\n {\n LoadUrl(urlTextBox.Text);\n }\n\n private void BackButtonClick(object sender, EventArgs e)\n {\n browser.Back();\n }\n\n private void ForwardButtonClick(object sender, EventArgs e)\n {\n browser.Forward();\n }\n\n #endregion \u6d4f\u89c8\u5668\u7684\u6309\u94ae\n }\n}","avg_line_length":33.7868421053,"max_line_length":156,"alphanum_fraction":0.5236389127} {"size":366,"ext":"cs","lang":"C#","max_stars_count":null,"content":"\ufeffusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\nnamespace MoreMountains.Tools\n{\n public class MMDropdownAttribute : PropertyAttribute\n {\n public readonly object[] DropdownValues;\n\n public MMDropdownAttribute(params object[] dropdownValues)\n {\n DropdownValues = dropdownValues;\n }\n }\n}\n","avg_line_length":21.5294117647,"max_line_length":66,"alphanum_fraction":0.693989071} {"size":2355,"ext":"cs","lang":"C#","max_stars_count":1.0,"content":"\ufeffusing System.Collections.Generic;\nusing System.Data;\nusing System.Globalization;\n\nnamespace MigSharp.NUnit.Integration\n{\n [MigrationExport(Tag = \"Renaming Column With Default Value and Adding New Column With Default Value Having the Previous Name\")]\n internal class Migration16 : IIntegrationTestMigration\n {\n private const string FirstDefaultValue = \"Test\";\n private const int SecondDefaultValue = 747;\n\n public void Up(IDatabase db)\n {\n \/\/ renaming columns is not supported by SqlServerCe35, SqlServerCe4 and SQLite\n bool renameColumnIsSupported = db.Context.ProviderMetadata.Name != ProviderNames.SqlServerCe4 && db.Context.ProviderMetadata.Name != ProviderNames.SqlServerCe35 && db.Context.ProviderMetadata.Name != ProviderNames.SQLite;\n\n db.CreateTable(Tables[0].Name)\n .WithPrimaryKeyColumn(Tables[0].Columns[0], DbType.Int32)\n .WithNotNullableColumn(renameColumnIsSupported ? Tables[0].Columns[2] : Tables[0].Columns[1], DbType.String).OfSize(10).HavingDefault(FirstDefaultValue);\n\n db.Execute(string.Format(CultureInfo.InvariantCulture, \"INSERT INTO \\\"{0}\\\" (\\\"{1}\\\") VALUES ('{2}')\", Tables[0].Name, Tables[0].Columns[0], Tables[0].Value(0, 0)));\n\n if (renameColumnIsSupported)\n {\n db.Tables[Tables[0].Name].Columns[Tables[0].Columns[2]].Rename(Tables[0].Columns[1]);\n }\n\n \/\/ add a new column with the same name like the previously renamed one to make sure that any associated db object were renamed, too\n db.Tables[Tables[0].Name].AddNotNullableColumn(Tables[0].Columns[2], DbType.Int32).HavingDefault(SecondDefaultValue);\n\n db.Execute(string.Format(CultureInfo.InvariantCulture, \"INSERT INTO \\\"{0}\\\" (\\\"{1}\\\") VALUES ('{2}')\", Tables[0].Name, Tables[0].Columns[0], Tables[0].Value(1, 0)));\n }\n\n public ExpectedTables Tables\n {\n get\n {\n return new ExpectedTables\n {\n new ExpectedTable(\"Mig16\", \"Id\", \"First Renamed\", \"First\")\n {\n { 1, FirstDefaultValue, SecondDefaultValue },\n { 2, FirstDefaultValue, SecondDefaultValue },\n }\n };\n }\n }\n }\n}","avg_line_length":47.1,"max_line_length":233,"alphanum_fraction":0.6195329087} {"size":3996,"ext":"cshtml","lang":"C#","max_stars_count":null,"content":"\ufeff@model VendedorModel\n\n@{\n ViewData[\"Title\"] = \"Apagar\";\n}\n\n

Agapar Vendedor?<\/h1>\n\n
\n
\n
\n\n