public TargetPlayerGambitImpl (Features pmFeature, PlayerTypes pmType, PlayerAdjectives pmAdjective, Player pmGambitPlayer)
	{
		feature = pmFeature;
		type = pmType;
		adjective = pmAdjective;
		gambitPlayer = pmGambitPlayer;
	}
Beispiel #2
0
			public static void SetDisallowed(Features feature, bool value)
			{
				if (value)
					m_DisallowedFeatures |= feature;
				else
					m_DisallowedFeatures &= ~feature;
			}
Beispiel #3
0
        public static List<Field> FiltersForFeature(Features feature)
        {
            List<Field> fields = new List<Field>();

            switch (feature)
            {
                case Features.Jobs:
                    fields.Add(Field.Keyword);
                    fields.Add(Field.FieldOfStudy);
                    fields.Add(Field.CompanyName);
                    fields.Add(Field.JobTitle);
                    fields.Add(Field.Location);
                    fields.Add(Field.JobType);
                    //fields.Add(Field.Source);
                    break;
                case Features.Alumni:
                    fields.Add(Field.Keyword);
                    fields.Add(Field.FieldOfStudy);
                    fields.Add(Field.CompanyName);
                    //fields.Add(Field.Location);
                    break;
                case Features.Salary:
                    fields.Add(Field.FieldOfStudy);
                    //fields.Add(Field.Location);
                    break;
                case Features.Housing:
                    fields.Add(Field.Keyword);
                    fields.Add(Field.Location);
                    break;
            }

            return fields;
        }
 public Features.ShowMailingLabel.ViewModel Handle(Features.ShowMailingLabel.ViewRequest request, Features.ShowMailingLabel.ViewModel result)
 {
     using (var session = OpenSession())
     {
         var customer = session.Load<Sales.Customer>(request.CustomerId);
         result.Name = customer.Name;
         return result;
     }
 }
        /// <summary>Creates a client service for the given features.</summary>
        private IClientService CreateClientService(Features? features = null)
        {
            var client = new MockClientService();
            if (features.HasValue)
            {
                client.SetFeatures(new[] { Utilities.GetEnumStringValue(features.Value) });
            }

            return client;
        }
        public void Write(Features features, AbsoluteFilePath fulldgmlFileName)
        {
            var list = new List<FeatureInfo>(features.AllFeatures);
            foreach (FeatureInfo featureInfo in list.OrderBy(x => x.FeatureType))
            {
                this.HandleNode(featureInfo, string.Empty);
            }

            this.WriteDgml(fulldgmlFileName);
        }
Beispiel #7
0
        protected override int GenerateValue(TestCase tc, Features f)
        {
            var instructions = tc.TestMethod.Body.Instructions.Where(IsRelevant).ToList();
            var ilCount = instructions.Count;
            var sequencePoints = instructions.Select(i => i.SequencePoint).Where(sp => sp != null).ToList();
            var lineNumbers = new HashSet<int>(sequencePoints.Select(sp => sp.StartLine));
            var spCount = sequencePoints.Count;

            return spCount > 0 ? lineNumbers.Count : (int)(ilCount / IL_PER_LOC);
        }
 private Property(string city, string streetAddress, double rent, bool moveInReady, string state, double purchasePrice, DateTime aquisitionDate, Features features, byte[] imageData)
 {
     PropertyID = "Prop_" + NextID++;
     StreetAddress = new Address() { State = state, City = city, StreetAddress = streetAddress };
     PurchasePrice = purchasePrice;
     IsReadyToRent = moveInReady;
     PropertyFeatures = features;
     AquisitionDate = Convert.ToDateTime(aquisitionDate);
     Rent = rent;
     ImageData = imageData;
 }
	void Start()
	{
		foreach (FeatureInfo feature in usedFeatures) 
		{
			if (feature.reference != null)
			{
				activeFeatures = activeFeatures | feature.type;
				feature.reference.OnStart();
			}
		}
	}
 public Features.ShowMailingLabel.ViewModel Handle(Features.ShowMailingLabel.ViewRequest request, Features.ShowMailingLabel.ViewModel result)
 {
     using (var session = OpenSession())
     {
         var customer = session.Load<Shipping.Customer>(request.CustomerId);
         result.Address = customer.ShippingAddress.Street;
         result.CityStateZip = string.Format("{0}, {1} {2}",
             customer.ShippingAddress.City,
             customer.ShippingAddress.State,
             customer.ShippingAddress.Zip);
         return result;
     }
 }
 public System.Collections.Generic.IEnumerable<IFeature> GetFeaturesInView(BoundingBox box, double resolution)
 {
     var features = new Features();
     IRaster raster = null;
     var view = new Viewport { Resolution = resolution, Center = box.GetCentroid(), Width = (box.Width / resolution), Height = (box.Height / resolution) };
     if (TryGetMap(view, ref raster))
     {
         IFeature feature = features.New();
         feature.Geometry = raster;
         features.Add(feature);
     }
     return features;
 }
        public static bool IsFeatureEnabled(User aUser, Features aFeature)
        {
            bool myIsEnabled = true;

            foreach (FeaturesEnabled myFeaturesEnabled in aUser.FeaturesEnableds) {
                if(myFeaturesEnabled.FeatureName.Equals(aFeature.ToString())) {
                    if(!myFeaturesEnabled.Enabled) {
                        myIsEnabled = false;
                        break;
                    }
                }
            }

            return myIsEnabled;
        }
Beispiel #13
0
        public static IRenderer Create(GraphicsDevice device, Features rendererFeatures)
        {
            switch (rendererFeatures)
            {
                case Features.MultiPass | Features.PreTransformed | Features.SingleChannelTexCoords :
                    return new MultipassSimpleEffectRenderer_SingleChannel(device);

                case Features.MultiPass | Features.PreTransformed | Features.SingleChannelTexCoords | Features.AlphaTest:
                    return new MultipassSimpleEffectRenderer_SingleChannel(device);

                case Features.MultiPass | Features.PreTransformed | Features.DualChannelTexCoords:
                    return new MultipassDualTextureEffectRenderer_DualChannel(device);

                default:
                    throw new NotSupportedException();
            }
        }
        public ActionResult DisableFeature(Features feature)
        {
            if (!IsLoggedIn()) {
                return RedirectToLogin();
            }

            try {
                theFeatureService.DisableFeature(GetUserInformatonModel().Details, feature);
                ForceUserInformationRefresh();
                TempData["Message"] += MessageHelper.SuccessMessage(FEATURE_UPDATED);
            } catch (Exception e) {
                LogError(e, ErrorKeys.ERROR_MESSAGE);
                TempData["Message"] += MessageHelper.ErrorMessage(ErrorKeys.ERROR_MESSAGE);
            }

            return RedirectToAction("Main", "University", new { universityId = UniversityHelper.GetMainUniversity(GetUserInformatonModel().Details).Id });
        }
        private DataTemplate CreateCellTemplate(Features.Documents.ColumnDefinition columnDefinition)
        {
            var templateString = GetXamlForDataTemplate(columnDefinition);

            try
            {
                var template = XamlReader.Load(templateString) as DataTemplate;
                if (template == null)
                {
                    throw new InvalidOperationException("Xaml did not produce a DataTemplate");
                }
                template.LoadContent();
                return template;
            }
            catch (XamlParseException)
            {
                return null;
            }
        }
 public void SetProperty(int rowNumber, int idVehicle, Features feature, int code, object value)
 {
     Vehicle vehicle;
     if (Vehicles.ContainsKey(idVehicle))
     {
         vehicle = Vehicles[idVehicle];
     }
     else
     {
         switch (feature)
         {
             case Features.Trains:
                 vehicle = new Train(idVehicle);
                 Vehicles.Add(idVehicle, vehicle);
                 break;
             default:
                 break;
         }
     }
     Vehicles[idVehicle].SetProperty(rowNumber, code, feature, value);
 }
Beispiel #17
0
        public override ProvisioningTemplate CreateEntities(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
        {
            var context = web.Context as ClientContext;
            bool isSubSite = web.IsSubSite();
            var webFeatures = web.Features;
            var siteFeatures = context.Site.Features;

            context.Load(webFeatures, fs => fs.Include(f => f.DefinitionId));
            if (!isSubSite)
            {
                context.Load(siteFeatures, fs => fs.Include(f => f.DefinitionId));
            }
            context.ExecuteQuery();

            var features = new Features();
            foreach (var feature in webFeatures)
            {
                features.WebFeatures.Add(new Feature() { Deactivate = false, ID = feature.DefinitionId });
            }

            // if this is a sub site then we're not creating  site collection scoped feature entities
            if (!isSubSite)
            {
                foreach (var feature in siteFeatures)
                {
                    features.SiteFeatures.Add(new Feature() { Deactivate = false, ID = feature.DefinitionId });
                }
            }

            template.Features = features;

            // If a base template is specified then use that one to "cleanup" the generated template model
            if (creationInfo.BaseTemplate != null)
            {
                template = CleanupEntities(template, creationInfo.BaseTemplate, isSubSite);
            }

            return template;
        }
Beispiel #18
0
  public virtual short[,] apply_to_feature_matrix(Features features) {
	IntPtr ptr = modshogunPINVOKE.WordPreprocessor_apply_to_feature_matrix(swigCPtr, Features.getCPtr(features));
    if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
	int[] ranks = new int[2];
	Marshal.Copy(ptr, ranks, 0, 2);

	int rows = ranks[0];
	int cols = ranks[1];
	int len = rows * cols;

	short[] ret = new short[len];

	Marshal.Copy(new IntPtr(ptr.ToInt64() + 2 * Marshal.SizeOf(typeof(int))), ret, 0, len);

	short[,] result = new short[rows, cols];
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < cols; j++) {
			result[i, j] = ret[i * cols + j];
		}
	}
	return result;
}
		/// <summary>
		/// Generates 'count' features.  The format string will be applied to the feature not the result.
		/// </summary>
		/// <param name="count">How many features are desired.</param>
		/// <param name="feature">The desired feature, such as Paragraph or Sentence.</param>
		/// <param name="formatString">The formatting to apply to each feature.</param>
		/// <returns></returns>
		public string GenerateLipsum(int count, Features part, string formatString) {
			StringBuilder results = new StringBuilder();
			string[] data = new string[] { };
			if (part == Features.Paragraphs) {
				data = GenerateParagraphs(count, formatString);
			} else if (part == Features.Sentences) {
				data = GenerateSentences(count, formatString);
			} else if (part == Features.Words) {
				data = GenerateWords(count);
			} else if (part == Features.Characters) {
				data = GenerateCharacters(count);
			} else {
				throw new NotImplementedException("Sorry, this is not yet implemented.");
			}

			int length = data.Length;
			for (int i = 0; i < length; i++) {
				results.Append(data[i]);
			}

			return results.ToString();
		}
        public int Calcuate(int a, int b)
        {
            var engine = Python.CreateEngine();

            var code =
                "prediction.Result = features.A + features.B + features.C * features.TimeStep";
            var script = engine.CreateScriptSourceFromString(code);

            var scope = engine.CreateScope();
            var features = new Features
            {
                A = a,
                B = b
            };
            scope.SetVariable("features", features);
            var prediction = new Prediction();
            scope.SetVariable("prediction", prediction);

            var result = script.Execute(scope);

            var test = scope.GetVariable<Prediction>("prediction");

            return test.Result;
        }
