static bool Prefix(XmlElement _e) { if (!Configuration.CheckFeatureStatus(AdvFeatureClass, SecondFeature)) { return(true); } PhysicsBodyColliderConfiguration physicsBodyColliderConfiguration = new PhysicsBodyColliderConfiguration(); DynamicProperties dynamicProperties = new DynamicProperties(); foreach (object obj in _e.ChildNodes) { XmlNode xmlNode = (XmlNode)obj; if (xmlNode.NodeType == XmlNodeType.Element && xmlNode.Name.Equals("property")) { dynamicProperties.Add(xmlNode, true); } } AdvLogging.DisplayLog(AdvFeatureClass, "\n======= Physics Bodies ============"); CheckTag(dynamicProperties, "tag"); CheckTag(dynamicProperties, "path"); CheckTag(dynamicProperties, "collisionLayer"); CheckTag(dynamicProperties, "ragdollLayer"); CheckTag(dynamicProperties, "layer"); CheckTag(dynamicProperties, "ragdollScale"); CheckTag(dynamicProperties, "type"); CheckTag(dynamicProperties, "flags"); if (dynamicProperties.Contains("collisionLayer")) { if (!dynamicProperties.Contains("ragdollLayer")) { AdvLogging.DisplayLog(AdvFeatureClass, "\tWARNING: Collision Layer is set, but does not contain a ragdollLayer"); } } else { if (!dynamicProperties.Contains("layer")) { AdvLogging.DisplayLog(AdvFeatureClass, "\tWARNING: Collision Layer IS NOT SET. Falling back to layer property, but that is not found either! "); } } AdvLogging.DisplayLog(AdvFeatureClass, "======= End Physics Bodies ============"); return(true); }
async Task showItem(YoutubeItem item) { YoutubeItemMetadata metaData = item.Metadata as YoutubeItemMetadata; if (metaData == null) { return; } Title = metaData.Title; Rating = metaData.Rating == null ? null : metaData.Rating / 5; Author = metaData.Author; CreationDate = metaData.CreationDate; IsReadOnly = item.IsReadOnly; Tags.Clear(); foreach (Tag tag in metaData.Tags) { Tags.Add(tag); } if (!metaData.Description.EndsWith("...")) { Description = metaData.Description; } else if (item is YoutubeVideoItem) { Video info = await requestVideoInfo((item as YoutubeVideoItem).VideoId); if (info != null) { Description = metaData.Description = info.Snippet.Description; } else { Description = metaData.Description; } } else { Description = metaData.Description; } if (metaData.ViewCount != null) { DynamicProperties.Add(new Tuple <string, string>("Views", metaData.ViewCount.Value.ToString("#,##0", new CultureInfo("en-US")))); } if (metaData.MimeType != null) { DynamicProperties.Add(new Tuple <string, string>("Mime Type", metaData.MimeType)); } if (metaData.Width != null && metaData.Height != null) { DynamicProperties.Add(new Tuple <string, string>("Resolution", metaData.Width + " x " + metaData.Height)); } if (metaData.FramesPerSecond != null) { DynamicProperties.Add(new Tuple <string, string>("Frames Per Second", metaData.FramesPerSecond.Value.ToString())); } if (metaData.DurationSeconds != null) { DynamicProperties.Add(new Tuple <string, string>("Duration", MiscUtils.formatTimeSeconds(metaData.DurationSeconds.Value))); } }
private void ParseTemplate([NotNull] XElement templateElement) { Debug.ArgumentNotNull(templateElement, nameof(templateElement)); var parameterValues = new UrlString(Parameters); DynamicProperties.Clear(); foreach (var field in templateElement.Elements()) { var n = field.GetAttributeValue("name"); if (DynamicProperties.Any(p => p.Name == n)) { continue; } var displayName = field.GetAttributeValue("displayname"); var category = field.GetAttributeValue("category"); var typeName = field.GetAttributeValue("type"); var subType = field.GetAttributeValue("subtype"); var description = field.GetAttributeValue("description"); var bindModeString = field.GetAttributeValue("bindmode"); var editor = field.GetAttributeValue("editor"); var value = HttpUtility.UrlDecode(parameterValues[n] ?? string.Empty); var bindMode = BindingMode.None; if (!string.IsNullOrEmpty(bindModeString)) { Enum.TryParse(bindModeString, out bindMode); } List <Tuple <string, string> > values = null; var valuesElement = field.Element("values"); if (valuesElement != null) { values = new List <Tuple <string, string> >(); foreach (var element in valuesElement.Elements()) { values.Add(new Tuple <string, string>(element.GetAttributeValue("displayname", element.Value), element.Value)); } } parameterValues.Remove(n); object actualValue = null; Type type; if (bindMode == BindingMode.ReadWrite || bindMode == BindingMode.Write || string.Compare(category, @"Data Bindings", StringComparison.InvariantCultureIgnoreCase) == 0) { type = typeof(DataBinding); var bindingValue = value; if (string.Compare(typeName, @"checkbox", StringComparison.InvariantCultureIgnoreCase) == 0) { if (value == @"1" || string.Compare(value, @"true", StringComparison.InvariantCultureIgnoreCase) == 0) { bindingValue = "True"; } else if (value == @"0" || string.Compare(value, @"false", StringComparison.InvariantCultureIgnoreCase) == 0) { bindingValue = "False"; } } if (values != null) { var item = values.FirstOrDefault(i => i.Item2 == bindingValue); if (item != null) { bindingValue = item.Item1; } } actualValue = new DataBinding(bindingValue); } else if (string.Compare(typeName, @"checkbox", StringComparison.InvariantCultureIgnoreCase) == 0) { type = typeof(bool?); if (value == @"1" || string.Compare(value, @"true", StringComparison.InvariantCultureIgnoreCase) == 0) { actualValue = true; } else if (value == @"0" || string.Compare(value, @"false", StringComparison.InvariantCultureIgnoreCase) == 0) { actualValue = false; } } else if (string.Compare(typeName, @"tristate", StringComparison.InvariantCultureIgnoreCase) == 0) { type = typeof(bool?); if (value == @"1" || string.Compare(value, @"true", StringComparison.InvariantCultureIgnoreCase) == 0) { actualValue = true; } else if (value == @"0" || string.Compare(value, @"false", StringComparison.InvariantCultureIgnoreCase) == 0) { actualValue = false; } else if (value == @"-") { actualValue = null; } } else if (string.Compare(typeName, @"datetime", StringComparison.InvariantCultureIgnoreCase) == 0 || string.Compare(typeName, @"date", StringComparison.InvariantCultureIgnoreCase) == 0) { type = typeof(DateTime); actualValue = value != null?DateTimeExtensions.FromIso(value) : DateTime.MinValue; } else if (values != null) { type = typeof(DropDownValue); var item = values.FirstOrDefault(i => i.Item2 == value) ?? new Tuple <string, string>(value, value); actualValue = new DropDownValue(item); } else { type = typeof(string); actualValue = value; } var dynamicProperty = new DynamicProperty(GetType(), n, displayName, type, typeName, category, description, editor, actualValue, this); dynamicProperty.Modified += RaiseModified; dynamicProperty.PropertyChanged += RaisePropertyChanged; if (type == typeof(DataBinding)) { dynamicProperty.Converter = new DataBindingConverter(values); } else if (type == typeof(DropDownValue) && values != null) { dynamicProperty.Converter = new DropDownValueConverter(values); } if (bindMode == BindingMode.Read) { dynamicProperty.IsReadOnly = true; } if (n == "Id") { OldId = value; } dynamicProperty.Attributes["subtype"] = subType; dynamicProperty.Attributes["bindmode"] = bindMode; DynamicProperties.Add(dynamicProperty); } ParameterDictionary.Parameters.Clear(); foreach (string key in parameterValues.Parameters.Keys) { ParameterDictionary.Parameters[key] = parameterValues.Parameters[key]; } }