Beispiel #21
0
        private static Features GenenerateTop100MajorCitiesFeatures()
        {
            List <City> c = new List <City>();

            c.Add(new City {
                CityName = "Tokyo", Lat = 35.69, Long = 139.75, Population = 22006300, Country = "Japan"
            });
            c.Add(new City {
                CityName = "Mumbai", Lat = 19.02, Long = 72.86, Population = 15834918, Country = "India"
            });
            c.Add(new City {
                CityName = "Mexico City", Lat = 19.44, Long = -99.13, Population = 14919501, Country = "Mexico"
            });
            c.Add(new City {
                CityName = "Shanghai", Lat = 31.22, Long = 121.44, Population = 14797756, Country = "China"
            });
            c.Add(new City {
                CityName = "Sao Paulo", Lat = -23.56, Long = -46.63, Population = 14433148, Country = "Brazil"
            });
            c.Add(new City {
                CityName = "New York", Lat = 40.75, Long = -73.98, Population = 13524139, Country = "United States of America"
            });
            c.Add(new City {
                CityName = "Karachi", Lat = 24.87, Long = 66.99, Population = 11877110, Country = "Pakistan"
            });
            c.Add(new City {
                CityName = "Buenos Aires", Lat = -34.6, Long = -58.4, Population = 11862073, Country = "Argentina"
            });
            c.Add(new City {
                CityName = "Delhi", Lat = 28.67, Long = 77.23, Population = 11779607, Country = "India"
            });
            c.Add(new City {
                CityName = "Moscow", Lat = 55.75, Long = 37.62, Population = 10452000, Country = "Russia"
            });
            c.Add(new City {
                CityName = "Istanbul", Lat = 41.1, Long = 29.01, Population = 10003305, Country = "Turkey"
            });
            c.Add(new City {
                CityName = "Dhaka", Lat = 23.72, Long = 90.41, Population = 9899167, Country = "Bangladesh"
            });
            c.Add(new City {
                CityName = "Cairo", Lat = 30.05, Long = 31.25, Population = 9813807, Country = "Egypt"
            });
            c.Add(new City {
                CityName = "Seoul", Lat = 37.57, Long = 127, Population = 9796000, Country = "South Korea"
            });
            c.Add(new City {
                CityName = "Kolkata", Lat = 22.49, Long = 88.32, Population = 9709196, Country = "India"
            });
            c.Add(new City {
                CityName = "Beijing", Lat = 39.93, Long = 116.39, Population = 9293301, Country = "China"
            });
            c.Add(new City {
                CityName = "Jakarta", Lat = -6.17, Long = 106.83, Population = 8832561, Country = "Indonesia"
            });
            c.Add(new City {
                CityName = "Los Angeles", Lat = 33.99, Long = -118.18, Population = 8097410, Country = "United States of America"
            });
            c.Add(new City {
                CityName = "London", Lat = 51.5, Long = -0.12, Population = 7994105, Country = "United Kingdom"
            });
            c.Add(new City {
                CityName = "Tehran", Lat = 35.67, Long = 51.42, Population = 7513155, Country = "Iran"
            });
            c.Add(new City {
                CityName = "Lima", Lat = -12.05, Long = -77.05, Population = 7385117, Country = "Peru"
            });
            c.Add(new City {
                CityName = "Manila", Lat = 14.6, Long = 120.98, Population = 7088788, Country = "Philippines"
            });
            c.Add(new City {
                CityName = "Bogota", Lat = 4.6, Long = -74.08, Population = 7052831, Country = "Colombia"
            });
            c.Add(new City {
                CityName = "Osaka", Lat = 34.75, Long = 135.46, Population = 6943207, Country = "Japan"
            });
            c.Add(new City {
                CityName = "Rio de Janeiro", Lat = -22.93, Long = -43.23, Population = 6879088, Country = "Brazil"
            });
            c.Add(new City {
                CityName = "Kinshasa", Lat = -4.33, Long = 15.31, Population = 6704352, Country = "Congo (Kinshasa)"
            });
            c.Add(new City {
                CityName = "Lahore", Lat = 31.56, Long = 74.35, Population = 6443944, Country = "Pakistan"
            });
            c.Add(new City {
                CityName = "Guangzhou", Lat = 23.14, Long = 113.33, Population = 5990913, Country = "China"
            });
            c.Add(new City {
                CityName = "Bangalore", Lat = 12.97, Long = 77.56, Population = 5945524, Country = "India"
            });
            c.Add(new City {
                CityName = "Chicago", Lat = 41.83, Long = -87.75, Population = 5915976, Country = "United States of America"
            });
            c.Add(new City {
                CityName = "Bangkok", Lat = 13.75, Long = 100.52, Population = 5904238, Country = "Thailand"
            });
            c.Add(new City {
                CityName = "Hong Kong", Lat = 22.3, Long = 114.19, Population = 5878790, Country = "Hong Kong S.A.R."
            });
            c.Add(new City {
                CityName = "Chennai", Lat = 13.09, Long = 80.28, Population = 5745532, Country = "India"
            });
            c.Add(new City {
                CityName = "Wuhan", Lat = 30.58, Long = 114.27, Population = 5713603, Country = "China"
            });
            c.Add(new City {
                CityName = "Tianjin", Lat = 39.13, Long = 117.2, Population = 5473104, Country = "China"
            });
            c.Add(new City {
                CityName = "Chongqing", Lat = 29.56, Long = 106.59, Population = 5214014, Country = "China"
            });
            c.Add(new City {
                CityName = "Baghdad", Lat = 33.34, Long = 44.39, Population = 5054000, Country = "Iraq"
            });
            c.Add(new City {
                CityName = "Hyderabad", Lat = 17.4, Long = 78.48, Population = 4986908, Country = "India"
            });
            c.Add(new City {
                CityName = "Paris", Lat = 48.87, Long = 2.33, Population = 4957589, Country = "France"
            });
            c.Add(new City {
                CityName = "Taipei", Lat = 25.04, Long = 121.57, Population = 4759523, Country = "Taiwan"
            });
            c.Add(new City {
                CityName = "Lagos", Lat = 6.44, Long = 3.39, Population = 4733768, Country = "Nigeria"
            });
            c.Add(new City {
                CityName = "Toronto", Lat = 43.7, Long = -79.42, Population = 4573711, Country = "Canada"
            });
            c.Add(new City {
                CityName = "Ahmedabad", Lat = 23.03, Long = 72.58, Population = 4547355, Country = "India"
            });
            c.Add(new City {
                CityName = "Dongguan", Lat = 23.05, Long = 113.74, Population = 4528000, Country = "China"
            });
            c.Add(new City {
                CityName = "Ho Chi Minh City", Lat = 10.78, Long = 106.7, Population = 4390666, Country = "Vietnam"
            });
            c.Add(new City {
                CityName = "Riyadh", Lat = 24.64, Long = 46.77, Population = 4335481, Country = "Saudi Arabia"
            });
            c.Add(new City {
                CityName = "Shenzhen", Lat = 22.55, Long = 114.12, Population = 4291796, Country = "China"
            });
            c.Add(new City {
                CityName = "Singapore", Lat = 1.29, Long = 103.86, Population = 4236615, Country = "Singapore"
            });
            c.Add(new City {
                CityName = "Chittagong", Lat = 22.33, Long = 91.8, Population = 4224611, Country = "Bangladesh"
            });
            c.Add(new City {
                CityName = "Shenyeng", Lat = 41.8, Long = 123.45, Population = 4149596, Country = "China"
            });
            c.Add(new City {
                CityName = "Sydney", Lat = -33.92, Long = 151.19, Population = 4135711, Country = "Australia"
            });
            c.Add(new City {
                CityName = "Houston", Lat = 29.82, Long = -95.34, Population = 4053287, Country = "United States of America"
            });
            c.Add(new City {
                CityName = "Chengdu", Lat = 30.67, Long = 104.07, Population = 4036719, Country = "China"
            });
            c.Add(new City {
                CityName = "St. Petersburg", Lat = 59.94, Long = 30.32, Population = 4023106, Country = "Russia"
            });
            c.Add(new City {
                CityName = "Alexandria", Lat = 31.2, Long = 29.95, Population = 3988258, Country = "Egypt"
            });
            c.Add(new City {
                CityName = "Belo Horizonte", Lat = -19.92, Long = -43.92, Population = 3974112, Country = "Brazil"
            });
            c.Add(new City {
                CityName = "Pune", Lat = 18.53, Long = 73.85, Population = 3803872, Country = "India"
            });
            c.Add(new City {
                CityName = "Yokohama", Lat = 35.32, Long = 139.58, Population = 3697894, Country = "Japan"
            });
            c.Add(new City {
                CityName = "Rangoon", Lat = 16.78, Long = 96.17, Population = 3694910, Country = "Myanmar"
            });
            c.Add(new City {
                CityName = "Xian", Lat = 34.28, Long = 108.89, Population = 3617406, Country = "China"
            });
            c.Add(new City {
                CityName = "Luanda", Lat = -8.84, Long = 13.23, Population = 3562086, Country = "Angola"
            });
            c.Add(new City {
                CityName = "Ankara", Lat = 39.93, Long = 32.86, Population = 3511690, Country = "Turkey"
            });
            c.Add(new City {
                CityName = "Philadelphia", Lat = 40, Long = -75.17, Population = 3504775, Country = "United States of America"
            });
            c.Add(new City {
                CityName = "Abidjan", Lat = 5.32, Long = -4.04, Population = 3496198, Country = "Ivory Coast"
            });
            c.Add(new City {
                CityName = "Busan", Lat = 35.1, Long = 129.01, Population = 3480000, Country = "South Korea"
            });
            c.Add(new City {
                CityName = "Harbin", Lat = 45.75, Long = 126.65, Population = 3425442, Country = "China"
            });
            c.Add(new City {
                CityName = "Nanjing", Lat = 32.05, Long = 118.78, Population = 3383005, Country = "China"
            });
            c.Add(new City {
                CityName = "Surat", Lat = 21.2, Long = 72.84, Population = 3368252, Country = "India"
            });
            c.Add(new City {
                CityName = "Khartoum", Lat = 15.59, Long = 32.53, Population = 3364324, Country = "Sudan"
            });
            c.Add(new City {
                CityName = "Hechi", Lat = 23.1, Long = 109.61, Population = 3275190, Country = "China"
            });
            c.Add(new City {
                CityName = "Barcelona", Lat = 41.38, Long = 2.18, Population = 3250798, Country = "Spain"
            });
            c.Add(new City {
                CityName = "Berlin", Lat = 52.52, Long = 13.4, Population = 3250007, Country = "Germany"
            });
            c.Add(new City {
                CityName = "Casablanca", Lat = 33.6, Long = -7.62, Population = 3162955, Country = "Morocco"
            });
            c.Add(new City {
                CityName = "Kabul", Lat = 34.52, Long = 69.18, Population = 3160266, Country = "Afghanistan"
            });
            c.Add(new City {
                CityName = "Kano", Lat = 12, Long = 8.52, Population = 3140000, Country = "Nigeria"
            });
            c.Add(new City {
                CityName = "Brasilia", Lat = -15.78, Long = -47.92, Population = 3139980, Country = "Brazil"
            });
            c.Add(new City {
                CityName = "Salvador", Lat = -12.97, Long = -38.48, Population = 3081423, Country = "Brazil"
            });
            c.Add(new City {
                CityName = "Montreal", Lat = 45.5, Long = -73.58, Population = 3017278, Country = "Canada"
            });
            c.Add(new City {
                CityName = "Dallas", Lat = 32.82, Long = -96.84, Population = 3004852, Country = "United States of America"
            });
            c.Add(new City {
                CityName = "Kanpur", Lat = 26.46, Long = 80.32, Population = 2992625, Country = "India"
            });
            c.Add(new City {
                CityName = "Miami", Lat = 25.79, Long = -80.22, Population = 2983947, Country = "United States of America"
            });
            c.Add(new City {
                CityName = "Fortaleza", Lat = -3.75, Long = -38.58, Population = 2958718, Country = "Brazil"
            });
            c.Add(new City {
                CityName = "Jeddah", Lat = 21.52, Long = 39.22, Population = 2939723, Country = "Saudi Arabia"
            });
            c.Add(new City {
                CityName = "Haora", Lat = 22.58, Long = 88.33, Population = 2934655, Country = "India"
            });
            c.Add(new City {
                CityName = "Addis Ababa", Lat = 9.03, Long = 38.7, Population = 2928865, Country = "Ethiopia"
            });
            c.Add(new City {
                CityName = "Guadalajara", Lat = 20.67, Long = -103.33, Population = 2919295, Country = "Mexico"
            });
            c.Add(new City {
                CityName = "Hanoi", Lat = 21.03, Long = 105.85, Population = 2904635, Country = "Vietnam"
            });
            c.Add(new City {
                CityName = "Pyongyang", Lat = 39.02, Long = 125.75, Population = 2899399, Country = "North Korea"
            });
            c.Add(new City {
                CityName = "Santiago", Lat = -33.45, Long = -70.67, Population = 2883306, Country = "Chile"
            });
            c.Add(new City {
                CityName = "Nairobi", Lat = -1.28, Long = 36.82, Population = 2880274, Country = "Kenya"
            });
            c.Add(new City {
                CityName = "Changchun", Lat = 43.87, Long = 125.34, Population = 2860211, Country = "China"
            });
            c.Add(new City {
                CityName = "Cape Town", Lat = -33.92, Long = 18.43, Population = 2823929, Country = "South Africa"
            });
            c.Add(new City {
                CityName = "New Taipei", Lat = 25.01, Long = 121.47, Population = 2821870, Country = "Taiwan"
            });
            c.Add(new City {
                CityName = "Taiyuan", Lat = 37.88, Long = 112.55, Population = 2817738, Country = "China"
            });
            c.Add(new City {
                CityName = "Jaipur", Lat = 26.92, Long = 75.81, Population = 2814379, Country = "India"
            });
            c.Add(new City {
                CityName = "Dar es Salaam", Lat = -6.8, Long = 39.27, Population = 2814326, Country = "Tanzania"
            });
            c.Add(new City {
                CityName = "Madrid", Lat = 40.4, Long = -3.68, Population = 2808719, Country = "Spain"
            });
            c.Add(new City {
                CityName = "Quezon City", Lat = 14.65, Long = 121.03, Population = 2761720, Country = "Philippines"
            });
            c.Add(new City {
                CityName = "Johannesburg", Lat = -26.17, Long = 28.03, Population = 2730735, Country = "South Africa"
            });
            c.Add(new City {
                CityName = "Durban", Lat = -29.87, Long = 30.98, Population = 2729000, Country = "South Africa"
            });

            var features = new Features();

            foreach (City item in c)
            {
                var geo = new Point(item.Long, item.Lat);
                features.Add(new Feature {
                    Geometry = geo, ["NAME"] = item.CityName, ["COUNTRY"] = item.Country, ["POPULATION"] = item.Population
                });
            }

            return(features);
        }
Beispiel #22
0
 protected ServerTypeViewModel(Features features)
 {
     Features = features;
 }
Beispiel #23
0
 public bool GetFeature(GameFeatures feature) => Features.Get((int)feature);
Beispiel #24
0
 public void EnableFeature(GameFeatures feature) => Features.Set((int)feature, true);
 public override bool CanUpdate() =>
 base.CanUpdate() &&
 Features.Any() &&            // can not update if there are no features...
 !isTaskRunning &&            // can not update if there is already a task running
 refreshSet.Count > 0;        // can not update if there are no request...
Beispiel #26
0
 internal static HandleRef getCPtr(Features obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Beispiel #27
0
            public Encoder(byte[] input, IHasher hasher, BrotliFileParameters fileParameters, Features features)
            {
                this.input          = input;
                this.hasher         = hasher;
                this.fileParameters = fileParameters;

                this.features = features;
                this.lgBlock  = ComputeLgBlock(features);
            }
        private string FormatArguments(FormatFlags formatFlags, params string[] args)
        {
            // Validation.
            ArgUtil.NotNull(args, nameof(args));
            ArgUtil.NotNull(Endpoint, nameof(Endpoint));
            ArgUtil.NotNull(Endpoint.Authorization, nameof(Endpoint.Authorization));
            ArgUtil.NotNull(Endpoint.Authorization.Parameters, nameof(Endpoint.Authorization.Parameters));
            ArgUtil.Equal(EndpointAuthorizationSchemes.OAuth, Endpoint.Authorization.Scheme, nameof(Endpoint.Authorization.Scheme));
            string accessToken = Endpoint.Authorization.Parameters.TryGetValue(EndpointAuthorizationParameters.AccessToken, out accessToken) ? accessToken : null;

            ArgUtil.NotNullOrEmpty(accessToken, EndpointAuthorizationParameters.AccessToken);
            ArgUtil.NotNull(Repository?.Url ?? Endpoint.Url, nameof(Endpoint.Url));

            // Format each arg.
            var formattedArgs = new List <string>();

            foreach (string arg in args ?? new string[0])
            {
                // Validate the arg.
                if (!string.IsNullOrEmpty(arg) && arg.IndexOfAny(new char[] { '"', '\r', '\n' }) >= 0)
                {
                    throw new Exception(StringUtil.Loc("InvalidCommandArg", arg));
                }

                // Add the arg.
                formattedArgs.Add(arg != null && arg.Contains(" ") ? $@"""{arg}""" : $"{arg}");
            }

            // Add the common parameters.
            if (!formatFlags.HasFlag(FormatFlags.OmitCollectionUrl))
            {
                if (Features.HasFlag(TfsVCFeatures.EscapedUrl))
                {
                    formattedArgs.Add($"{Switch}collection:{Repository?.Url?.AbsoluteUri ?? Endpoint.Url.AbsoluteUri}");
                }
                else
                {
                    // TEE CLC expects the URL in unescaped form.
                    string url;
                    try
                    {
                        url = Uri.UnescapeDataString(Repository?.Url?.AbsoluteUri ?? Endpoint.Url.AbsoluteUri);
                    }
                    catch (Exception ex)
                    {
                        // Unlikely (impossible?), but don't fail if encountered. If we don't hear complaints
                        // about this warning then it is likely OK to remove the try/catch altogether and have
                        // faith that UnescapeDataString won't throw for this scenario.
                        url = Repository?.Url?.AbsoluteUri ?? Endpoint.Url.AbsoluteUri;
                        ExecutionContext.Warning($"{ex.Message} ({url})");
                    }

                    formattedArgs.Add($"\"{Switch}collection:{url}\"");
                }
            }

            if (!formatFlags.HasFlag(FormatFlags.OmitLogin))
            {
                if (Features.HasFlag(TfsVCFeatures.LoginType))
                {
                    formattedArgs.Add($"{Switch}loginType:OAuth");
                    formattedArgs.Add($"{Switch}login:.,{accessToken}");
                }
                else
                {
                    formattedArgs.Add($"{Switch}jwt:{accessToken}");
                }
            }

            if (!formatFlags.HasFlag(FormatFlags.OmitNoPrompt))
            {
                formattedArgs.Add($"{Switch}noprompt");
            }

            return(string.Join(" ", formattedArgs));
        }
Beispiel #29
0
 public MasterController(IOptions <Features> _feature, IOptions <LocalNetwork> _network)
 {
     this.features = _feature.Value;
     this.network  = _network.Value;
 }
Beispiel #30
0
 public static void AllowFeature(Features feature)
 {
     SetDisallowed(feature, false);
 }
Beispiel #31
0
 public static void DisallowFeature(Features feature)
 {
     SetDisallowed(feature, true);
 }
Beispiel #32
0
            /// <summary>
            /// gets realtime data from public transport in city vilnius of lithuania
            /// </summary>
            private void GetVilniusTransportData(string line)
            {
                if (_isActive)
                {
                    return;
                }
                _isActive = true;

                //List<FeatureDataRow> newFeatures = new List<FeatureDataRow>();
                var fdt = VehicleDataTable();

                string url = "http://www.troleibusai.lt/puslapiai/services/vehiclestate.php?type=";

                switch (_transportType)
                {
                case TransportType.Bus:
                {
                    url += "bus";
                }
                break;

                case TransportType.TrolleyBus:
                {
                    url += "trolley";
                }
                break;
                }

                if (!string.IsNullOrEmpty(line))
                {
                    url += "&line=" + line;
                }

                url += "&app=SharpMap.WinFormSamples";

                var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);

                request.Timeout          = Timeout;
                request.ReadWriteTimeout = request.Timeout;
                request.Accept           = "*/*";
                request.KeepAlive        = false;

                string xml;

                using (var response = request.GetResponse() as System.Net.HttpWebResponse)
                {
                    if (response == null)
                    {
                        return;
                    }

                    using (var responseStream = response.GetResponseStream())
                    {
                        if (responseStream == null)
                        {
                            return;
                        }
                        using (var read = new System.IO.StreamReader(responseStream))
                        {
                            xml = read.ReadToEnd();
                        }
                    }
                }

                var doc = new System.Xml.XmlDocument();

                {
                    doc.LoadXml(xml);

                    var devices = doc.GetElementsByTagName("Device");
                    foreach (System.Xml.XmlNode dev in devices)
                    {
                        if (dev.Attributes == null)
                        {
                            continue;
                        }

                        double?lat = null, lng = null;
                        SharpMap.Data.FeatureDataRow dr = fdt.NewRow();
                        dr["Id"] = int.Parse(dev.Attributes["ID"].InnerText);
                        foreach (System.Xml.XmlElement elem in dev.ChildNodes)
                        {
                            // Debug.WriteLine(d.Id + "->" + elem.Name + ": " + elem.InnerText);

                            switch (elem.Name)
                            {
                            case "Lat":
                                lat = double.Parse(elem.InnerText, System.Globalization.CultureInfo.InvariantCulture);
                                break;

                            case "Lng":
                                lng = double.Parse(elem.InnerText, System.Globalization.CultureInfo.InvariantCulture);
                                break;

                            case "Bearing":
                                if (!string.IsNullOrEmpty(elem.InnerText))
                                {
                                    dr["Bearing"] = double.Parse(elem.InnerText, System.Globalization.CultureInfo.InvariantCulture);
                                }
                                break;

                            case "LineNum":
                                dr["Line"] = elem.InnerText;
                                break;

                            case "AreaName":
                                dr["AreaName"] = elem.InnerText;
                                break;

                            case "StreetName":
                                dr["StreetName"] = elem.InnerText;
                                break;

                            case "TrackType":
                                dr["TrackType"] = elem.InnerText;
                                break;

                            case "LastStop":
                                dr["LastStop"] = elem.InnerText;
                                break;

                            case "Time":
                                dr["Time"] = elem.InnerText;
                                break;
                            }
                        }

                        if (lat.HasValue && lng.HasValue)
                        {
                            dr.Geometry = _factory.CreatePoint(new GeoAPI.Geometries.Coordinate(lng.Value, lat.Value));
                            fdt.Rows.Add(dr);
                        }
                    }
                }

                Features.Clear();

                foreach (SharpMap.Data.FeatureDataRow featureDataRow in fdt.Rows)
                {
                    var fdr = Features.NewRow();
                    fdr.ItemArray = featureDataRow.ItemArray;
                    fdr.Geometry  = featureDataRow.Geometry;
                    Features.AddRow(fdr);
                }
                Features.AcceptChanges();

                _isActive = false;
            }
Beispiel #33
0
 /// <summary>
 /// Adapted from https://github.com/google/brotli/blob/master/c/enc/quality.h (ComputeLgBlock).
 /// </summary>
 private static int ComputeLgBlock(Features features)
 {
     return(features.HasFlag(Features.BlockSplit) ? 16 : 14);
 }
Beispiel #34
0
 public KernelDistance(Features l, Features r, double width, Kernel k) : this(modshogunPINVOKE.new_KernelDistance__SWIG_2(Features.getCPtr(l), Features.getCPtr(r), width, Kernel.getCPtr(k)), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Beispiel #35
0
        /// <summary>Dumps an optical disc</summary>
        void Mmc()
        {
            MediaType dskType = MediaType.Unknown;
            bool      sense;

            byte[] tmpBuf;
            bool   compactDisc = true;
            bool   isXbox      = false;

            _speedMultiplier = 1;

            // TODO: Log not only what is it reading, but if it was read correctly or not.
            sense = _dev.GetConfiguration(out byte[] cmdBuf, out _, 0, MmcGetConfigurationRt.Current, _dev.Timeout,
                                          out _);

            if (!sense)
            {
                Features.SeparatedFeatures ftr = Features.Separate(cmdBuf);
                _dumpLog.WriteLine("Device reports current profile is 0x{0:X4}", ftr.CurrentProfile);

                switch (ftr.CurrentProfile)
                {
                case 0x0001:
                    dskType          = MediaType.GENERIC_HDD;
                    _speedMultiplier = -1;
                    goto default;

                case 0x0002:
                    dskType          = MediaType.PD650;
                    _speedMultiplier = -1;
                    goto default;

                case 0x0005:
                    dskType = MediaType.CDMO;

                    break;

                case 0x0008:
                    dskType = MediaType.CD;

                    break;

                case 0x0009:
                    dskType = MediaType.CDR;

                    break;

                case 0x000A:
                    dskType = MediaType.CDRW;

                    break;

                case 0x0010:
                    dskType          = MediaType.DVDROM;
                    _speedMultiplier = 9;
                    goto default;

                case 0x0011:
                    dskType          = MediaType.DVDR;
                    _speedMultiplier = 9;
                    goto default;

                case 0x0012:
                    dskType          = MediaType.DVDRAM;
                    _speedMultiplier = 9;
                    goto default;

                case 0x0013:
                case 0x0014:
                    dskType          = MediaType.DVDRW;
                    _speedMultiplier = 9;
                    goto default;

                case 0x0015:
                case 0x0016:
                    dskType          = MediaType.DVDRDL;
                    _speedMultiplier = 9;
                    goto default;

                case 0x0017:
                    dskType          = MediaType.DVDRWDL;
                    _speedMultiplier = 9;
                    goto default;

                case 0x0018:
                    dskType          = MediaType.DVDDownload;
                    _speedMultiplier = 9;
                    goto default;

                case 0x001A:
                    dskType          = MediaType.DVDPRW;
                    _speedMultiplier = 9;
                    goto default;

                case 0x001B:
                    dskType          = MediaType.DVDPR;
                    _speedMultiplier = 9;
                    goto default;

                case 0x0020:
                    dskType = MediaType.DDCD;
                    goto default;

                case 0x0021:
                    dskType = MediaType.DDCDR;
                    goto default;

                case 0x0022:
                    dskType = MediaType.DDCDRW;
                    goto default;

                case 0x002A:
                    dskType          = MediaType.DVDPRWDL;
                    _speedMultiplier = 9;
                    goto default;

                case 0x002B:
                    dskType          = MediaType.DVDPRDL;
                    _speedMultiplier = 9;
                    goto default;

                case 0x0040:
                    dskType          = MediaType.BDROM;
                    _speedMultiplier = 30;
                    goto default;

                case 0x0041:
                case 0x0042:
                    dskType          = MediaType.BDR;
                    _speedMultiplier = 30;
                    goto default;

                case 0x0043:
                    dskType          = MediaType.BDRE;
                    _speedMultiplier = 30;
                    goto default;

                case 0x0050:
                    dskType          = MediaType.HDDVDROM;
                    _speedMultiplier = 30;
                    goto default;

                case 0x0051:
                    dskType          = MediaType.HDDVDR;
                    _speedMultiplier = 30;
                    goto default;

                case 0x0052:
                    dskType          = MediaType.HDDVDRAM;
                    _speedMultiplier = 30;
                    goto default;

                case 0x0053:
                    dskType          = MediaType.HDDVDRW;
                    _speedMultiplier = 30;
                    goto default;

                case 0x0058:
                    dskType          = MediaType.HDDVDRDL;
                    _speedMultiplier = 30;
                    goto default;

                case 0x005A:
                    dskType          = MediaType.HDDVDRWDL;
                    _speedMultiplier = 30;
                    goto default;

                default:
                    compactDisc = false;

                    break;
                }
            }

            if (compactDisc)
            {
                _speedMultiplier *= 177;
                CompactDisc();

                return;
            }

            _speedMultiplier *= 150;

            var   scsiReader = new Reader(_dev, _dev.Timeout, null, _dumpRaw);
            ulong blocks     = scsiReader.GetDeviceBlocks();

            _dumpLog.WriteLine("Device reports disc has {0} blocks", blocks);
            Dictionary <MediaTagType, byte[]> mediaTags = new Dictionary <MediaTagType, byte[]>();

            if (dskType == MediaType.PD650)
            {
                switch (blocks + 1)
                {
                case 1281856:
                    dskType = MediaType.PD650_WORM;

                    break;

                case 58620544:
                    dskType = MediaType.REV120;

                    break;

                case 17090880:
                    dskType = MediaType.REV35;

                    break;

                // TODO: Unknown value
                default:
                    dskType = MediaType.REV70;

                    break;
                }
            }

            #region Nintendo
            switch (dskType)
            {
            case MediaType.Unknown when blocks > 0:
                _dumpLog.WriteLine("Reading Physical Format Information");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.PhysicalInformation, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    PFI.PhysicalFormatInformation?nintendoPfi = PFI.Decode(cmdBuf);

                    if (nintendoPfi != null)
                    {
                        if (nintendoPfi.Value.DiskCategory == DiskCategory.Nintendo &&
                            nintendoPfi.Value.PartVersion == 15)
                        {
                            _dumpLog.WriteLine("Dumping Nintendo GameCube or Wii discs is not yet implemented.");

                            StoppingErrorMessage?.
                            Invoke("Dumping Nintendo GameCube or Wii discs is not yet implemented.");

                            return;
                        }
                    }
                }

                break;

            case MediaType.DVDDownload:
            case MediaType.DVDPR:
            case MediaType.DVDPRDL:
            case MediaType.DVDPRW:
            case MediaType.DVDPRWDL:
            case MediaType.DVDR:
            case MediaType.DVDRAM:
            case MediaType.DVDRDL:
            case MediaType.DVDROM:
            case MediaType.DVDRW:
            case MediaType.DVDRWDL:
            case MediaType.HDDVDR:
            case MediaType.HDDVDRAM:
            case MediaType.HDDVDRDL:
            case MediaType.HDDVDROM:
            case MediaType.HDDVDRW:
            case MediaType.HDDVDRWDL:
                _dumpLog.WriteLine("Reading Physical Format Information");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.PhysicalInformation, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    if (PFI.Decode(cmdBuf).HasValue)
                    {
                        tmpBuf = new byte[cmdBuf.Length - 4];
                        Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                        mediaTags.Add(MediaTagType.DVD_PFI, tmpBuf);

                        PFI.PhysicalFormatInformation decPfi = PFI.Decode(cmdBuf).Value;
                        UpdateStatus?.Invoke($"PFI:\n{PFI.Prettify(decPfi)}");

                        // False book types
                        if (dskType == MediaType.DVDROM)
                        {
                            switch (decPfi.DiskCategory)
                            {
                            case DiskCategory.DVDPR:
                                dskType = MediaType.DVDPR;

                                break;

                            case DiskCategory.DVDPRDL:
                                dskType = MediaType.DVDPRDL;

                                break;

                            case DiskCategory.DVDPRW:
                                dskType = MediaType.DVDPRW;

                                break;

                            case DiskCategory.DVDPRWDL:
                                dskType = MediaType.DVDPRWDL;

                                break;

                            case DiskCategory.DVDR:
                                dskType = decPfi.PartVersion == 6 ? MediaType.DVDRDL : MediaType.DVDR;

                                break;

                            case DiskCategory.DVDRAM:
                                dskType = MediaType.DVDRAM;

                                break;

                            default:
                                dskType = MediaType.DVDROM;

                                break;

                            case DiskCategory.DVDRW:
                                dskType = decPfi.PartVersion == 3 ? MediaType.DVDRWDL : MediaType.DVDRW;

                                break;

                            case DiskCategory.HDDVDR:
                                dskType = MediaType.HDDVDR;

                                break;

                            case DiskCategory.HDDVDRAM:
                                dskType = MediaType.HDDVDRAM;

                                break;

                            case DiskCategory.HDDVDROM:
                                dskType = MediaType.HDDVDROM;

                                break;

                            case DiskCategory.HDDVDRW:
                                dskType = MediaType.HDDVDRW;

                                break;

                            case DiskCategory.Nintendo:
                                dskType = decPfi.DiscSize == DVDSize.Eighty ? MediaType.GOD : MediaType.WOD;

                                break;

                            case DiskCategory.UMD:
                                dskType = MediaType.UMD;

                                break;
                            }
                        }
                    }
                }

                _dumpLog.WriteLine("Reading Disc Manufacturing Information");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.DiscManufacturingInformation, 0, _dev.Timeout,
                                               out _);

                if (!sense)
                {
                    if (DMI.IsXbox(cmdBuf) ||
                        DMI.IsXbox360(cmdBuf))
                    {
                        if (DMI.IsXbox(cmdBuf))
                        {
                            dskType = MediaType.XGD;
                        }
                        else if (DMI.IsXbox360(cmdBuf))
                        {
                            dskType = MediaType.XGD2;

                            // All XGD3 all have the same number of blocks
                            if (blocks == 25063 ||      // Locked (or non compatible drive)
                                blocks == 4229664 ||    // Xtreme unlock
                                blocks == 4246304)      // Wxripper unlock
                            {
                                dskType = MediaType.XGD3;
                            }
                        }

                        sense = _dev.ScsiInquiry(out byte[] inqBuf, out _);

                        if (sense ||
                            !Inquiry.Decode(inqBuf).HasValue ||
                            (Inquiry.Decode(inqBuf).HasValue&& !Inquiry.Decode(inqBuf).Value.KreonPresent))
                        {
                            _dumpLog.WriteLine("Dumping Xbox Game Discs requires a drive with Kreon firmware.");

                            StoppingErrorMessage?.
                            Invoke("Dumping Xbox Game Discs requires a drive with Kreon firmware.");

                            return;
                        }

                        if (_dumpRaw && !_force)
                        {
                            StoppingErrorMessage?.
                            Invoke("Not continuing. If you want to continue reading cooked data when raw is not available use the force option.");

                            // TODO: Exit more gracefully
                            return;
                        }

                        isXbox = true;
                    }

                    if (cmdBuf.Length == 2052)
                    {
                        tmpBuf = new byte[cmdBuf.Length - 4];
                        Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                        mediaTags.Add(MediaTagType.DVD_DMI, tmpBuf);
                    }
                }

                break;
            }
            #endregion Nintendo

            #region All DVD and HD DVD types
            #endregion All DVD and HD DVD types

            #region DVD-ROM
            if (dskType == MediaType.DVDDownload ||
                dskType == MediaType.DVDROM)
            {
                _dumpLog.WriteLine("Reading Lead-in Copyright Information.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.CopyrightInformation, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    if (CSS_CPRM.DecodeLeadInCopyright(cmdBuf).HasValue)
                    {
                        tmpBuf = new byte[cmdBuf.Length - 4];
                        Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                        mediaTags.Add(MediaTagType.DVD_CMI, tmpBuf);
                    }
                }
            }
            #endregion DVD-ROM

            switch (dskType)
            {
                #region DVD-ROM and HD DVD-ROM
            case MediaType.DVDDownload:
            case MediaType.DVDROM:
            case MediaType.HDDVDROM:
                _dumpLog.WriteLine("Reading Burst Cutting Area.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.BurstCuttingArea, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    tmpBuf = new byte[cmdBuf.Length - 4];
                    Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                    mediaTags.Add(MediaTagType.DVD_BCA, tmpBuf);
                }

                break;
                #endregion DVD-ROM and HD DVD-ROM

                #region DVD-RAM and HD DVD-RAM
            case MediaType.DVDRAM:
            case MediaType.HDDVDRAM:
                _dumpLog.WriteLine("Reading Disc Description Structure.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.DvdramDds, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    if (DDS.Decode(cmdBuf).HasValue)
                    {
                        tmpBuf = new byte[cmdBuf.Length - 4];
                        Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                        mediaTags.Add(MediaTagType.DVDRAM_DDS, tmpBuf);
                    }
                }

                _dumpLog.WriteLine("Reading Spare Area Information.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.DvdramSpareAreaInformation, 0, _dev.Timeout,
                                               out _);

                if (!sense)
                {
                    if (Spare.Decode(cmdBuf).HasValue)
                    {
                        tmpBuf = new byte[cmdBuf.Length - 4];
                        Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                        mediaTags.Add(MediaTagType.DVDRAM_SpareArea, tmpBuf);
                    }
                }

                break;
                #endregion DVD-RAM and HD DVD-RAM

                #region DVD-R and DVD-RW
            case MediaType.DVDR:
            case MediaType.DVDRW:
                _dumpLog.WriteLine("Reading Pre-Recorded Information.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.PreRecordedInfo, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    tmpBuf = new byte[cmdBuf.Length - 4];
                    Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                    mediaTags.Add(MediaTagType.DVDR_PreRecordedInfo, tmpBuf);
                }

                break;
                #endregion DVD-R and DVD-RW
            }

            switch (dskType)
            {
                #region DVD-R, DVD-RW and HD DVD-R
            case MediaType.DVDR:
            case MediaType.DVDRW:
            case MediaType.HDDVDR:
                _dumpLog.WriteLine("Reading Media Identifier.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.DvdrMediaIdentifier, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    tmpBuf = new byte[cmdBuf.Length - 4];
                    Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                    mediaTags.Add(MediaTagType.DVDR_MediaIdentifier, tmpBuf);
                }

                _dumpLog.WriteLine("Reading Recordable Physical Information.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.DvdrPhysicalInformation, 0, _dev.Timeout,
                                               out _);

                if (!sense)
                {
                    tmpBuf = new byte[cmdBuf.Length - 4];
                    Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                    mediaTags.Add(MediaTagType.DVDR_PFI, tmpBuf);
                }

                break;
                #endregion DVD-R, DVD-RW and HD DVD-R

                #region All DVD+
            case MediaType.DVDPR:
            case MediaType.DVDPRDL:
            case MediaType.DVDPRW:
            case MediaType.DVDPRWDL:
                _dumpLog.WriteLine("Reading ADdress In Pregroove.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.Adip, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    tmpBuf = new byte[cmdBuf.Length - 4];
                    Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                    mediaTags.Add(MediaTagType.DVD_ADIP, tmpBuf);
                }

                _dumpLog.WriteLine("Reading Disc Control Blocks.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.Dcb, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    tmpBuf = new byte[cmdBuf.Length - 4];
                    Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                    mediaTags.Add(MediaTagType.DCB, tmpBuf);
                }

                break;
                #endregion All DVD+

                #region HD DVD-ROM
            case MediaType.HDDVDROM:
                _dumpLog.WriteLine("Reading Lead-in Copyright Information.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Dvd, 0, 0,
                                               MmcDiscStructureFormat.HddvdCopyrightInformation, 0, _dev.Timeout,
                                               out _);

                if (!sense)
                {
                    tmpBuf = new byte[cmdBuf.Length - 4];
                    Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                    mediaTags.Add(MediaTagType.HDDVD_CPI, tmpBuf);
                }

                break;
                #endregion HD DVD-ROM

                #region All Blu-ray
            case MediaType.BDR:
            case MediaType.BDRE:
            case MediaType.BDROM:
            case MediaType.BDRXL:
            case MediaType.BDREXL:
                _dumpLog.WriteLine("Reading Disc Information.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
                                               MmcDiscStructureFormat.DiscInformation, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    if (DI.Decode(cmdBuf).HasValue)
                    {
                        tmpBuf = new byte[cmdBuf.Length - 4];
                        Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                        mediaTags.Add(MediaTagType.BD_DI, tmpBuf);
                    }
                }

                // TODO: PAC

                /*
                 * dumpLog.WriteLine("Reading PAC.");
                 * sense = dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
                 *                            MmcDiscStructureFormat.Pac, 0, dev.Timeout, out _);
                 * if(!sense)
                 * {
                 *  tmpBuf = new byte[cmdBuf.Length - 4];
                 *  Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                 *  mediaTags.Add(MediaTagType.PAC, tmpBuf);
                 * }*/
                break;
                #endregion All Blu-ray
            }

            switch (dskType)
            {
                #region BD-ROM only
            case MediaType.BDROM:
                _dumpLog.WriteLine("Reading Burst Cutting Area.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
                                               MmcDiscStructureFormat.BdBurstCuttingArea, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    tmpBuf = new byte[cmdBuf.Length - 4];
                    Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                    mediaTags.Add(MediaTagType.BD_BCA, tmpBuf);
                }

                break;
                #endregion BD-ROM only

                #region Writable Blu-ray only
            case MediaType.BDR:
            case MediaType.BDRE:
            case MediaType.BDRXL:
            case MediaType.BDREXL:
                _dumpLog.WriteLine("Reading Disc Definition Structure.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
                                               MmcDiscStructureFormat.BdDds, 0, _dev.Timeout, out _);

                if (!sense)
                {
                    tmpBuf = new byte[cmdBuf.Length - 4];
                    Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                    mediaTags.Add(MediaTagType.BD_DDS, tmpBuf);
                }

                _dumpLog.WriteLine("Reading Spare Area Information.");

                sense = _dev.ReadDiscStructure(out cmdBuf, out _, MmcDiscStructureMediaType.Bd, 0, 0,
                                               MmcDiscStructureFormat.BdSpareAreaInformation, 0, _dev.Timeout,
                                               out _);

                if (!sense)
                {
                    tmpBuf = new byte[cmdBuf.Length - 4];
                    Array.Copy(cmdBuf, 4, tmpBuf, 0, cmdBuf.Length - 4);
                    mediaTags.Add(MediaTagType.BD_SpareArea, tmpBuf);
                }

                break;
                #endregion Writable Blu-ray only
            }

            if (isXbox)
            {
                Xgd(mediaTags, dskType);

                return;
            }

            Sbc(mediaTags, dskType, true);
        }
Beispiel #36
0
 public virtual void set_features(Features f) {
   modshogunPINVOKE.Distribution_set_features(swigCPtr, Features.getCPtr(f));
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Beispiel #37
0
        public static void Initialize()
        {
            // glGetError and glGetString are used in our error handlers
            // so we want these to be available early.
            openGLDebugDelegate = OpenGLDebugCallback;
            try
            {
                glGetError          = Bind <GetError>("glGetError");
                glGetStringInternal = Bind <GetString>("glGetString");
            }
            catch (Exception)
            {
                throw new InvalidProgramException("Failed to initialize low-level OpenGL bindings. GPU information is not available");
            }


            DetectGLFeatures();
            if (!Features.HasFlag(GLFeatures.GL2OrGreater) || !Features.HasFlag(GLFeatures.FramebufferExt))
            {
                WriteGraphicsLog("Unsupported OpenGL version: " + glGetString(GL_VERSION));
                throw new InvalidProgramException("OpenGL Version Error: See graphics.log for details.");
            }
            else
            {
                Console.WriteLine("OpenGL version: " + glGetString(GL_VERSION));
            }

            try
            {
                glDeleteProgram        = Bind <DeleteProgramDelegate>("glDeleteProgram");
                glDeleteShader         = Bind <DeleteShaderDelegate>("glDeleteShader");
                glDetachShader         = Bind <DetachShaderDelegate>("glDetachShader");
                glDebugMessageControl  = Bind <glDebugMessageControlDelegate>("glDebugMessageControl");
                glDebugMessageCallback = Bind <glDebugMessageCallbackDelegate>("glDebugMessageCallback");
                glDebugMessageCallback(openGLDebugDelegate, IntPtr.Zero);
                glDebugMessageControl(DebugSourceControl.GL_DONT_CARE, DebugTypeControl.GL_DONT_CARE, DebugSeverityControl.GL_DEBUG_SEVERITY_LOW, 0, new uint[0], true);

                glGenVertexArrays          = Bind <glGenVertexArraysDeleagte>("glGenVertexArrays");
                glBindVertexArray          = Bind <glBindVertexArrayDelegate>("glBindVertexArray");
                glFlush                    = Bind <Flush>("glFlush");
                glViewport                 = Bind <Viewport>("glViewport");
                glClear                    = Bind <Clear>("glClear");
                glClearColor               = Bind <ClearColor>("glClearColor");
                glGetIntegerv              = Bind <GetIntegerv>("glGetIntegerv");
                glFinish                   = Bind <Finish>("glFinish");
                glCreateProgram            = Bind <CreateProgram>("glCreateProgram");
                glUseProgram               = Bind <UseProgram>("glUseProgram");
                glGetProgramiv             = Bind <GetProgramiv>("glGetProgramiv");
                glCreateShader             = Bind <CreateShader>("glCreateShader");
                glShaderSource             = Bind <ShaderSource>("glShaderSource");
                glCompileShader            = Bind <CompileShader>("glCompileShader");
                glGetShaderiv              = Bind <GetShaderiv>("glGetShaderiv");
                glAttachShader             = Bind <AttachShader>("glAttachShader");
                glGetShaderInfoLog         = Bind <GetShaderInfoLog>("glGetShaderInfoLog");
                glLinkProgram              = Bind <LinkProgram>("glLinkProgram");
                glGetProgramInfoLog        = Bind <GetProgramInfoLog>("glGetProgramInfoLog");
                glGetUniformLocation       = Bind <GetUniformLocation>("glGetUniformLocation");
                glGetActiveUniform         = Bind <GetActiveUniform>("glGetActiveUniform");
                glUniform1i                = Bind <Uniform1i>("glUniform1i");
                glUniform1f                = Bind <Uniform1f>("glUniform1f");
                glUniform2f                = Bind <Uniform2f>("glUniform2f");
                glUniform3f                = Bind <Uniform3f>("glUniform3f");
                glUniform1fv               = Bind <Uniform1fv>("glUniform1fv");
                glUniform2fv               = Bind <Uniform2fv>("glUniform2fv");
                glUniform3fv               = Bind <Uniform3fv>("glUniform3fv");
                glUniform4fv               = Bind <Uniform4fv>("glUniform4fv");
                glUniformMatrix4fv         = Bind <UniformMatrix4fv>("glUniformMatrix4fv");
                glGenBuffers               = Bind <GenBuffers>("glGenBuffers");
                glBindBuffer               = Bind <BindBuffer>("glBindBuffer");
                glBufferData               = Bind <BufferData>("glBufferData");
                glBufferSubData            = Bind <BufferSubData>("glBufferSubData");
                glDeleteBuffers            = Bind <DeleteBuffers>("glDeleteBuffers");
                glBindAttribLocation       = Bind <BindAttribLocation>("glBindAttribLocation");
                glVertexAttribPointer      = Bind <VertexAttribPointer>("glVertexAttribPointer");
                glEnableVertexAttribArray  = Bind <EnableVertexAttribArray>("glEnableVertexAttribArray");
                glDisableVertexAttribArray = Bind <DisableVertexAttribArray>("glDisableVertexAttribArray");
                glDrawArrays               = Bind <DrawArrays>("glDrawArrays");
                glEnable                   = Bind <Enable>("glEnable");
                glDisable                  = Bind <Disable>("glDisable");
                glBlendEquation            = Bind <BlendEquation>("glBlendEquation");
                glBlendFunc                = Bind <BlendFunc>("glBlendFunc");
                glDepthFunc                = Bind <DepthFunc>("glDepthFunc");
                glScissor                  = Bind <Scissor>("glScissor");
                glPushClientAttrib         = Bind <PushClientAttrib>("glPushClientAttrib");
                glPopClientAttrib          = Bind <PopClientAttrib>("glPopClientAttrib");
                glPixelStoref              = Bind <PixelStoref>("glPixelStoref");
                glReadPixels               = Bind <ReadPixels>("glReadPixels");
                glGenTextures              = Bind <GenTextures>("glGenTextures");
                glDeleteTextures           = Bind <DeleteTextures>("glDeleteTextures");
                glBindTexture              = Bind <BindTexture>("glBindTexture");
                glActiveTexture            = Bind <ActiveTexture>("glActiveTexture");
                glTexImage2D               = Bind <TexImage2D>("glTexImage2D");
                glTexSubImage3D            = Bind <TexSubImage3D>("glTexSubImage3D");
                glTexImage3D               = Bind <TexImage3D>("glTexImage3D");
                glGetTexImage              = Bind <GetTexImage>("glGetTexImage");
                glTexParameteri            = Bind <TexParameteri>("glTexParameteri");
                glTexParameterf            = Bind <TexParameterf>("glTexParameterf");
                glGenFramebuffers          = Bind <GenFramebuffers>("glGenFramebuffersEXT");
                glBindFramebuffer          = Bind <BindFramebuffer>("glBindFramebufferEXT");
                glFramebufferTexture2D     = Bind <FramebufferTexture2D>("glFramebufferTexture2DEXT");
                glDeleteFramebuffers       = Bind <DeleteFramebuffers>("glDeleteFramebuffersEXT");
                glGenRenderbuffers         = Bind <GenRenderbuffers>("glGenRenderbuffersEXT");
                glBindRenderbuffer         = Bind <BindRenderbuffer>("glBindRenderbufferEXT");
                glRenderbufferStorage      = Bind <RenderbufferStorage>("glRenderbufferStorageEXT");
                glDeleteRenderbuffers      = Bind <DeleteRenderbuffers>("glDeleteRenderbuffersEXT");
                glFramebufferRenderbuffer  = Bind <FramebufferRenderbuffer>("glFramebufferRenderbufferEXT");
                glCheckFramebufferStatus   = Bind <CheckFramebufferStatus>("glCheckFramebufferStatusEXT");
            }
            catch (Exception e)
            {
                WriteGraphicsLog("Failed to initialize OpenGL bindings.\nInner exception was: {0}".F(e));
                throw new InvalidProgramException("Failed to initialize OpenGL. See graphics.log for details.");
            }

            glEnable(GL_DEBUG_OUTPUT);
            glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
        }
        public IFeatures FetchTiles(BoundingBox boundingBox, double resolution)
        {
            Extent extent = new Extent(boundingBox.Min.X, boundingBox.Min.Y, boundingBox.Max.X, boundingBox.Max.Y);
            int level = BruTile.Utilities.GetNearestLevel(source.Schema.Resolutions, resolution);
            IList<TileInfo> tiles = source.Schema.GetTilesInView(extent, level);

            ICollection<WaitHandle> waitHandles = new List<WaitHandle>();
                        
            foreach (TileInfo info in tiles)    
            {
                if (bitmaps.Find(info.Index) != null) continue;
                if (queue.Contains(info.Index)) continue;
                AutoResetEvent waitHandle = new AutoResetEvent(false);
                waitHandles.Add(waitHandle);
                queue.Add(info.Index);

                Thread thread = new Thread(GetTileOnThread);
                thread.Start(new object[] { source.Provider, info, bitmaps, waitHandle });
                //!!!ThreadPool.QueueUserWorkItem(GetTileOnThread, new object[] { source.Provider, info, bitmaps, waitHandle });
            }

            //foreach (WaitHandle handle in waitHandles)
            //    handle.WaitOne();

            IFeatures features = new Features();
            foreach (TileInfo info in tiles)
            {
                byte[] bitmap = bitmaps.Find(info.Index);
                if (bitmap == null) continue;
                IRaster raster = new Raster(bitmap, new BoundingBox(info.Extent.MinX, info.Extent.MinY, info.Extent.MaxX, info.Extent.MaxY));
                IFeature feature = features.New();
                feature.Geometry = raster;
                features.Add(feature);
            }
            return features;
        }
Beispiel #39
0
        /// <summary>
        /// Attempt to translated the provided untranslated text. Will be used in a "coroutine",
        /// so it can be implemented in an asynchronous fashion.
        /// </summary>
        public IEnumerator Translate(ITranslationContext context)
        {
            EnsureInitialized();

            while (_initializing && !_failed)
            {
                var instruction = Features.GetWaitForSecondsRealtime(0.2f);
                if (instruction != null)
                {
                    yield return(instruction);
                }
                else
                {
                    yield return(null);
                }
            }

            if (_failed)
            {
                context.Fail("External process failed.");
            }

            var totalDelay    = (float)(Rng.Next((int)((MaxDelay - MinDelay) * 1000)) + (MinDelay * 1000)) / 1000;
            var timeSinceLast = TimeSupport.Time.realtimeSinceStartup - _lastRequestTimestamp;

            if (timeSinceLast < totalDelay)
            {
                var remainingDelay = totalDelay - timeSinceLast;

                var instruction = Features.GetWaitForSecondsRealtime(remainingDelay);
                if (instruction != null)
                {
                    yield return(instruction);
                }
                else
                {
                    float start = TimeSupport.Time.realtimeSinceStartup;
                    var   end   = start + remainingDelay;
                    while (TimeSupport.Time.realtimeSinceStartup < end)
                    {
                        yield return(null);
                    }
                }
            }
            _lastRequestTimestamp = TimeSupport.Time.realtimeSinceStartup;

            var result = new ProtocolTransactionHandle();
            var id     = Guid.NewGuid();

            lock ( _sync )
            {
                _transactionHandles[id] = result;
            }

            try
            {
                var request = new TranslationRequest
                {
                    Id                    = id,
                    SourceLanguage        = context.SourceLanguage,
                    DestinationLanguage   = context.DestinationLanguage,
                    UntranslatedTextInfos = context.UntranslatedTextInfos.Select(x => x.ToTransmittable()).ToArray()
                };
                var payload = ExtProtocolConvert.Encode(request);

                _process.StandardInput.WriteLine(payload);
            }
            catch (Exception e)
            {
                result.SetCompleted(null, e.Message, StatusCode.Unknown);
            }

            // yield-wait for completion
            var iterator = result.GetSupportedEnumerator();

            while (iterator.MoveNext())
            {
                yield return(iterator.Current);
            }

            if (!result.Succeeded)
            {
                context.Fail("Error occurred while retrieving translation. " + result.Error);
            }

            context.Complete(result.Results);
        }
Beispiel #40
0
 public virtual bool train(Features data) {
   bool ret = modshogunPINVOKE.Machine_train__SWIG_0(swigCPtr, Features.getCPtr(data));
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Beispiel #41
0
 public void DisableFeature(GameFeatures feature) => Features.Set((int)feature, false);
Beispiel #42
0
        /// <summary>
        ///     Updates the plots with data stored in the cache.
        /// </summary>
        private void UpdatePlotsWithClusterData(UMCClusterLightMatched matchedCluster)
        {
            //TODO: Make this select mass!
            ClusterMassPlot = ScatterPlotFactory.CreateFeatureMassScatterPlot(matchedCluster.Cluster.Features);

            //TODO: Make this select drift time!
            ClusterDriftPlot = ScatterPlotFactory.CreateFeatureDriftTimeScatterPlot(matchedCluster.Cluster.Features);

            var cluster = matchedCluster.Cluster;

            // Then we find all the nearby clusters
            var massPpm = ClusterTolerances.Mass;
            var net     = ClusterTolerances.Net;


            //TODO: Add other clusters back
            // var minMass = FeatureLight.ComputeDaDifferenceFromPPM(cluster.MassMonoisotopic, massPpm);
            //var maxMass = FeatureLight.ComputeDaDifferenceFromPPM(cluster.MassMonoisotopic, -massPpm);
            //var minNet = cluster.Net - net;
            //var maxNet = cluster.Net + net;

            //var otherClusters
            //    = SingletonDataProviders.Providers.ClusterCache.FindNearby(minMass, maxMass, minNet, maxNet);

            //// Remove self from the list
            //var index = otherClusters.FindIndex(x => x.Id == cluster.Id);

            //if (index > -1)
            //{
            //    otherClusters.RemoveAt(index);
            //}


            //// Then find the matching clusters and map them back to previously matched (to mass tag data)
            //var otherClusterMatches = new List<UMCClusterLightMatched>();
            //otherClusters.ForEach(x => otherClusterMatches.Add(FeatureCacheManager<UMCClusterLightMatched>.FindById(x.Id)));

            //foreach (var matchedOtherCluster in otherClusterMatches)
            //{
            //    matchedOtherCluster.Cluster.Features.Clear();
            //    matchedOtherCluster.Cluster.ReconstructUMCCluster(SingletonDataProviders.Providers, false, false);
            //}


            // Map out the MS/MS spectra.
            var msmsFeatures = new List <MSFeatureMsMs>();

            foreach (var feature in cluster.Features)
            {
                foreach (var msFeature in feature.MsFeatures)
                {
                    msmsFeatures.AddRange(msFeature.MSnSpectra.Select(spectrum => new MSFeatureMsMs
                    {
                        FeatureID               = msFeature.Id,
                        FeatureGroupID          = msFeature.GroupId,
                        Mz                      = msFeature.Mz,
                        PrecursorMZ             = spectrum.PrecursorMz,
                        FeatureScan             = msFeature.Scan,
                        MsMsScan                = spectrum.Scan,
                        MassMonoisotopicAligned = msFeature.MassMonoisotopicAligned,
                        ChargeState             = msFeature.ChargeState,
                        Sequence                = "",
                        PeptideSequence         = ""
                    }));
                }
            }


            var features = new List <UMCLight>();

            features.AddRange(matchedCluster.Cluster.Features);

            Features.Clear();
            features.ForEach(x => Features.Add(new UMCTreeViewModel(x)));
            SelectedFeature = Features[0];
        }
Beispiel #43
0
        public void SetClientVersion(int version)
        {
            if (ClientVersion == version)
            {
                return;
            }

            if (IsGameRunning)
            {
                throw new System.Exception("Unable to change client version while online");
            }

            if (version != 0 && (version < 740 || version > 1099))
            {
                throw new System.Exception(string.Format("Client version {0} not supported", version));
            }

            Features.SetAll(false); // reset all

            if (version >= 770)
            {
                EnableFeature(GameFeatures.GameLooktypeU16);
                EnableFeature(GameFeatures.GameMessageStatements);
                EnableFeature(GameFeatures.GameLoginPacketEncryption);
            }

            if (version >= 780)
            {
                EnableFeature(GameFeatures.GamePlayerAddons);
                EnableFeature(GameFeatures.GamePlayerStamina);
                EnableFeature(GameFeatures.GameNewFluids);
                EnableFeature(GameFeatures.GameMessageLevel);
                EnableFeature(GameFeatures.GamePlayerStateU16);
                EnableFeature(GameFeatures.GameNewOutfitProtocol);
            }

            if (version >= 790)
            {
                EnableFeature(GameFeatures.GameWritableDate);
            }

            if (version >= 840)
            {
                EnableFeature(GameFeatures.GameProtocolChecksum);
                EnableFeature(GameFeatures.GameAccountNames);
                EnableFeature(GameFeatures.GameDoubleFreeCapacity);
            }

            if (version >= 841)
            {
                EnableFeature(GameFeatures.GameChallengeOnLogin);
                EnableFeature(GameFeatures.GameMessageSizeCheck);
            }

            if (version >= 854)
            {
                EnableFeature(GameFeatures.GameCreatureEmblems);
            }

            if (version >= 860)
            {
                EnableFeature(GameFeatures.GameAttackSeq);
            }

            if (version >= 862)
            {
                EnableFeature(GameFeatures.GamePenalityOnDeath);
            }

            if (version >= 870)
            {
                EnableFeature(GameFeatures.GameDoubleExperience);
                EnableFeature(GameFeatures.GamePlayerMounts);
                EnableFeature(GameFeatures.GameSpellList);
            }

            if (version >= 910)
            {
                EnableFeature(GameFeatures.GameNameOnNpcTrade);
                EnableFeature(GameFeatures.GameTotalCapacity);
                EnableFeature(GameFeatures.GameSkillsBase);
                EnableFeature(GameFeatures.GamePlayerRegenerationTime);
                EnableFeature(GameFeatures.GameChannelPlayerList);
                EnableFeature(GameFeatures.GameEnvironmentEffect);
                EnableFeature(GameFeatures.GameItemAnimationPhase);
            }

            if (version >= 940)
            {
                EnableFeature(GameFeatures.GamePlayerMarket);
            }

            if (version >= 953)
            {
                EnableFeature(GameFeatures.GamePurseSlot);
                EnableFeature(GameFeatures.GameClientPing);
            }

            if (version >= 960)
            {
                EnableFeature(GameFeatures.GameSpritesU32);
                EnableFeature(GameFeatures.GameOfflineTrainingTime);
            }

            if (version >= 963)
            {
                EnableFeature(GameFeatures.GameAdditionalVipInfo);
            }

            if (version >= 980)
            {
                EnableFeature(GameFeatures.GamePreviewState);
                EnableFeature(GameFeatures.GameClientVersion);
            }

            if (version >= 981)
            {
                EnableFeature(GameFeatures.GameLoginPending);
                EnableFeature(GameFeatures.GameNewSpeedLaw);
            }

            if (version >= 984)
            {
                EnableFeature(GameFeatures.GameContainerPagination);
                EnableFeature(GameFeatures.GameBrowseField);
            }

            if (version >= 1000)
            {
                EnableFeature(GameFeatures.GameThingMarks);
                EnableFeature(GameFeatures.GamePVPMode);
            }

            if (version >= 1035)
            {
                EnableFeature(GameFeatures.GameDoubleSkills);
                EnableFeature(GameFeatures.GameBaseSkillU16);
            }

            if (version >= 1036)
            {
                EnableFeature(GameFeatures.GameCreatureIcons);
                EnableFeature(GameFeatures.GameHideNpcNames);
            }

            if (version >= 1038)
            {
                EnableFeature(GameFeatures.GamePremiumExpiration);
            }

            if (version >= 1050)
            {
                EnableFeature(GameFeatures.GameEnhancedAnimations);
            }

            if (version >= 1053)
            {
                EnableFeature(GameFeatures.GameUnjustifiedPoints);
            }

            if (version >= 1054)
            {
                EnableFeature(GameFeatures.GameExperienceBonus);
            }

            if (version >= 1055)
            {
                EnableFeature(GameFeatures.GameDeathType);
            }

            if (version >= 1057)
            {
                EnableFeature(GameFeatures.GameIdleAnimations);
            }

            if (version >= 1061)
            {
                EnableFeature(GameFeatures.GameOGLInformation);
            }

            if (version >= 1071)
            {
                EnableFeature(GameFeatures.GameContentRevision);
            }

            if (version >= 1072)
            {
                EnableFeature(GameFeatures.GameAuthenticator);
            }

            if (version >= 1074)
            {
                EnableFeature(GameFeatures.GameSessionKey);
            }

            if (version >= 1080)
            {
                EnableFeature(GameFeatures.GameIngameStore);
            }

            if (version >= 1092)
            {
                EnableFeature(GameFeatures.GameIngameStoreServiceType);
            }

            if (version >= 1093)
            {
                EnableFeature(GameFeatures.GameIngameStoreHighlights);
            }

            if (version >= 1094)
            {
                EnableFeature(GameFeatures.GameAdditionalSkills);
            }

            if (version >= 1102)
            {
                EnableFeature(GameFeatures.GameWorldName);
            }

            if (version >= 1132)
            {
                DisableFeature(GameFeatures.GameProtocolChecksum);
                EnableFeature(GameFeatures.GameProtocolSequenceNumber);
            }

            int oldVersion = ClientVersion;

            ClientVersion = version;

            onClientVersionChange.Invoke(oldVersion, ClientVersion);
        }
Beispiel #44
0
 public WixFeature FeatureById(string id)
 {
     return(Features.Where(f => f.Id == id).AssertSingle());
 }
Beispiel #45
0
        ScanResults Scsi()
        {
            var     results = new ScanResults();
            MhddLog mhddLog;
            IbgLog  ibgLog;

            byte[] senseBuf;
            bool   sense = false;

            results.Blocks = 0;
            uint   blockSize      = 0;
            ushort currentProfile = 0x0001;

            if (dev.IsRemovable)
            {
                sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);

                if (sense)
                {
                    InitProgress?.Invoke();
                    FixedSense?decSense = Sense.DecodeFixed(senseBuf);

                    if (decSense.HasValue)
                    {
                        if (decSense.Value.ASC == 0x3A)
                        {
                            int leftRetries = 5;

                            while (leftRetries > 0)
                            {
                                PulseProgress?.Invoke("Waiting for drive to become ready");
                                Thread.Sleep(2000);
                                sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);

                                if (!sense)
                                {
                                    break;
                                }

                                leftRetries--;
                            }

                            if (sense)
                            {
                                StoppingErrorMessage?.Invoke("Please insert media in drive");

                                return(results);
                            }
                        }
                        else if (decSense.Value.ASC == 0x04 &&
                                 decSense.Value.ASCQ == 0x01)
                        {
                            int leftRetries = 10;

                            while (leftRetries > 0)
                            {
                                PulseProgress?.Invoke("Waiting for drive to become ready");
                                Thread.Sleep(2000);
                                sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);

                                if (!sense)
                                {
                                    break;
                                }

                                leftRetries--;
                            }

                            if (sense)
                            {
                                StoppingErrorMessage?.
                                Invoke($"Error testing unit was ready:\n{Sense.PrettifySense(senseBuf)}");

                                return(results);
                            }
                        }

                        // These should be trapped by the OS but seems in some cases they're not
                        else if (decSense.Value.ASC == 0x28)
                        {
                            int leftRetries = 10;

                            while (leftRetries > 0)
                            {
                                PulseProgress?.Invoke("Waiting for drive to become ready");
                                Thread.Sleep(2000);
                                sense = dev.ScsiTestUnitReady(out senseBuf, dev.Timeout, out _);

                                if (!sense)
                                {
                                    break;
                                }

                                leftRetries--;
                            }

                            if (sense)
                            {
                                StoppingErrorMessage?.
                                Invoke($"Error testing unit was ready:\n{Sense.PrettifySense(senseBuf)}");

                                return(results);
                            }
                        }
                        else
                        {
                            StoppingErrorMessage?.
                            Invoke($"Error testing unit was ready:\n{Sense.PrettifySense(senseBuf)}");

                            return(results);
                        }
                    }
                    else
                    {
                        StoppingErrorMessage?.Invoke("Unknown testing unit was ready.");

                        return(results);
                    }

                    EndProgress?.Invoke();
                }
            }

            Reader scsiReader = null;

            switch (dev.ScsiType)
            {
            case PeripheralDeviceTypes.DirectAccess:
            case PeripheralDeviceTypes.MultiMediaDevice:
            case PeripheralDeviceTypes.OCRWDevice:
            case PeripheralDeviceTypes.OpticalDevice:
            case PeripheralDeviceTypes.SimplifiedDevice:
            case PeripheralDeviceTypes.WriteOnceDevice:
                scsiReader     = new Reader(dev, dev.Timeout, null);
                results.Blocks = scsiReader.GetDeviceBlocks();

                if (scsiReader.FindReadCommand())
                {
                    StoppingErrorMessage?.Invoke("Unable to read medium.");

                    return(results);
                }

                blockSize = scsiReader.LogicalBlockSize;

                if (results.Blocks != 0 &&
                    blockSize != 0)
                {
                    results.Blocks++;

                    UpdateStatus?.
                    Invoke($"Media has {results.Blocks} blocks of {blockSize} bytes/each. (for a total of {results.Blocks * (ulong)blockSize} bytes)");
                }

                break;

            case PeripheralDeviceTypes.SequentialAccess:
                StoppingErrorMessage?.Invoke("Scanning will never be supported on SCSI Streaming Devices." +
                                             Environment.NewLine +
                                             "It has no sense to do it, and it will put too much strain on the tape.");

                return(results);
            }

            if (results.Blocks == 0)
            {
                StoppingErrorMessage?.Invoke("Unable to read medium or empty medium present...");

                return(results);
            }

            bool compactDisc = true;

            FullTOC.CDFullTOC?toc = null;

            if (dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
            {
                sense = dev.GetConfiguration(out byte[] cmdBuf, out senseBuf, 0, MmcGetConfigurationRt.Current,
                                             dev.Timeout, out _);

                if (!sense)
                {
                    Features.SeparatedFeatures ftr = Features.Separate(cmdBuf);

                    currentProfile = ftr.CurrentProfile;

                    switch (ftr.CurrentProfile)
                    {
                    case 0x0005:
                    case 0x0008:
                    case 0x0009:
                    case 0x000A:
                    case 0x0020:
                    case 0x0021:
                    case 0x0022: break;

                    default:
                        compactDisc = false;

                        break;
                    }
                }

                if (compactDisc)
                {
                    currentProfile = 0x0008;

                    // We discarded all discs that falsify a TOC before requesting a real TOC
                    // No TOC, no CD (or an empty one)
                    bool tocSense = dev.ReadRawToc(out cmdBuf, out senseBuf, 1, dev.Timeout, out _);

                    if (!tocSense)
                    {
                        toc = FullTOC.Decode(cmdBuf);
                    }
                }
            }
            else
            {
                compactDisc = false;
            }

            uint blocksToRead = 64;

            results.A       = 0; // <3ms
            results.B       = 0; // >=3ms, <10ms
            results.C       = 0; // >=10ms, <50ms
            results.D       = 0; // >=50ms, <150ms
            results.E       = 0; // >=150ms, <500ms
            results.F       = 0; // >=500ms
            results.Errored = 0;
            DateTime start;
            DateTime end;

            results.ProcessingTime = 0;
            results.TotalTime      = 0;
            double currentSpeed = 0;

            results.MaxSpeed          = double.MinValue;
            results.MinSpeed          = double.MaxValue;
            results.UnreadableSectors = new List <ulong>();

            if (compactDisc)
            {
                if (toc == null)
                {
                    StoppingErrorMessage?.Invoke("Error trying to decode TOC...");

                    return(results);
                }

                bool readcd = !dev.ReadCd(out _, out senseBuf, 0, 2352, 1, MmcSectorTypes.AllTypes, false, false, true,
                                          MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None, MmcSubchannel.None,
                                          dev.Timeout, out _);

                if (readcd)
                {
                    UpdateStatus?.Invoke("Using MMC READ CD command.");
                }

                start = DateTime.UtcNow;

                while (true)
                {
                    if (readcd)
                    {
                        sense = dev.ReadCd(out _, out senseBuf, 0, 2352, blocksToRead, MmcSectorTypes.AllTypes, false,
                                           false, true, MmcHeaderCodes.AllHeaders, true, true, MmcErrorField.None,
                                           MmcSubchannel.None, dev.Timeout, out _);

                        if (dev.Error)
                        {
                            blocksToRead /= 2;
                        }
                    }

                    if (!dev.Error ||
                        blocksToRead == 1)
                    {
                        break;
                    }
                }

                if (dev.Error)
                {
                    StoppingErrorMessage?.
                    Invoke($"Device error {dev.LastError} trying to guess ideal transfer length.");

                    return(results);
                }

                UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time.");

                InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, currentProfile);
                mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead, false);
                ibgLog  = new IbgLog(ibgLogPath, currentProfile);
                DateTime timeSpeedStart   = DateTime.UtcNow;
                ulong    sectorSpeedStart = 0;

                InitProgress?.Invoke();

                for (ulong i = 0; i < results.Blocks; i += blocksToRead)
                {
                    if (aborted)
                    {
                        break;
                    }

                    double cmdDuration = 0;

                    if (results.Blocks - i < blocksToRead)
                    {
                        blocksToRead = (uint)(results.Blocks - i);
                    }

                    #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
                    if (currentSpeed > results.MaxSpeed &&
                        currentSpeed != 0)
                    {
                        results.MaxSpeed = currentSpeed;
                    }

                    if (currentSpeed < results.MinSpeed &&
                        currentSpeed != 0)
                    {
                        results.MinSpeed = currentSpeed;
                    }
                    #pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator

                    UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)",
                                           (long)i, (long)results.Blocks);

                    if (readcd)
                    {
                        sense = dev.ReadCd(out _, out senseBuf, (uint)i, 2352, blocksToRead, MmcSectorTypes.AllTypes,
                                           false, false, true, MmcHeaderCodes.AllHeaders, true, true,
                                           MmcErrorField.None, MmcSubchannel.None, dev.Timeout, out cmdDuration);

                        results.ProcessingTime += cmdDuration;
                    }

                    if (!sense)
                    {
                        if (cmdDuration >= 500)
                        {
                            results.F += blocksToRead;
                        }
                        else if (cmdDuration >= 150)
                        {
                            results.E += blocksToRead;
                        }
                        else if (cmdDuration >= 50)
                        {
                            results.D += blocksToRead;
                        }
                        else if (cmdDuration >= 10)
                        {
                            results.C += blocksToRead;
                        }
                        else if (cmdDuration >= 3)
                        {
                            results.B += blocksToRead;
                        }
                        else
                        {
                            results.A += blocksToRead;
                        }

                        ScanTime?.Invoke(i, cmdDuration);
                        mhddLog.Write(i, cmdDuration);
                        ibgLog.Write(i, currentSpeed * 1024);
                    }
                    else
                    {
                        AaruConsole.DebugWriteLine("Media-Scan", "READ CD error:\n{0}", Sense.PrettifySense(senseBuf));

                        FixedSense?senseDecoded = Sense.DecodeFixed(senseBuf);

                        if (senseDecoded.HasValue)
                        {
                            // TODO: This error happens when changing from track type afaik. Need to solve that more cleanly
                            // LOGICAL BLOCK ADDRESS OUT OF RANGE
                            if ((senseDecoded.Value.ASC != 0x21 || senseDecoded.Value.ASCQ != 0x00) &&

                                // ILLEGAL MODE FOR THIS TRACK (requesting sectors as-is, this is a firmware misconception when audio sectors
                                // are in a track where subchannel indicates data)
                                (senseDecoded.Value.ASC != 0x64 || senseDecoded.Value.ASCQ != 0x00))
                            {
                                results.Errored += blocksToRead;

                                for (ulong b = i; b < i + blocksToRead; b++)
                                {
                                    results.UnreadableSectors.Add(b);
                                }

                                ScanUnreadable?.Invoke(i);
                                mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);

                                ibgLog.Write(i, 0);
                            }
                        }
                        else
                        {
                            ScanUnreadable?.Invoke(i);
                            results.Errored += blocksToRead;

                            for (ulong b = i; b < i + blocksToRead; b++)
                            {
                                results.UnreadableSectors.Add(b);
                            }

                            mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);

                            ibgLog.Write(i, 0);
                        }
                    }

                    sectorSpeedStart += blocksToRead;

                    double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds;

                    if (elapsed < 1)
                    {
                        continue;
                    }

                    currentSpeed = (sectorSpeedStart * blockSize) / (1048576 * elapsed);
                    ScanSpeed?.Invoke(i, currentSpeed * 1024);
                    sectorSpeedStart = 0;
                    timeSpeedStart   = DateTime.UtcNow;
                }

                end = DateTime.UtcNow;
                EndProgress?.Invoke();
                mhddLog.Close();

                ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
                             (blockSize * (double)(results.Blocks + 1)) / 1024 /
                             (results.ProcessingTime / 1000),
                             devicePath);
            }
            else
            {
                start = DateTime.UtcNow;

                UpdateStatus?.Invoke($"Reading {blocksToRead} sectors at a time.");

                InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, currentProfile);
                mhddLog = new MhddLog(mhddLogPath, dev, results.Blocks, blockSize, blocksToRead, false);
                ibgLog  = new IbgLog(ibgLogPath, currentProfile);
                DateTime timeSpeedStart   = DateTime.UtcNow;
                ulong    sectorSpeedStart = 0;

                InitProgress?.Invoke();

                for (ulong i = 0; i < results.Blocks; i += blocksToRead)
                {
                    if (aborted)
                    {
                        break;
                    }

                    if (results.Blocks - i < blocksToRead)
                    {
                        blocksToRead = (uint)(results.Blocks - i);
                    }

                    #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
                    if (currentSpeed > results.MaxSpeed &&
                        currentSpeed != 0)
                    {
                        results.MaxSpeed = currentSpeed;
                    }

                    if (currentSpeed < results.MinSpeed &&
                        currentSpeed != 0)
                    {
                        results.MinSpeed = currentSpeed;
                    }
                    #pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator

                    UpdateProgress?.Invoke($"Reading sector {i} of {results.Blocks} ({currentSpeed:F3} MiB/sec.)",
                                           (long)i, (long)results.Blocks);

                    sense = scsiReader.ReadBlocks(out _, i, blocksToRead, out double cmdDuration);
                    results.ProcessingTime += cmdDuration;

                    if (!sense &&
                        !dev.Error)
                    {
                        if (cmdDuration >= 500)
                        {
                            results.F += blocksToRead;
                        }
                        else if (cmdDuration >= 150)
                        {
                            results.E += blocksToRead;
                        }
                        else if (cmdDuration >= 50)
                        {
                            results.D += blocksToRead;
                        }
                        else if (cmdDuration >= 10)
                        {
                            results.C += blocksToRead;
                        }
                        else if (cmdDuration >= 3)
                        {
                            results.B += blocksToRead;
                        }
                        else
                        {
                            results.A += blocksToRead;
                        }

                        ScanTime?.Invoke(i, cmdDuration);
                        mhddLog.Write(i, cmdDuration);
                        ibgLog.Write(i, currentSpeed * 1024);
                    }

                    // TODO: Separate errors on kind of errors.
                    else
                    {
                        ScanUnreadable?.Invoke(i);
                        results.Errored += blocksToRead;

                        for (ulong b = i; b < i + blocksToRead; b++)
                        {
                            results.UnreadableSectors.Add(b);
                        }

                        mhddLog.Write(i, cmdDuration < 500 ? 65535 : cmdDuration);
                        ibgLog.Write(i, 0);
                    }

                    sectorSpeedStart += blocksToRead;

                    double elapsed = (DateTime.UtcNow - timeSpeedStart).TotalSeconds;

                    if (elapsed < 1)
                    {
                        continue;
                    }

                    currentSpeed = (sectorSpeedStart * blockSize) / (1048576 * elapsed);
                    ScanSpeed?.Invoke(i, currentSpeed * 1024);
                    sectorSpeedStart = 0;
                    timeSpeedStart   = DateTime.UtcNow;
                }

                end = DateTime.UtcNow;
                EndProgress?.Invoke();
                mhddLog.Close();

                ibgLog.Close(dev, results.Blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
                             (blockSize * (double)(results.Blocks + 1)) / 1024 /
                             (results.ProcessingTime / 1000),
                             devicePath);
            }

            results.SeekMax   = double.MinValue;
            results.SeekMin   = double.MaxValue;
            results.SeekTotal = 0;
            const int SEEK_TIMES = 1000;

            var rnd = new Random();

            InitProgress?.Invoke();

            for (int i = 0; i < SEEK_TIMES; i++)
            {
                if (aborted)
                {
                    break;
                }

                uint seekPos = (uint)rnd.Next((int)results.Blocks);

                PulseProgress?.Invoke($"Seeking to sector {seekPos}...\t\t");

                double seekCur;

                if (scsiReader.CanSeek)
                {
                    scsiReader.Seek(seekPos, out seekCur);
                }
                else
                {
                    scsiReader.ReadBlock(out _, seekPos, out seekCur);
                }

                #pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
                if (seekCur > results.SeekMax &&
                    seekCur != 0)
                {
                    results.SeekMax = seekCur;
                }

                if (seekCur < results.SeekMin &&
                    seekCur != 0)
                {
                    results.SeekMin = seekCur;
                }
                #pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator

                results.SeekTotal += seekCur;
                GC.Collect();
            }

            EndProgress?.Invoke();

            results.ProcessingTime /= 1000;
            results.TotalTime       = (end - start).TotalSeconds;
            results.AvgSpeed        = (blockSize * (double)(results.Blocks + 1)) / 1048576 / results.ProcessingTime;
            results.SeekTimes       = SEEK_TIMES;

            return(results);
        }
 public abstract Feature GetFeature(Features feature, string name, int rating, float price, string type);
        /// <summary>
        /// Analyze text.
        ///
        /// Analyzes text, HTML, or a public webpage for the following features:
        /// - Categories
        /// - Concepts
        /// - Emotion
        /// - Entities
        /// - Keywords
        /// - Metadata
        /// - Relations
        /// - Semantic roles
        /// - Sentiment
        /// - Syntax.
        ///
        /// If a language for the input text is not specified with the `language` parameter, the service [automatically
        /// detects the
        /// language](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-detectable-languages).
        /// </summary>
        /// <param name="parameters">An object containing request parameters. The `features` object and one of the
        /// `text`, `html`, or `url` attributes are required.</param>
        /// <returns><see cref="AnalysisResults" />AnalysisResults</returns>
        public DetailedResponse <AnalysisResults> Analyze(Features features, string text = null, string html = null, string url = null, bool?clean = null, string xpath = null, bool?fallbackToRaw = null, bool?returnAnalyzedText = null, string language = null, long?limitTextCharacters = null)
        {
            if (features == null)
            {
                throw new ArgumentNullException("`features` is required for `Analyze`");
            }

            if (string.IsNullOrEmpty(VersionDate))
            {
                throw new ArgumentNullException("versionDate cannot be null.");
            }

            DetailedResponse <AnalysisResults> result = null;

            try
            {
                IClient client = this.Client;
                SetAuthentication();

                var restRequest = client.PostAsync($"{this.Endpoint}/v1/analyze");

                restRequest.WithArgument("version", VersionDate);
                restRequest.WithHeader("Accept", "application/json");
                restRequest.WithHeader("Content-Type", "application/json");

                JObject bodyObject = new JObject();
                if (features != null)
                {
                    bodyObject["features"] = JToken.FromObject(features);
                }
                if (!string.IsNullOrEmpty(text))
                {
                    bodyObject["text"] = text;
                }
                if (!string.IsNullOrEmpty(html))
                {
                    bodyObject["html"] = html;
                }
                if (!string.IsNullOrEmpty(url))
                {
                    bodyObject["url"] = url;
                }
                if (clean != null)
                {
                    bodyObject["clean"] = JToken.FromObject(clean);
                }
                if (!string.IsNullOrEmpty(xpath))
                {
                    bodyObject["xpath"] = xpath;
                }
                if (fallbackToRaw != null)
                {
                    bodyObject["fallback_to_raw"] = JToken.FromObject(fallbackToRaw);
                }
                if (returnAnalyzedText != null)
                {
                    bodyObject["return_analyzed_text"] = JToken.FromObject(returnAnalyzedText);
                }
                if (!string.IsNullOrEmpty(language))
                {
                    bodyObject["language"] = language;
                }
                if (limitTextCharacters != null)
                {
                    bodyObject["limit_text_characters"] = JToken.FromObject(limitTextCharacters);
                }
                var httpContent = new StringContent(JsonConvert.SerializeObject(bodyObject), Encoding.UTF8, HttpMediaType.APPLICATION_JSON);
                restRequest.WithBodyContent(httpContent);

                restRequest.WithHeaders(Common.GetSdkHeaders("natural-language-understanding", "v1", "Analyze"));
                restRequest.WithHeaders(customRequestHeaders);
                ClearCustomRequestHeaders();

                result = restRequest.As <AnalysisResults>().Result;
                if (result == null)
                {
                    result = new DetailedResponse <AnalysisResults>();
                }
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
 /// <summary>
 /// Abstract method - overwritten by derived classes for producing instances
 /// derived from <see cref="Mapsui.Geometries.Geometry"/>.
 /// </summary>
 internal abstract Collection <Geometry> CreateGeometries(Features features);
 public MultiquadricKernel(Features l, Features r, double coef, Distance dist) : this(modshogunPINVOKE.new_MultiquadricKernel__SWIG_2(Features.getCPtr(l), Features.getCPtr(r), coef, Distance.getCPtr(dist)), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Beispiel #50
0
        public ConfigUnicastBus DoNotAutoSubscribe()
        {
            Features.Disable <AutoSubscribe>();

            return(this);
        }
 public virtual bool apply_to_string_features(Features f) {
   bool ret = modshogunPINVOKE.StringCharPreprocessor_apply_to_string_features(swigCPtr, Features.getCPtr(f));
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Beispiel #52
0
 public ConfigUnicastBus DoNotAutoSubscribeSagas()
 {
     Features.AutoSubscribe(f => f.DoNotAutoSubscribeSagas());
     //ApplyDefaultAutoSubscriptionStrategy.DoNotAutoSubscribeSagas = true;
     return(this);
 }
Beispiel #53
0
 public ConstKernel(Features l, Features r, double c) : this(modshogunPINVOKE.new_ConstKernel__SWIG_2(Features.getCPtr(l), Features.getCPtr(r), c), true) {
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
 }
Beispiel #54
0
 public ConfigUnicastBus AllowSubscribeToSelf()
 {
     Features.AutoSubscribe(f => f.DoNotRequireExplicitRouting());
     return(this);
 }
Beispiel #55
0
 public override bool train(Features data) {
   bool ret = modshogunPINVOKE.Histogram_train__SWIG_0(swigCPtr, Features.getCPtr(data));
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Beispiel #56
0
 public ConfigUnicastBus AutoSubscribePlainMessages()
 {
     Features.AutoSubscribe(f => f.AutoSubscribePlainMessages());
     return(this);
 }
Beispiel #57
0
 public virtual Labels apply(Features data) {
   IntPtr cPtr = modshogunPINVOKE.Machine_apply__SWIG_1(swigCPtr, Features.getCPtr(data));
   Labels ret = (cPtr == IntPtr.Zero) ? null : new Labels(cPtr, true);
   if (modshogunPINVOKE.SWIGPendingException.Pending) throw modshogunPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
Beispiel #58
0
 public bool GetFeature(string feature)
 {
     return(!string.IsNullOrEmpty(Features) && Features.Split(' ', ',', ';').Contains(feature));
 }
        public IEnumerable<IFeature> GetFeaturesInView(BoundingBox box, double resolution)
        {
            //If there are no layers (probably not initialised) return nothing
            if (Capabilities.layers == null)
                return new Features();

            IFeatures features = new Features();
            IRaster raster = null;
            IViewport viewport = new Viewport { Resolution = resolution, Center = box.GetCentroid(), Width = (box.Width / resolution), Height = (box.Height / resolution) };
            if (TryGetMap(viewport, ref raster))
            {
                var feature = features.New();
                feature.Geometry = raster;
                features.Add(feature);
            }
            return features;
        }
Beispiel #60
0
 /// <summary>
 /// Constructs an EmissionUIBlock based on the parameters.
 /// </summary>
 /// <param name="expandableBit">Bit index used to store the foldout state.</param>
 /// <param name="features">Features of the block.</param>
 public EmissionUIBlock(ExpandableBit expandableBit, Features features = Features.All)
     : base(expandableBit, Styles.header)
 {
     m_Features = features;
 }